From 465cfd287daadfde6a60cddc7afc86fbb28551e5 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 28 May 2026 04:11:23 +0000 Subject: [PATCH] Configurations: 'specification/policyinsights/resource-manager/Microsoft.PolicyInsights/PolicyInsights/tspconfig.yaml', API Version: 2024-10-01, SDK Release Type: beta, and CommitSHA: 'cb62053a18882dd258d9922be9770702b7ef6ac9' in SpecRepo: 'https://github.com/Azure/azure-rest-api-specs' Pipeline run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6362432 Refer to https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites to prepare for SDK release. --- .../azure-mgmt-policyinsights/CHANGELOG.md | 307 + .../azure-mgmt-policyinsights/_metadata.json | 15 +- .../apiview-properties.json | 402 +- .../azure/mgmt/policyinsights/__init__.py | 4 +- ...{_policy_insights_client.py => _client.py} | 70 +- .../mgmt/policyinsights/_configuration.py | 10 +- .../azure/mgmt/policyinsights/_patch.py | 13 +- .../mgmt/policyinsights/_utils/__init__.py | 2 +- .../mgmt/policyinsights/_utils/model_base.py | 1755 +++ .../policyinsights/_utils/serialization.py | 31 +- .../azure/mgmt/policyinsights/_version.py | 5 +- .../azure/mgmt/policyinsights/aio/__init__.py | 4 +- ...{_policy_insights_client.py => _client.py} | 70 +- .../mgmt/policyinsights/aio/_configuration.py | 10 +- .../azure/mgmt/policyinsights/aio/_patch.py | 13 +- .../policyinsights/aio/operations/__init__.py | 24 +- .../aio/operations/_operations.py | 8766 +++++++++++- .../policyinsights/aio/operations/_patch.py | 13 +- .../operations/_policy_events_operations.py | 1154 -- .../operations/_policy_metadata_operations.py | 184 - .../_policy_restrictions_operations.py | 277 - .../operations/_policy_states_operations.py | 2089 --- .../_policy_tracked_resources_operations.py | 425 - .../operations/_remediations_operations.py | 1967 --- .../mgmt/policyinsights/models/__init__.py | 60 +- ...icy_insights_client_enums.py => _enums.py} | 50 +- .../mgmt/policyinsights/models/_models.py | 2998 ++++ .../mgmt/policyinsights/models/_models_py3.py | 2702 ---- .../mgmt/policyinsights/models/_patch.py | 13 +- .../policyinsights/operations/__init__.py | 24 +- .../policyinsights/operations/_operations.py | 11760 +++++++++++++++- .../mgmt/policyinsights/operations/_patch.py | 13 +- .../operations/_policy_events_operations.py | 1846 --- .../operations/_policy_metadata_operations.py | 229 - .../_policy_restrictions_operations.py | 343 - .../operations/_policy_states_operations.py | 3235 ----- .../_policy_tracked_resources_operations.py | 589 - .../operations/_remediations_operations.py | 2698 ---- ...ttestations_create_resource_group_scope.py | 61 + .../attestations_create_resource_scope.py | 61 + .../attestations_create_subscription_scope.py | 48 + ...reate_subscription_scope_all_properties.py | 60 + ...ttestations_delete_resource_group_scope.py | 41 + .../attestations_delete_resource_scope.py | 42 + .../attestations_delete_subscription_scope.py | 40 + .../attestations_get_resource_group_scope.py | 42 + .../attestations_get_resource_scope.py | 43 + .../attestations_get_subscription_scope.py | 41 + .../attestations_list_resource_group_scope.py | 42 + ...ns_list_resource_group_scope_with_query.py | 42 + .../attestations_list_resource_scope.py | 43 + ...stations_list_resource_scope_with_query.py | 43 + .../attestations_list_subscription_scope.py | 40 + ...ions_list_subscription_scope_with_query.py | 40 + ...licy_states_query_nested_resource_scope.py | 43 + ...rce_group_level_policy_assignment_scope.py | 44 + ...olicy_states_query_resource_group_scope.py | 43 + ..._group_by_component_type_with_aggregate.py | 43 + ...nent_policy_states_query_resource_scope.py | 43 + ..._scope_expand_policy_evaluation_details.py | 43 + ...y_resource_scope_filter_by_component_id.py | 43 + ..._group_by_component_type_with_aggregate.py | 43 + ...scription_level_policy_assignment_scope.py | 43 + ...scription_level_policy_definition_scope.py | 43 + ..._policy_states_query_subscription_scope.py | 42 + ..._group_by_component_type_with_aggregate.py | 42 + .../operations_list_operations.py | 5 +- ...policy_events_filter_and_aggregate_only.py | 9 +- ...ents_filter_and_group_by_with_aggregate.py | 9 +- ...s_filter_and_group_by_without_aggregate.py | 9 +- ...olicy_events_filter_and_multiple_groups.py | 9 +- ...icy_events_query_management_group_scope.py | 5 +- ..._query_management_group_scope_next_link.py | 5 +- ...licy_events_query_nested_resource_scope.py | 4 +- ...rce_group_level_policy_assignment_scope.py | 9 +- ...level_policy_assignment_scope_next_link.py | 9 +- ...olicy_events_query_resource_group_scope.py | 9 +- ...ts_query_resource_group_scope_next_link.py | 9 +- .../policy_events_query_resource_scope.py | 4 +- ..._query_resource_scope_expand_components.py | 4 +- ...pand_components_group_by_with_aggregate.py | 4 +- ...y_events_query_resource_scope_next_link.py | 4 +- ...ubscription_level_nested_resource_scope.py | 4 +- ...scription_level_policy_assignment_scope.py | 9 +- ...level_policy_assignment_scope_next_link.py | 9 +- ...scription_level_policy_definition_scope.py | 9 +- ...level_policy_definition_scope_next_link.py | 9 +- ...ption_level_policy_set_definition_scope.py | 9 +- ...l_policy_set_definition_scope_next_link.py | 9 +- ...query_subscription_level_resource_scope.py | 4 +- .../policy_events_query_subscription_scope.py | 9 +- ...ents_query_subscription_scope_next_link.py | 9 +- ...olicy_events_time_range_sort_select_top.py | 9 +- .../policy_metadata_get_resource.py | 5 +- .../generated_samples/policy_metadata_list.py | 5 +- .../policy_metadata_list_with_top.py | 5 +- ...ictions_check_at_management_group_scope.py | 42 + ...trictions_check_at_resource_group_scope.py | 7 +- ...source_group_scope_include_audit_effect.py | 53 + ...estrictions_check_at_subscription_scope.py | 7 +- ...subscription_scope_include_audit_effect.py | 52 + ...policy_states_filter_and_aggregate_only.py | 9 +- ...ates_filter_and_group_by_with_aggregate.py | 9 +- ...s_filter_and_group_by_without_aggregate.py | 9 +- ...olicy_states_filter_and_multiple_groups.py | 9 +- ...icy_states_query_management_group_scope.py | 5 +- ..._query_management_group_scope_next_link.py | 5 +- ...licy_states_query_nested_resource_scope.py | 4 +- ...rce_group_level_policy_assignment_scope.py | 9 +- ...level_policy_assignment_scope_next_link.py | 9 +- ...olicy_states_query_resource_group_scope.py | 9 +- ...es_query_resource_group_scope_next_link.py | 9 +- .../policy_states_query_resource_scope.py | 4 +- ..._query_resource_scope_expand_components.py | 4 +- ...pand_components_group_by_with_aggregate.py | 4 +- ..._scope_expand_policy_evaluation_details.py | 4 +- ...y_states_query_resource_scope_next_link.py | 4 +- ...ubscription_level_nested_resource_scope.py | 4 +- ...scription_level_policy_assignment_scope.py | 9 +- ...level_policy_assignment_scope_next_link.py | 9 +- ...scription_level_policy_definition_scope.py | 9 +- ...level_policy_definition_scope_next_link.py | 9 +- ...ption_level_policy_set_definition_scope.py | 9 +- ...l_policy_set_definition_scope_next_link.py | 9 +- ...query_subscription_level_resource_scope.py | 4 +- .../policy_states_query_subscription_scope.py | 9 +- ...ates_query_subscription_scope_next_link.py | 9 +- ...states_summarize_management_group_scope.py | 5 +- ...rce_group_level_policy_assignment_scope.py | 9 +- ...y_states_summarize_resource_group_scope.py | 9 +- .../policy_states_summarize_resource_scope.py | 4 +- ...scription_level_policy_assignment_scope.py | 9 +- ...scription_level_policy_definition_scope.py | 9 +- ...ption_level_policy_set_definition_scope.py | 9 +- ...icy_states_summarize_subscription_scope.py | 9 +- ...ize_subscription_scope_for_policy_group.py | 9 +- ...olicy_states_time_range_sort_select_top.py | 9 +- ...tates_trigger_resource_group_evaluation.py | 7 +- ..._states_trigger_subscription_evaluation.py | 7 +- ..._resources_query_management_group_scope.py | 5 +- ...agement_group_scope_with_filter_and_top.py | 5 +- ...ed_resources_query_resource_group_scope.py | 7 +- ...esource_group_scope_with_filter_and_top.py | 7 +- ..._tracked_resources_query_resource_scope.py | 4 +- ...uery_resource_scope_with_filter_and_top.py | 4 +- ...cked_resources_query_subscription_scope.py | 7 +- ..._subscription_scope_with_filter_and_top.py | 7 +- ...ediations_cancel_management_group_scope.py | 5 +- ...emediations_cancel_resource_group_scope.py | 7 +- .../remediations_cancel_resource_scope.py | 4 +- .../remediations_cancel_subscription_scope.py | 7 +- ...ediations_create_management_group_scope.py | 4 +- ...emediations_create_resource_group_scope.py | 6 +- .../remediations_create_resource_scope.py | 4 +- .../remediations_create_subscription_scope.py | 6 +- ...reate_subscription_scope_all_properties.py | 9 +- ..._subscription_scope_resource_ids_filter.py | 63 + ...ediations_delete_management_group_scope.py | 5 +- ...emediations_delete_resource_group_scope.py | 7 +- .../remediations_delete_resource_scope.py | 4 +- .../remediations_delete_subscription_scope.py | 7 +- ...remediations_get_management_group_scope.py | 5 +- .../remediations_get_resource_group_scope.py | 7 +- .../remediations_get_resource_scope.py | 4 +- .../remediations_get_subscription_scope.py | 7 +- ...list_deployments_management_group_scope.py | 5 +- ...s_list_deployments_resource_group_scope.py | 7 +- ...iations_list_deployments_resource_scope.py | 4 +- ...ons_list_deployments_subscription_scope.py | 7 +- ...emediations_list_management_group_scope.py | 5 +- ..._list_management_group_scope_with_query.py | 5 +- .../remediations_list_resource_group_scope.py | 7 +- ...ns_list_resource_group_scope_with_query.py | 7 +- .../remediations_list_resource_scope.py | 4 +- ...diations_list_resource_scope_with_query.py | 4 +- .../remediations_list_subscription_scope.py | 7 +- ...ions_list_subscription_scope_with_query.py | 7 +- .../generated_tests/conftest.py | 2 +- ...policy_insights_attestations_operations.py | 128 +- ..._insights_attestations_operations_async.py | 128 +- ...ghts_component_policy_states_operations.py | 2 +- ...omponent_policy_states_operations_async.py | 2 +- .../test_policy_insights_operations.py | 4 +- .../test_policy_insights_operations_async.py | 4 +- ...olicy_insights_policy_events_operations.py | 30 +- ...insights_policy_events_operations_async.py | 30 +- ...icy_insights_policy_metadata_operations.py | 6 +- ...sights_policy_metadata_operations_async.py | 6 +- ...insights_policy_restrictions_operations.py | 24 +- ...ts_policy_restrictions_operations_async.py | 24 +- ...olicy_insights_policy_states_operations.py | 62 +- ...insights_policy_states_operations_async.py | 62 +- ...hts_policy_tracked_resources_operations.py | 2 +- ...licy_tracked_resources_operations_async.py | 2 +- ...policy_insights_remediations_operations.py | 330 +- ..._insights_remediations_operations_async.py | 330 +- .../azure-mgmt-policyinsights/pyproject.toml | 7 +- .../tsp-location.yaml | 4 + 198 files changed, 28512 insertions(+), 19020 deletions(-) rename sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/{_policy_insights_client.py => _client.py} (80%) create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/model_base.py rename sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/{_policy_insights_client.py => _client.py} (81%) delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py rename sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/{_policy_insights_client_enums.py => _enums.py} (54%) create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py delete mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/tsp-location.yaml diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md index cec09162e555..bc4c9f326f95 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md +++ b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md @@ -1,5 +1,312 @@ # Release History +## 1.1.0b6 (2026-05-28) + +### Features Added + + - Client `PolicyInsightsClient` added parameter `cloud_setting` in method `__init__` + - Client `PolicyInsightsClient` added method `send_request` + - Model `FieldRestriction` added property `values_property` + - Model `PendingField` added property `values_property` + - Model `PolicyMetadata` added property `properties` + - Model `PolicyMetadata` added property `system_data` + - Model `Resource` added property `system_data` + - Model `SlimPolicyMetadata` added property `properties` + - Added model `ProxyResource` + - Model `AttestationsOperations` added parameter `top` in method `list_for_resource` + - Model `AttestationsOperations` added parameter `filter` in method `list_for_resource` + - Model `AttestationsOperations` added parameter `top` in method `list_for_resource_group` + - Model `AttestationsOperations` added parameter `filter` in method `list_for_resource_group` + - Model `AttestationsOperations` added parameter `top` in method `list_for_subscription` + - Model `AttestationsOperations` added parameter `filter` in method `list_for_subscription` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_management_group` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_policy_definition` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_policy_set_definition` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `expand` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_resource` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_resource_group` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_subscription` + - Model `PolicyEventsOperations` added parameter `top` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `order_by` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `select` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `from_parameter` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `to` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `filter` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `apply` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyEventsOperations` added parameter `skip_token` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyMetadataOperations` added parameter `top` in method `list` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_management_group` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `expand` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_resource` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_resource_group` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_subscription` + - Model `PolicyStatesOperations` added parameter `top` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `order_by` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `select` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `to` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `filter` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `apply` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `skip_token` in method `list_query_results_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_management_group` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_management_group` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_management_group` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_management_group` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_policy_definition` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_policy_set_definition` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_resource` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_resource` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_resource` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_resource` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_resource_group` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_resource_group` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_resource_group` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_resource_group` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_resource_group_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_subscription` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_subscription` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_subscription` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_subscription` + - Model `PolicyStatesOperations` added parameter `top` in method `summarize_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `from_parameter` in method `summarize_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `to` in method `summarize_for_subscription_level_policy_assignment` + - Model `PolicyStatesOperations` added parameter `filter` in method `summarize_for_subscription_level_policy_assignment` + - Model `PolicyTrackedResourcesOperations` added parameter `top` in method `list_query_results_for_management_group` + - Model `PolicyTrackedResourcesOperations` added parameter `filter` in method `list_query_results_for_management_group` + - Model `PolicyTrackedResourcesOperations` added parameter `top` in method `list_query_results_for_resource` + - Model `PolicyTrackedResourcesOperations` added parameter `filter` in method `list_query_results_for_resource` + - Model `PolicyTrackedResourcesOperations` added parameter `top` in method `list_query_results_for_resource_group` + - Model `PolicyTrackedResourcesOperations` added parameter `filter` in method `list_query_results_for_resource_group` + - Model `PolicyTrackedResourcesOperations` added parameter `top` in method `list_query_results_for_subscription` + - Model `PolicyTrackedResourcesOperations` added parameter `filter` in method `list_query_results_for_subscription` + - Model `RemediationsOperations` added parameter `top` in method `list_deployments_at_management_group` + - Model `RemediationsOperations` added parameter `top` in method `list_deployments_at_resource` + - Model `RemediationsOperations` added parameter `top` in method `list_deployments_at_resource_group` + - Model `RemediationsOperations` added parameter `top` in method `list_deployments_at_subscription` + - Model `RemediationsOperations` added parameter `top` in method `list_for_management_group` + - Model `RemediationsOperations` added parameter `filter` in method `list_for_management_group` + - Model `RemediationsOperations` added parameter `top` in method `list_for_resource` + - Model `RemediationsOperations` added parameter `filter` in method `list_for_resource` + - Model `RemediationsOperations` added parameter `top` in method `list_for_resource_group` + - Model `RemediationsOperations` added parameter `filter` in method `list_for_resource_group` + - Model `RemediationsOperations` added parameter `top` in method `list_for_subscription` + - Model `RemediationsOperations` added parameter `filter` in method `list_for_subscription` + +### Breaking Changes + + - Model `FieldRestriction` deleted or renamed its instance variable `values` + - Model `PendingField` deleted or renamed its instance variable `values` + - Model `PolicyMetadata` deleted or renamed its instance variable `metadata_id` + - Model `PolicyMetadata` deleted or renamed its instance variable `category` + - Model `PolicyMetadata` deleted or renamed its instance variable `title` + - Model `PolicyMetadata` deleted or renamed its instance variable `owner` + - Model `PolicyMetadata` deleted or renamed its instance variable `additional_content_url` + - Model `PolicyMetadata` deleted or renamed its instance variable `metadata` + - Model `PolicyMetadata` deleted or renamed its instance variable `description` + - Model `PolicyMetadata` deleted or renamed its instance variable `requirements` + - Model `SlimPolicyMetadata` deleted or renamed its instance variable `metadata_id` + - Model `SlimPolicyMetadata` deleted or renamed its instance variable `category` + - Model `SlimPolicyMetadata` deleted or renamed its instance variable `title` + - Model `SlimPolicyMetadata` deleted or renamed its instance variable `owner` + - Model `SlimPolicyMetadata` deleted or renamed its instance variable `additional_content_url` + - Model `SlimPolicyMetadata` deleted or renamed its instance variable `metadata` + - Deleted or renamed model `ErrorDefinitionAutoGenerated` + - Deleted or renamed model `ErrorDefinitionAutoGenerated2` + - Deleted or renamed model `ErrorResponseAutoGenerated` + - Deleted or renamed model `ErrorResponseAutoGenerated2` + - Deleted or renamed model `PolicyEventsQueryResults` + - Deleted or renamed model `PolicyMetadataCollection` + - Deleted or renamed model `PolicyStatesQueryResults` + - Deleted or renamed model `PolicyTrackedResourcesQueryResults` + - Deleted or renamed model `QueryOptions` + - Method `AttestationsOperations.list_for_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `AttestationsOperations.list_for_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `AttestationsOperations.list_for_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `ComponentPolicyStatesOperations.list_query_results_for_policy_definition` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_policy_definition` changed its parameter `select` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_policy_definition` changed its parameter `from_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_policy_definition` changed its parameter `to` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_policy_definition` changed its parameter `apply` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource` changed its parameter `select` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource` changed its parameter `from_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource` changed its parameter `to` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource` changed its parameter `apply` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource` changed its parameter `expand` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group` changed its parameter `select` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group` changed its parameter `from_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group` changed its parameter `to` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group` changed its parameter `apply` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment` changed its parameter `select` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment` changed its parameter `from_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment` changed its parameter `to` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment` changed its parameter `apply` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription` changed its parameter `select` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription` changed its parameter `from_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription` changed its parameter `to` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription` changed its parameter `apply` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment` changed its parameter `order_by` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment` changed its parameter `select` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment` changed its parameter `from_parameter` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment` changed its parameter `to` from `positional_or_keyword` to `keyword_only` + - Method `ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment` changed its parameter `apply` from `positional_or_keyword` to `keyword_only` + - Method `PolicyEventsOperations.list_query_results_for_management_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_policy_definition` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_policy_set_definition` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_resource_group_level_policy_assignment` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyEventsOperations.list_query_results_for_subscription_level_policy_assignment` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyMetadataOperations.list` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_management_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_policy_definition` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_policy_set_definition` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_management_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_policy_definition` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_policy_set_definition` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_resource_group_level_policy_assignment` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyStatesOperations.summarize_for_subscription_level_policy_assignment` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyTrackedResourcesOperations.list_query_results_for_management_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyTrackedResourcesOperations.list_query_results_for_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyTrackedResourcesOperations.list_query_results_for_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `PolicyTrackedResourcesOperations.list_query_results_for_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_deployments_at_management_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_deployments_at_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_deployments_at_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_deployments_at_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_for_management_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_for_resource` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_for_resource_group` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_for_subscription` deleted or renamed its parameter `query_options` of kind `positional_or_keyword` + - Method `RemediationsOperations.list_deployments_at_resource` re-ordered its parameters from `['self', 'resource_id', 'remediation_name', 'query_options', 'kwargs']` to `['self', 'resource_id', 'remediation_name', 'top', 'kwargs']` + - Method `RemediationsOperations.list_deployments_at_resource_group` re-ordered its parameters from `['self', 'resource_group_name', 'remediation_name', 'query_options', 'kwargs']` to `['self', 'resource_group_name', 'remediation_name', 'top', 'kwargs']` + - Method `RemediationsOperations.list_deployments_at_management_group` re-ordered its parameters from `['self', 'management_group_id', 'remediation_name', 'query_options', 'kwargs']` to `['self', 'management_group_id', 'remediation_name', 'top', 'kwargs']` + - Method `RemediationsOperations.list_deployments_at_subscription` re-ordered its parameters from `['self', 'remediation_name', 'query_options', 'kwargs']` to `['self', 'remediation_name', 'top', 'kwargs']` + - Method `PolicyMetadataOperations.list` re-ordered its parameters from `['self', 'query_options', 'kwargs']` to `['self', 'top', 'kwargs']` + ## 1.0.1 (2026-05-19) ### Other Changes diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json b/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json index 7093e2e214f9..8645b84c69f1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json +++ b/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json @@ -1,11 +1,10 @@ { - "commit": "6ed455a1fb884a0a8d5c8970d44d4ccee288cf30", + "apiVersions": { + "PolicyInsightsApi": "2024-10-01", + "PolicyTrackedResourcesApi": "2018-07-01-preview" + }, + "commit": "cb62053a18882dd258d9922be9770702b7ef6ac9", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.10.2", - "use": [ - "@autorest/python@6.50.0", - "@autorest/modelerfour@4.27.0" - ], - "autorest_command": "autorest specification/policyinsights/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --package-mode=azure-mgmt --python --python-sdks-folder=C:\\dev\\azure-sdk-for-python\\sdk --tag=package-2020-07 --use=@autorest/python@6.50.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", - "readme": "specification/policyinsights/resource-manager/readme.md" + "typespec_src": "specification/policyinsights/resource-manager/Microsoft.PolicyInsights/PolicyInsights", + "emitterVersion": "0.62.1" } \ No newline at end of file diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/apiview-properties.json b/sdk/policyinsights/azure-mgmt-policyinsights/apiview-properties.json index f65bbd0cf921..49aa851d868e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/apiview-properties.json +++ b/sdk/policyinsights/azure-mgmt-policyinsights/apiview-properties.json @@ -1,180 +1,228 @@ { - "CrossLanguagePackageId": null, + "CrossLanguagePackageId": "PolicyInsightsApi", "CrossLanguageDefinitionId": { - "azure.mgmt.policyinsights.models.CheckRestrictionsRequest": null, - "azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails": null, - "azure.mgmt.policyinsights.models.CheckRestrictionsResult": null, - "azure.mgmt.policyinsights.models.CheckRestrictionsResultContentEvaluationResult": null, - "azure.mgmt.policyinsights.models.ComplianceDetail": null, - "azure.mgmt.policyinsights.models.ComponentEventDetails": null, - "azure.mgmt.policyinsights.models.ComponentStateDetails": null, - "azure.mgmt.policyinsights.models.ErrorDefinition": null, - "azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated": null, - "azure.mgmt.policyinsights.models.ErrorResponse": null, - "azure.mgmt.policyinsights.models.ErrorResponseAutoGenerated": null, - "azure.mgmt.policyinsights.models.ExpressionEvaluationDetails": null, - "azure.mgmt.policyinsights.models.FieldRestriction": null, - "azure.mgmt.policyinsights.models.FieldRestrictions": null, - "azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails": null, - "azure.mgmt.policyinsights.models.Operation": null, - "azure.mgmt.policyinsights.models.OperationDisplay": null, - "azure.mgmt.policyinsights.models.OperationsListResults": null, - "azure.mgmt.policyinsights.models.PendingField": null, - "azure.mgmt.policyinsights.models.PolicyAssignmentSummary": null, - "azure.mgmt.policyinsights.models.PolicyDefinitionSummary": null, - "azure.mgmt.policyinsights.models.PolicyDetails": null, - "azure.mgmt.policyinsights.models.PolicyEvaluationDetails": null, - "azure.mgmt.policyinsights.models.PolicyEvaluationResult": null, - "azure.mgmt.policyinsights.models.PolicyEvent": null, - "azure.mgmt.policyinsights.models.PolicyEventsQueryResults": null, - "azure.mgmt.policyinsights.models.PolicyGroupSummary": null, - "azure.mgmt.policyinsights.models.PolicyMetadata": null, - "azure.mgmt.policyinsights.models.PolicyMetadataCollection": null, - "azure.mgmt.policyinsights.models.PolicyMetadataSlimProperties": null, - "azure.mgmt.policyinsights.models.PolicyMetadataProperties": null, - "azure.mgmt.policyinsights.models.PolicyReference": null, - "azure.mgmt.policyinsights.models.PolicyState": null, - "azure.mgmt.policyinsights.models.PolicyStatesQueryResults": null, - "azure.mgmt.policyinsights.models.PolicyTrackedResource": null, - "azure.mgmt.policyinsights.models.PolicyTrackedResourcesQueryResults": null, - "azure.mgmt.policyinsights.models.QueryFailure": null, - "azure.mgmt.policyinsights.models.QueryFailureError": null, - "azure.mgmt.policyinsights.models.QueryOptions": null, - "azure.mgmt.policyinsights.models.Remediation": null, - "azure.mgmt.policyinsights.models.RemediationDeployment": null, - "azure.mgmt.policyinsights.models.RemediationDeploymentsListResult": null, - "azure.mgmt.policyinsights.models.RemediationDeploymentSummary": null, - "azure.mgmt.policyinsights.models.RemediationFilters": null, - "azure.mgmt.policyinsights.models.RemediationListResult": null, - "azure.mgmt.policyinsights.models.SlimPolicyMetadata": null, - "azure.mgmt.policyinsights.models.SummarizeResults": null, - "azure.mgmt.policyinsights.models.Summary": null, - "azure.mgmt.policyinsights.models.SummaryResults": null, - "azure.mgmt.policyinsights.models.TrackedResourceModificationDetails": null, - "azure.mgmt.policyinsights.models.TypedErrorInfo": null, - "azure.mgmt.policyinsights.models.ResourceDiscoveryMode": null, - "azure.mgmt.policyinsights.models.FieldRestrictionResult": null, - "azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType": null, - "azure.mgmt.policyinsights.models.PolicyEventsResourceType": null, - "azure.mgmt.policyinsights.models.PolicyStatesResource": null, - "azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType": null, - "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_management_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_management_group": null, - "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_subscription": null, - "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_subscription": null, - "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource_group": null, - "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource": null, - "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_management_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_management_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_management_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_management_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_management_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_management_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_management_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_management_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_management_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_management_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_management_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_management_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_subscription": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_subscription": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_subscription": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_subscription": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_subscription": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_subscription": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_subscription": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_subscription": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_subscription": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_subscription": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_subscription": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_subscription": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_resource_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_resource_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_resource_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_resource_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_resource_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_resource_group": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_resource": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_resource": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_resource": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_resource": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_resource": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_resource": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_resource": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_resource": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_resource": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_resource": null, - "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_resource": null, - "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_resource": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_management_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_management_group": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_subscription": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_subscription": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_resource_group": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_resource": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_resource": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_policy_set_definition": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_policy_set_definition": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_policy_definition": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_policy_definition": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_subscription_level_policy_assignment": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_subscription_level_policy_assignment": null, - "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_resource_group_level_policy_assignment": null, - "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_resource_group_level_policy_assignment": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_management_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_management_group": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_management_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_management_group": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_subscription": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_subscription": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_subscription": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_subscription": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_resource_group": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_resource_group": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_resource_group": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_resource": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_resource": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_resource": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_resource": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.begin_trigger_subscription_evaluation": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.begin_trigger_subscription_evaluation": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.begin_trigger_resource_group_evaluation": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.begin_trigger_resource_group_evaluation": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_policy_set_definition": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_policy_set_definition": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_policy_set_definition": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_policy_set_definition": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_policy_definition": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_policy_definition": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_policy_definition": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_policy_definition": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_subscription_level_policy_assignment": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_subscription_level_policy_assignment": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment": null, - "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_resource_group_level_policy_assignment": null, - "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_resource_group_level_policy_assignment": null, - "azure.mgmt.policyinsights.operations.Operations.list": null, - "azure.mgmt.policyinsights.aio.operations.Operations.list": null, - "azure.mgmt.policyinsights.operations.PolicyMetadataOperations.get_resource": null, - "azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations.get_resource": null, - "azure.mgmt.policyinsights.operations.PolicyMetadataOperations.list": null, - "azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations.list": null, - "azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations.check_at_subscription_scope": null, - "azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations.check_at_subscription_scope": null, - "azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations.check_at_resource_group_scope": null, - "azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations.check_at_resource_group_scope": null - } + "azure.mgmt.policyinsights.models.Resource": "Azure.ResourceManager.CommonTypes.Resource", + "azure.mgmt.policyinsights.models.ProxyResource": "Azure.ResourceManager.CommonTypes.ProxyResource", + "azure.mgmt.policyinsights.models.Attestation": "PolicyInsightsApi.Attestation", + "azure.mgmt.policyinsights.models.AttestationEvidence": "PolicyInsightsApi.AttestationEvidence", + "azure.mgmt.policyinsights.models.AttestationProperties": "PolicyInsightsApi.AttestationProperties", + "azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest": "PolicyInsightsApi.CheckManagementGroupRestrictionsRequest", + "azure.mgmt.policyinsights.models.CheckRestrictionEvaluationDetails": "PolicyInsightsApi.CheckRestrictionEvaluationDetails", + "azure.mgmt.policyinsights.models.CheckRestrictionsRequest": "PolicyInsightsApi.CheckRestrictionsRequest", + "azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails": "PolicyInsightsApi.CheckRestrictionsResourceDetails", + "azure.mgmt.policyinsights.models.CheckRestrictionsResult": "PolicyInsightsApi.CheckRestrictionsResult", + "azure.mgmt.policyinsights.models.CheckRestrictionsResultContentEvaluationResult": "PolicyInsightsApi.CheckRestrictionsResultContentEvaluationResult", + "azure.mgmt.policyinsights.models.ComplianceDetail": "PolicyInsightsApi.ComplianceDetail", + "azure.mgmt.policyinsights.models.ComponentEventDetails": "PolicyInsightsApi.ComponentEventDetails", + "azure.mgmt.policyinsights.models.ComponentExpressionEvaluationDetails": "PolicyInsightsApi.ComponentExpressionEvaluationDetails", + "azure.mgmt.policyinsights.models.ComponentPolicyEvaluationDetails": "PolicyInsightsApi.ComponentPolicyEvaluationDetails", + "azure.mgmt.policyinsights.models.ComponentPolicyState": "PolicyInsightsApi.ComponentPolicyState", + "azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults": "PolicyInsightsApi.ComponentPolicyStatesQueryResults", + "azure.mgmt.policyinsights.models.ComponentStateDetails": "PolicyInsightsApi.ComponentStateDetails", + "azure.mgmt.policyinsights.models.ErrorDefinition": "PolicyInsightsApi.ErrorDefinition", + "azure.mgmt.policyinsights.models.ErrorResponse": "PolicyInsightsApi.ErrorResponse", + "azure.mgmt.policyinsights.models.ExpressionEvaluationDetails": "PolicyInsightsApi.ExpressionEvaluationDetails", + "azure.mgmt.policyinsights.models.FieldRestriction": "PolicyInsightsApi.FieldRestriction", + "azure.mgmt.policyinsights.models.FieldRestrictions": "PolicyInsightsApi.FieldRestrictions", + "azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails": "PolicyInsightsApi.IfNotExistsEvaluationDetails", + "azure.mgmt.policyinsights.models.Operation": "PolicyInsightsApi.Operation", + "azure.mgmt.policyinsights.models.OperationDisplay": "PolicyInsightsApi.OperationDisplay", + "azure.mgmt.policyinsights.models.OperationsListResults": "PolicyInsightsApi.OperationsListResults", + "azure.mgmt.policyinsights.models.PendingField": "PolicyInsightsApi.PendingField", + "azure.mgmt.policyinsights.models.PolicyAssignmentSummary": "PolicyInsightsApi.PolicyAssignmentSummary", + "azure.mgmt.policyinsights.models.PolicyDefinitionSummary": "PolicyInsightsApi.PolicyDefinitionSummary", + "azure.mgmt.policyinsights.models.PolicyDetails": "PolicyTrackedResourcesApi.PolicyDetails", + "azure.mgmt.policyinsights.models.PolicyEffectDetails": "PolicyInsightsApi.PolicyEffectDetails", + "azure.mgmt.policyinsights.models.PolicyEvaluationDetails": "PolicyInsightsApi.PolicyEvaluationDetails", + "azure.mgmt.policyinsights.models.PolicyEvaluationResult": "PolicyInsightsApi.PolicyEvaluationResult", + "azure.mgmt.policyinsights.models.PolicyEvent": "PolicyInsightsApi.PolicyEvent", + "azure.mgmt.policyinsights.models.PolicyGroupSummary": "PolicyInsightsApi.PolicyGroupSummary", + "azure.mgmt.policyinsights.models.PolicyMetadata": "PolicyInsightsApi.PolicyMetadata", + "azure.mgmt.policyinsights.models.PolicyMetadataSlimProperties": "PolicyInsightsApi.PolicyMetadataSlimProperties", + "azure.mgmt.policyinsights.models.PolicyMetadataProperties": "PolicyInsightsApi.PolicyMetadataProperties", + "azure.mgmt.policyinsights.models.PolicyReference": "PolicyInsightsApi.PolicyReference", + "azure.mgmt.policyinsights.models.PolicyState": "PolicyInsightsApi.PolicyState", + "azure.mgmt.policyinsights.models.PolicyTrackedResource": "PolicyTrackedResourcesApi.PolicyTrackedResource", + "azure.mgmt.policyinsights.models.QueryFailure": "PolicyInsightsCommon.QueryFailure", + "azure.mgmt.policyinsights.models.QueryFailureError": "PolicyInsightsCommon.QueryFailureError", + "azure.mgmt.policyinsights.models.Remediation": "PolicyInsightsApi.Remediation", + "azure.mgmt.policyinsights.models.RemediationDeployment": "PolicyInsightsApi.RemediationDeployment", + "azure.mgmt.policyinsights.models.RemediationDeploymentSummary": "PolicyInsightsApi.RemediationDeploymentSummary", + "azure.mgmt.policyinsights.models.RemediationFilters": "PolicyInsightsApi.RemediationFilters", + "azure.mgmt.policyinsights.models.RemediationProperties": "PolicyInsightsApi.RemediationProperties", + "azure.mgmt.policyinsights.models.RemediationPropertiesFailureThreshold": "PolicyInsightsApi.RemediationPropertiesFailureThreshold", + "azure.mgmt.policyinsights.models.SlimPolicyMetadata": "PolicyInsightsApi.SlimPolicyMetadata", + "azure.mgmt.policyinsights.models.SummarizeResults": "PolicyInsightsApi.SummarizeResults", + "azure.mgmt.policyinsights.models.Summary": "PolicyInsightsApi.Summary", + "azure.mgmt.policyinsights.models.SummaryResults": "PolicyInsightsApi.SummaryResults", + "azure.mgmt.policyinsights.models.SystemData": "Azure.ResourceManager.CommonTypes.SystemData", + "azure.mgmt.policyinsights.models.TrackedResourceModificationDetails": "PolicyTrackedResourcesApi.TrackedResourceModificationDetails", + "azure.mgmt.policyinsights.models.TypedErrorInfo": "PolicyInsightsApi.TypedErrorInfo", + "azure.mgmt.policyinsights.models.CreatedByType": "Azure.ResourceManager.CommonTypes.createdByType", + "azure.mgmt.policyinsights.models.ResourceDiscoveryMode": "PolicyInsightsApi.ResourceDiscoveryMode", + "azure.mgmt.policyinsights.models.ComplianceState": "PolicyInsightsApi.ComplianceState", + "azure.mgmt.policyinsights.models.PolicyEventsResourceType": "PolicyInsightsApi.PolicyEventsResourceType", + "azure.mgmt.policyinsights.models.PolicyStatesResource": "PolicyInsightsApi.PolicyStatesResource", + "azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType": "PolicyInsightsApi.PolicyStatesSummaryResourceType", + "azure.mgmt.policyinsights.models.FieldRestrictionResult": "PolicyInsightsApi.FieldRestrictionResult", + "azure.mgmt.policyinsights.models.ComponentPolicyStatesResource": "PolicyInsightsApi.ComponentPolicyStatesResource", + "azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType": "PolicyTrackedResourcesApi.PolicyTrackedResourcesResourceType", + "azure.mgmt.policyinsights.operations.Operations.list": "PolicyInsightsApi.Operations.list", + "azure.mgmt.policyinsights.aio.operations.Operations.list": "PolicyInsightsApi.Operations.list", + "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_management_group": "PolicyInsightsApi.Remediations.getAtManagementGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_management_group": "PolicyInsightsApi.Remediations.getAtManagementGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_management_group": "PolicyInsightsApi.Remediations.createOrUpdateAtManagementGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_management_group": "PolicyInsightsApi.Remediations.createOrUpdateAtManagementGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_management_group": "PolicyInsightsApi.Remediations.deleteAtManagementGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_management_group": "PolicyInsightsApi.Remediations.deleteAtManagementGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_management_group": "PolicyInsightsApi.Remediations.listForManagementGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_management_group": "PolicyInsightsApi.Remediations.listForManagementGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.getAtSubscription", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.getAtSubscription", + "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.createOrUpdateAtSubscription", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.createOrUpdateAtSubscription", + "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.deleteAtSubscription", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.deleteAtSubscription", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.listForSubscription", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.listForSubscription", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.listDeploymentsAtSubscription", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.listDeploymentsAtSubscription", + "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.cancelAtSubscription", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_subscription": "PolicyInsightsApi.RemediationSubscriptionOperations.cancelAtSubscription", + "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.getAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.getAtResourceGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.createOrUpdateAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.createOrUpdateAtResourceGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.deleteAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.deleteAtResourceGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.listForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.listForResourceGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.listDeploymentsAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.listDeploymentsAtResourceGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.cancelAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_resource_group": "PolicyInsightsApi.RemediationResourceGroupOperations.cancelAtResourceGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.get_at_resource": "PolicyInsightsApi.RemediationResourceOperations.getAtResource", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.get_at_resource": "PolicyInsightsApi.RemediationResourceOperations.getAtResource", + "azure.mgmt.policyinsights.operations.RemediationsOperations.create_or_update_at_resource": "PolicyInsightsApi.RemediationResourceOperations.createOrUpdateAtResource", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.create_or_update_at_resource": "PolicyInsightsApi.RemediationResourceOperations.createOrUpdateAtResource", + "azure.mgmt.policyinsights.operations.RemediationsOperations.delete_at_resource": "PolicyInsightsApi.RemediationResourceOperations.deleteAtResource", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.delete_at_resource": "PolicyInsightsApi.RemediationResourceOperations.deleteAtResource", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_for_resource": "PolicyInsightsApi.RemediationResourceOperations.listForResource", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_for_resource": "PolicyInsightsApi.RemediationResourceOperations.listForResource", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_resource": "PolicyInsightsApi.RemediationResourceOperations.listDeploymentsAtResource", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_resource": "PolicyInsightsApi.RemediationResourceOperations.listDeploymentsAtResource", + "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_resource": "PolicyInsightsApi.RemediationResourceOperations.cancelAtResource", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_resource": "PolicyInsightsApi.RemediationResourceOperations.cancelAtResource", + "azure.mgmt.policyinsights.operations.RemediationsOperations.list_deployments_at_management_group": "PolicyInsightsApi.RemediationsOperationGroup.listDeploymentsAtManagementGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.list_deployments_at_management_group": "PolicyInsightsApi.RemediationsOperationGroup.listDeploymentsAtManagementGroup", + "azure.mgmt.policyinsights.operations.RemediationsOperations.cancel_at_management_group": "PolicyInsightsApi.RemediationsOperationGroup.cancelAtManagementGroup", + "azure.mgmt.policyinsights.aio.operations.RemediationsOperations.cancel_at_management_group": "PolicyInsightsApi.RemediationsOperationGroup.cancelAtManagementGroup", + "azure.mgmt.policyinsights.operations.AttestationsOperations.get_at_subscription": "PolicyInsightsApi.Attestations.getAtSubscription", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.get_at_subscription": "PolicyInsightsApi.Attestations.getAtSubscription", + "azure.mgmt.policyinsights.operations.AttestationsOperations.begin_create_or_update_at_subscription": "PolicyInsightsApi.Attestations.createOrUpdateAtSubscription", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.begin_create_or_update_at_subscription": "PolicyInsightsApi.Attestations.createOrUpdateAtSubscription", + "azure.mgmt.policyinsights.operations.AttestationsOperations.delete_at_subscription": "PolicyInsightsApi.Attestations.deleteAtSubscription", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.delete_at_subscription": "PolicyInsightsApi.Attestations.deleteAtSubscription", + "azure.mgmt.policyinsights.operations.AttestationsOperations.list_for_subscription": "PolicyInsightsApi.Attestations.listForSubscription", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.list_for_subscription": "PolicyInsightsApi.Attestations.listForSubscription", + "azure.mgmt.policyinsights.operations.AttestationsOperations.get_at_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.getAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.get_at_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.getAtResourceGroup", + "azure.mgmt.policyinsights.operations.AttestationsOperations.begin_create_or_update_at_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.createOrUpdateAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.begin_create_or_update_at_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.createOrUpdateAtResourceGroup", + "azure.mgmt.policyinsights.operations.AttestationsOperations.delete_at_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.deleteAtResourceGroup", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.delete_at_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.deleteAtResourceGroup", + "azure.mgmt.policyinsights.operations.AttestationsOperations.list_for_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.listForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.list_for_resource_group": "PolicyInsightsApi.AttestationResourceGroupOperations.listForResourceGroup", + "azure.mgmt.policyinsights.operations.AttestationsOperations.get_at_resource": "PolicyInsightsApi.AttestationOperationGroup.getAtResource", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.get_at_resource": "PolicyInsightsApi.AttestationOperationGroup.getAtResource", + "azure.mgmt.policyinsights.operations.AttestationsOperations.begin_create_or_update_at_resource": "PolicyInsightsApi.AttestationOperationGroup.createOrUpdateAtResource", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.begin_create_or_update_at_resource": "PolicyInsightsApi.AttestationOperationGroup.createOrUpdateAtResource", + "azure.mgmt.policyinsights.operations.AttestationsOperations.delete_at_resource": "PolicyInsightsApi.AttestationOperationGroup.deleteAtResource", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.delete_at_resource": "PolicyInsightsApi.AttestationOperationGroup.deleteAtResource", + "azure.mgmt.policyinsights.operations.AttestationsOperations.list_for_resource": "PolicyInsightsApi.AttestationOperationGroup.listForResource", + "azure.mgmt.policyinsights.aio.operations.AttestationsOperations.list_for_resource": "PolicyInsightsApi.AttestationOperationGroup.listForResource", + "azure.mgmt.policyinsights.operations.PolicyMetadataOperations.get_resource": "PolicyInsightsApi.PolicyMetadataOperationGroup.getResource", + "azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations.get_resource": "PolicyInsightsApi.PolicyMetadataOperationGroup.getResource", + "azure.mgmt.policyinsights.operations.PolicyMetadataOperations.list": "PolicyInsightsApi.PolicyMetadataNonResourceOperationGroup.list", + "azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations.list": "PolicyInsightsApi.PolicyMetadataNonResourceOperationGroup.list", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_management_group": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForManagementGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_management_group": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForManagementGroup", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_subscription": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_subscription": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_resource_group": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_resource_group": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_resource": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_resource": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_policy_set_definition": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForPolicySetDefinition", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_policy_set_definition": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForPolicySetDefinition", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_policy_definition": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForPolicyDefinition", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_policy_definition": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForPolicyDefinition", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_subscription_level_policy_assignment": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_subscription_level_policy_assignment": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyEventsOperations.list_query_results_for_resource_group_level_policy_assignment": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations.list_query_results_for_resource_group_level_policy_assignment": "PolicyInsightsApi.PolicyEventsOperationGroup.listQueryResultsForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_management_group": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForManagementGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_management_group": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForManagementGroup", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_management_group": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForManagementGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_management_group": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForManagementGroup", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_subscription": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_subscription": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_subscription": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForSubscription", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_subscription": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForSubscription", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_resource_group": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_resource_group": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_resource_group": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_resource_group": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForResourceGroup", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_resource": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_resource": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_resource": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForResource", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_resource": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForResource", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.begin_trigger_subscription_evaluation": "PolicyInsightsApi.PolicyStatesOperationGroup.triggerSubscriptionEvaluation", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.begin_trigger_subscription_evaluation": "PolicyInsightsApi.PolicyStatesOperationGroup.triggerSubscriptionEvaluation", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.begin_trigger_resource_group_evaluation": "PolicyInsightsApi.PolicyStatesOperationGroup.triggerResourceGroupEvaluation", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.begin_trigger_resource_group_evaluation": "PolicyInsightsApi.PolicyStatesOperationGroup.triggerResourceGroupEvaluation", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_policy_set_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForPolicySetDefinition", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_policy_set_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForPolicySetDefinition", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_policy_set_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForPolicySetDefinition", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_policy_set_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForPolicySetDefinition", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_policy_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForPolicyDefinition", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_policy_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForPolicyDefinition", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_policy_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForPolicyDefinition", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_policy_definition": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForPolicyDefinition", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_subscription_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_subscription_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.listQueryResultsForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyStatesOperations.summarize_for_resource_group_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations.summarize_for_resource_group_level_policy_assignment": "PolicyInsightsApi.PolicyStatesOperationGroup.summarizeForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations.check_at_subscription_scope": "PolicyInsightsApi.PolicyRestrictionsOperationGroup.checkAtSubscriptionScope", + "azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations.check_at_subscription_scope": "PolicyInsightsApi.PolicyRestrictionsOperationGroup.checkAtSubscriptionScope", + "azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations.check_at_resource_group_scope": "PolicyInsightsApi.PolicyRestrictionsOperationGroup.checkAtResourceGroupScope", + "azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations.check_at_resource_group_scope": "PolicyInsightsApi.PolicyRestrictionsOperationGroup.checkAtResourceGroupScope", + "azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations.check_at_management_group_scope": "PolicyInsightsApi.PolicyRestrictionsOperationGroup.checkAtManagementGroupScope", + "azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations.check_at_management_group_scope": "PolicyInsightsApi.PolicyRestrictionsOperationGroup.checkAtManagementGroupScope", + "azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations.list_query_results_for_subscription": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations.list_query_results_for_subscription": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations.list_query_results_for_resource_group": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations.list_query_results_for_resource_group": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations.list_query_results_for_resource": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations.list_query_results_for_resource": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations.list_query_results_for_policy_definition": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForPolicyDefinition", + "azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations.list_query_results_for_policy_definition": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForPolicyDefinition", + "azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations.list_query_results_for_subscription_level_policy_assignment": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForSubscriptionLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations.list_query_results_for_resource_group_level_policy_assignment": "PolicyInsightsApi.ComponentPolicyStatesOperationGroup.listQueryResultsForResourceGroupLevelPolicyAssignment", + "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_management_group": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForManagementGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_management_group": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForManagementGroup", + "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_subscription": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_subscription": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForSubscription", + "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource_group": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource_group": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForResourceGroup", + "azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForResource", + "azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations.list_query_results_for_resource": "PolicyTrackedResourcesApi.PolicyTrackedResourcesOperationGroup.listQueryResultsForResource" + }, + "CrossLanguageVersion": "d698ce40a253" } \ No newline at end of file diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py index 8461746b6906..81bce0c19faf 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._policy_insights_client import PolicyInsightsClient # type: ignore +from ._client import PolicyInsightsClient # type: ignore from ._version import VERSION __version__ = VERSION diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_client.py similarity index 80% rename from sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py rename to sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_client.py index edb74291017e..2477a519746e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_client.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy +import sys from typing import Any, Optional, TYPE_CHECKING, cast -from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -17,10 +17,11 @@ from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from . import models as _models from ._configuration import PolicyInsightsClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( + AttestationsOperations, + ComponentPolicyStatesOperations, Operations, PolicyEventsOperations, PolicyMetadataOperations, @@ -30,6 +31,11 @@ RemediationsOperations, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: from azure.core import AzureClouds from azure.core.credentials import TokenCredential @@ -38,26 +44,31 @@ class PolicyInsightsClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """PolicyInsightsClient. - :ivar policy_tracked_resources: PolicyTrackedResourcesOperations operations - :vartype policy_tracked_resources: - azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.policyinsights.operations.Operations :ivar remediations: RemediationsOperations operations :vartype remediations: azure.mgmt.policyinsights.operations.RemediationsOperations + :ivar attestations: AttestationsOperations operations + :vartype attestations: azure.mgmt.policyinsights.operations.AttestationsOperations + :ivar policy_metadata: PolicyMetadataOperations operations + :vartype policy_metadata: azure.mgmt.policyinsights.operations.PolicyMetadataOperations :ivar policy_events: PolicyEventsOperations operations :vartype policy_events: azure.mgmt.policyinsights.operations.PolicyEventsOperations :ivar policy_states: PolicyStatesOperations operations :vartype policy_states: azure.mgmt.policyinsights.operations.PolicyStatesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.policyinsights.operations.Operations - :ivar policy_metadata: PolicyMetadataOperations operations - :vartype policy_metadata: azure.mgmt.policyinsights.operations.PolicyMetadataOperations :ivar policy_restrictions: PolicyRestrictionsOperations operations :vartype policy_restrictions: azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar component_policy_states: ComponentPolicyStatesOperations operations + :vartype component_policy_states: + azure.mgmt.policyinsights.operations.ComponentPolicyStatesOperations + :ivar policy_tracked_resources: PolicyTrackedResourcesOperations operations + :vartype policy_tracked_resources: + azure.mgmt.policyinsights.operations.PolicyTrackedResourcesOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Microsoft Azure subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. @@ -75,6 +86,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -83,6 +95,7 @@ def __init__( self._config = PolicyInsightsClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -106,31 +119,34 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, _endpoint), policies=_policies, **kwargs) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.policy_tracked_resources = PolicyTrackedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.remediations = RemediationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.attestations = AttestationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_metadata = PolicyMetadataOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_events = PolicyEventsOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_states = PolicyStatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.policy_metadata = PolicyMetadataOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_restrictions = PolicyRestrictionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.component_policy_states = ComponentPolicyStatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_tracked_resources = PolicyTrackedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = client._send_request(request) + >>> response = client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -143,7 +159,11 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py index e48c29d0dca2..63cdda06fc5f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,10 +24,12 @@ class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-at Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Microsoft Azure subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds @@ -37,6 +39,7 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -47,6 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-policyinsights/{}".format(VERSION)) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_patch.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_patch.py index 49900f6ab120..ea765788358a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_patch.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_patch.py @@ -1,15 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py index 0af9b28f6607..8026245c2abc 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py @@ -1,6 +1,6 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/model_base.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/model_base.py new file mode 100644 index 000000000000..bd5b9caf1022 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/model_base.py @@ -0,0 +1,1755 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access, broad-except + +import copy +import calendar +import decimal +import functools +import sys +import logging +import base64 +import re +import typing +import enum +import email.utils +from datetime import datetime, date, time, timedelta, timezone +from json import JSONEncoder +import xml.etree.ElementTree as ET +from collections.abc import MutableMapping +import isodate +from azure.core.exceptions import DeserializationError +from azure.core import CaseInsensitiveEnumMeta +from azure.core.pipeline import PipelineResponse +from azure.core.serialization import _Null + +from azure.core.rest import HttpResponse + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + +_LOGGER = logging.getLogger(__name__) + +__all__ = ["SdkJSONEncoder", "Model", "rest_field", "rest_discriminator"] + +TZ_UTC = timezone.utc +_T = typing.TypeVar("_T") +_NONE_TYPE = type(None) + + +def _timedelta_as_isostr(td: timedelta) -> str: + """Converts a datetime.timedelta object into an ISO 8601 formatted string, e.g. 'P4DT12H30M05S' + + Function adapted from the Tin Can Python project: https://github.com/RusticiSoftware/TinCanPython + + :param timedelta td: The timedelta to convert + :rtype: str + :return: ISO8601 version of this timedelta + """ + + # Split seconds to larger units + seconds = td.total_seconds() + minutes, seconds = divmod(seconds, 60) + hours, minutes = divmod(minutes, 60) + days, hours = divmod(hours, 24) + + days, hours, minutes = list(map(int, (days, hours, minutes))) + seconds = round(seconds, 6) + + # Build date + date_str = "" + if days: + date_str = "%sD" % days + + if hours or minutes or seconds: + # Build time + time_str = "T" + + # Hours + bigger_exists = date_str or hours + if bigger_exists: + time_str += "{:02}H".format(hours) + + # Minutes + bigger_exists = bigger_exists or minutes + if bigger_exists: + time_str += "{:02}M".format(minutes) + + # Seconds + try: + if seconds.is_integer(): + seconds_string = "{:02}".format(int(seconds)) + else: + # 9 chars long w/ leading 0, 6 digits after decimal + seconds_string = "%09.6f" % seconds + # Remove trailing zeros + seconds_string = seconds_string.rstrip("0") + except AttributeError: # int.is_integer() raises + seconds_string = "{:02}".format(seconds) + + time_str += "{}S".format(seconds_string) + else: + time_str = "" + + return "P" + date_str + time_str + + +def _serialize_bytes(o, format: typing.Optional[str] = None) -> str: + encoded = base64.b64encode(o).decode() + if format == "base64url": + return encoded.strip("=").replace("+", "-").replace("/", "_") + return encoded + + +def _serialize_datetime(o, format: typing.Optional[str] = None): + if hasattr(o, "year") and hasattr(o, "hour"): + if format == "rfc7231": + return email.utils.format_datetime(o, usegmt=True) + if format == "unix-timestamp": + return int(calendar.timegm(o.utctimetuple())) + + # astimezone() fails for naive times in Python 2.7, so make make sure o is aware (tzinfo is set) + if not o.tzinfo: + iso_formatted = o.replace(tzinfo=TZ_UTC).isoformat() + else: + iso_formatted = o.astimezone(TZ_UTC).isoformat() + # Replace the trailing "+00:00" UTC offset with "Z" (RFC 3339: https://www.ietf.org/rfc/rfc3339.txt) + return iso_formatted.replace("+00:00", "Z") + # Next try datetime.date or datetime.time + return o.isoformat() + + +def _is_readonly(p): + try: + return p._visibility == ["read"] + except AttributeError: + return False + + +class SdkJSONEncoder(JSONEncoder): + """A JSON encoder that's capable of serializing datetime objects and bytes.""" + + def __init__(self, *args, exclude_readonly: bool = False, format: typing.Optional[str] = None, **kwargs): + super().__init__(*args, **kwargs) + self.exclude_readonly = exclude_readonly + self.format = format + + def default(self, o): # pylint: disable=too-many-return-statements + if _is_model(o): + if self.exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + return {k: v for k, v in o.items() if k not in readonly_props} + return dict(o.items()) + try: + return super(SdkJSONEncoder, self).default(o) + except TypeError: + if isinstance(o, _Null): + return None + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, self.format) + try: + # First try datetime.datetime + return _serialize_datetime(o, self.format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return super(SdkJSONEncoder, self).default(o) + + +_VALID_DATE = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" + r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") +_VALID_RFC7231 = re.compile( + r"(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s\d{2}\s" + r"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\s\d{2}:\d{2}:\d{2}\sGMT" +) + +_ARRAY_ENCODE_MAPPING = { + "pipeDelimited": "|", + "spaceDelimited": " ", + "commaDelimited": ",", + "newlineDelimited": "\n", +} + + +def _deserialize_array_encoded(delimit: str, attr): + if isinstance(attr, str): + if attr == "": + return [] + return attr.split(delimit) + return attr + + +def _deserialize_datetime(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + attr = attr.upper() + match = _VALID_DATE.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + return date_obj # type: ignore[no-any-return] + + +def _deserialize_datetime_rfc7231(attr: typing.Union[str, datetime]) -> datetime: + """Deserialize RFC7231 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + match = _VALID_RFC7231.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + return email.utils.parsedate_to_datetime(attr) + + +def _deserialize_datetime_unix_timestamp(attr: typing.Union[float, datetime]) -> datetime: + """Deserialize unix timestamp into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: ~datetime.datetime + :returns: The datetime object from that input + """ + if isinstance(attr, datetime): + # i'm already deserialized + return attr + return datetime.fromtimestamp(attr, TZ_UTC) + + +def _deserialize_date(attr: typing.Union[str, date]) -> date: + """Deserialize ISO-8601 formatted string into Date object. + :param str attr: response string to be deserialized. + :rtype: date + :returns: The date object from that input + """ + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + if isinstance(attr, date): + return attr + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) # type: ignore + + +def _deserialize_time(attr: typing.Union[str, time]) -> time: + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :returns: The time object from that input + """ + if isinstance(attr, time): + return attr + return isodate.parse_time(attr) # type: ignore[no-any-return] + + +def _deserialize_bytes(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + return bytes(base64.b64decode(attr)) + + +def _deserialize_bytes_base64(attr): + if isinstance(attr, (bytes, bytearray)): + return attr + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return bytes(base64.b64decode(encoded)) + + +def _deserialize_duration(attr): + if isinstance(attr, timedelta): + return attr + return isodate.parse_duration(attr) + + +def _deserialize_decimal(attr): + if isinstance(attr, decimal.Decimal): + return attr + return decimal.Decimal(str(attr)) + + +def _deserialize_int_as_str(attr): + if isinstance(attr, int): + return attr + return int(attr) + + +_DESERIALIZE_MAPPING = { + datetime: _deserialize_datetime, + date: _deserialize_date, + time: _deserialize_time, + bytes: _deserialize_bytes, + bytearray: _deserialize_bytes, + timedelta: _deserialize_duration, + typing.Any: lambda x: x, + decimal.Decimal: _deserialize_decimal, +} + +_DESERIALIZE_MAPPING_WITHFORMAT = { + "rfc3339": _deserialize_datetime, + "rfc7231": _deserialize_datetime_rfc7231, + "unix-timestamp": _deserialize_datetime_unix_timestamp, + "base64": _deserialize_bytes, + "base64url": _deserialize_bytes_base64, +} + + +def get_deserializer(annotation: typing.Any, rf: typing.Optional["_RestField"] = None): + if annotation is int and rf and rf._format == "str": + return _deserialize_int_as_str + if annotation is str and rf and rf._format in _ARRAY_ENCODE_MAPPING: + return functools.partial(_deserialize_array_encoded, _ARRAY_ENCODE_MAPPING[rf._format]) + if rf and rf._format: + return _DESERIALIZE_MAPPING_WITHFORMAT.get(rf._format) + return _DESERIALIZE_MAPPING.get(annotation) # pyright: ignore + + +def _get_type_alias_type(module_name: str, alias_name: str): + types = { + k: v + for k, v in sys.modules[module_name].__dict__.items() + if isinstance(v, typing._GenericAlias) # type: ignore + } + if alias_name not in types: + return alias_name + return types[alias_name] + + +def _get_model(module_name: str, model_name: str): + models = {k: v for k, v in sys.modules[module_name].__dict__.items() if isinstance(v, type)} + module_end = module_name.rsplit(".", 1)[0] + models.update({k: v for k, v in sys.modules[module_end].__dict__.items() if isinstance(v, type)}) + if isinstance(model_name, str): + model_name = model_name.split(".")[-1] + if model_name not in models: + return model_name + return models[model_name] + + +_UNSET = object() + + +class _MyMutableMapping(MutableMapping[str, typing.Any]): + def __init__(self, data: dict[str, typing.Any]) -> None: + self._data = data + + def __contains__(self, key: typing.Any) -> bool: + return key in self._data + + def __getitem__(self, key: str) -> typing.Any: + # If this key has been deserialized (for mutable types), we need to handle serialization + if hasattr(self, "_attr_to_rest_field"): + cache_attr = f"_deserialized_{key}" + if hasattr(self, cache_attr): + rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key) + if rf: + value = self._data.get(key) + if isinstance(value, (dict, list, set)): + # For mutable types, serialize and return + # But also update _data with serialized form and clear flag + # so mutations via this returned value affect _data + serialized = _serialize(value, rf._format) + # If serialized form is same type (no transformation needed), + # return _data directly so mutations work + if isinstance(serialized, type(value)) and serialized == value: + return self._data.get(key) + # Otherwise return serialized copy and clear flag + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + # Store serialized form back + self._data[key] = serialized + return serialized + return self._data.__getitem__(key) + + def __setitem__(self, key: str, value: typing.Any) -> None: + # Clear any cached deserialized value when setting through dictionary access + cache_attr = f"_deserialized_{key}" + try: + object.__delattr__(self, cache_attr) + except AttributeError: + pass + self._data.__setitem__(key, value) + + def __delitem__(self, key: str) -> None: + self._data.__delitem__(key) + + def __iter__(self) -> typing.Iterator[typing.Any]: + return self._data.__iter__() + + def __len__(self) -> int: + return self._data.__len__() + + def __ne__(self, other: typing.Any) -> bool: + return not self.__eq__(other) + + def keys(self) -> typing.KeysView[str]: + """ + :returns: a set-like object providing a view on D's keys + :rtype: ~typing.KeysView + """ + return self._data.keys() + + def values(self) -> typing.ValuesView[typing.Any]: + """ + :returns: an object providing a view on D's values + :rtype: ~typing.ValuesView + """ + return self._data.values() + + def items(self) -> typing.ItemsView[str, typing.Any]: + """ + :returns: set-like object providing a view on D's items + :rtype: ~typing.ItemsView + """ + return self._data.items() + + def get(self, key: str, default: typing.Any = None) -> typing.Any: + """ + Get the value for key if key is in the dictionary, else default. + :param str key: The key to look up. + :param any default: The value to return if key is not in the dictionary. Defaults to None + :returns: D[k] if k in D, else d. + :rtype: any + """ + try: + return self[key] + except KeyError: + return default + + @typing.overload + def pop(self, key: str) -> typing.Any: ... # pylint: disable=arguments-differ + + @typing.overload + def pop(self, key: str, default: _T) -> _T: ... # pylint: disable=signature-differs + + @typing.overload + def pop(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Removes specified key and return the corresponding value. + :param str key: The key to pop. + :param any default: The value to return if key is not in the dictionary + :returns: The value corresponding to the key. + :rtype: any + :raises KeyError: If key is not found and default is not given. + """ + if default is _UNSET: + return self._data.pop(key) + return self._data.pop(key, default) + + def popitem(self) -> tuple[str, typing.Any]: + """ + Removes and returns some (key, value) pair + :returns: The (key, value) pair. + :rtype: tuple + :raises KeyError: if D is empty. + """ + return self._data.popitem() + + def clear(self) -> None: + """ + Remove all items from D. + """ + self._data.clear() + + def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ + """ + Updates D from mapping/iterable E and F. + :param any args: Either a mapping object or an iterable of key-value pairs. + """ + self._data.update(*args, **kwargs) + + @typing.overload + def setdefault(self, key: str, default: None = None) -> None: ... + + @typing.overload + def setdefault(self, key: str, default: typing.Any) -> typing.Any: ... # pylint: disable=signature-differs + + def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any: + """ + Same as calling D.get(k, d), and setting D[k]=d if k not found + :param str key: The key to look up. + :param any default: The value to set if key is not in the dictionary + :returns: D[k] if k in D, else d. + :rtype: any + """ + if default is _UNSET: + return self._data.setdefault(key) + return self._data.setdefault(key, default) + + def __eq__(self, other: typing.Any) -> bool: + if isinstance(other, _MyMutableMapping): + return self._data == other._data + try: + other_model = self.__class__(other) + except Exception: + return False + return self._data == other_model._data + + def __repr__(self) -> str: + return str(self._data) + + +def _is_model(obj: typing.Any) -> bool: + return getattr(obj, "_is_model", False) + + +def _serialize(o, format: typing.Optional[str] = None): # pylint: disable=too-many-return-statements + if isinstance(o, list): + if format in _ARRAY_ENCODE_MAPPING and all(isinstance(x, str) for x in o): + return _ARRAY_ENCODE_MAPPING[format].join(o) + return [_serialize(x, format) for x in o] + if isinstance(o, dict): + return {k: _serialize(v, format) for k, v in o.items()} + if isinstance(o, set): + return {_serialize(x, format) for x in o} + if isinstance(o, tuple): + return tuple(_serialize(x, format) for x in o) + if isinstance(o, (bytes, bytearray)): + return _serialize_bytes(o, format) + if isinstance(o, decimal.Decimal): + return float(o) + if isinstance(o, enum.Enum): + return o.value + if isinstance(o, int): + if format == "str": + return str(o) + return o + try: + # First try datetime.datetime + return _serialize_datetime(o, format) + except AttributeError: + pass + # Last, try datetime.timedelta + try: + return _timedelta_as_isostr(o) + except AttributeError: + # This will be raised when it hits value.total_seconds in the method above + pass + return o + + +def _get_rest_field(attr_to_rest_field: dict[str, "_RestField"], rest_name: str) -> typing.Optional["_RestField"]: + try: + return next(rf for rf in attr_to_rest_field.values() if rf._rest_name == rest_name) + except StopIteration: + return None + + +def _create_value(rf: typing.Optional["_RestField"], value: typing.Any) -> typing.Any: + if not rf: + return _serialize(value, None) + if rf._is_multipart_file_input: + return value + if rf._is_model: + return _deserialize(rf._type, value) + if isinstance(value, ET.Element): + value = _deserialize(rf._type, value) + return _serialize(value, rf._format) + + +# ============================================================================ +# Fast-path scalar deserializer functions for rest_field(deserializer=...) +# These are referenced from rest_field declarations to bypass the generic +# _deserialize -> _deserialize_with_callable chain. +# Only simple/primitive types — no models or container types. +# ============================================================================ + + +def _xml_deser_str(value): + if isinstance(value, ET.Element): + return value.text or "" + return str(value) if value is not None else None + + +def _xml_deser_int(value): + if isinstance(value, ET.Element): + return int(value.text) if value.text else None + return int(value) if value is not None else None + + +def _xml_deser_float(value): + if isinstance(value, ET.Element): + return float(value.text) if value.text else None + return float(value) if value is not None else None + + +def _xml_deser_bool(value): + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + if text in (True, False): + return text + return text.lower() == "true" + + +# pylint: disable=docstring-missing-param +def _xml_deser_bytes(value): + """Deserialize bytes from XML (base64).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes(text) + + +def _xml_deser_bytes_base64url(value): + """Deserialize bytes from XML (base64url).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_bytes_base64(text) + + +def _xml_deser_datetime(value): + """Deserialize a datetime from XML (ISO 8601 / rfc3339).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime(text) + + +def _xml_deser_datetime_rfc7231(value): + """Deserialize a datetime from XML (RFC7231 format).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_rfc7231(text) + + +def _xml_deser_datetime_unix_timestamp(value): + """Deserialize a datetime from XML (Unix timestamp).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_datetime_unix_timestamp(float(text)) + + +def _xml_deser_date(value): + """Deserialize a date from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_date(text) + + +def _xml_deser_time(value): + """Deserialize a time from XML (ISO 8601).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_time(text) + + +def _xml_deser_duration(value): + """Deserialize a timedelta from XML (ISO 8601 duration).""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_duration(text) + + +def _xml_deser_decimal(value): + """Deserialize a Decimal from XML.""" + if isinstance(value, ET.Element): + text = value.text + else: + text = value + if text is None: + return None + return _deserialize_decimal(text) + + +def _xml_deser_enum_or_str(enum_cls, value): + """Deserialize a Union[EnumType, str] from XML.""" + text = value.text if isinstance(value, ET.Element) else value + if text is None: + return None + try: + return enum_cls(text) + except ValueError: + return text + + +def _extract_xml_model_type(rf_type): + """Extract the concrete Model class from a resolved rf._type partial chain. + + Unwraps ``Optional[Model]`` and ``_deserialize_model(Model, ...)`` + wrappers. Only handles Model and Optional[Model] — other composite + types (List, Dict, Union, etc.) return None and fall through to the + generic ``_deserialize`` path at runtime. + """ + if rf_type is None: + return None + if isinstance(rf_type, type) and _is_model(rf_type): + return rf_type + if not isinstance(rf_type, functools.partial): + return None + func = rf_type.func + args = rf_type.args + if func is _deserialize_with_optional and args: + return _extract_xml_model_type(args[0]) + if func is _deserialize_model and args: + cls = args[0] + return cls if isinstance(cls, type) and _is_model(cls) else None + return None + + +def _build_xml_field_plan( # pylint: disable=docstring-missing-return, docstring-missing-rtype, unused-variable + cls, attr_to_rest_field: dict +) -> list: + """Build a precomputed XML field plan for fast _init_from_xml iteration. + + Called once per model class in __new__. Returns a list of tuples: + (rest_name, xml_name, kind, deser, rf_type, is_optional, items_name) + + kind: 0=wrapped, 1=attribute, 2=unwrapped, 3=text + + For Model and Optional[Model] fields that lack a scalar + ``_deserializer``, this function precomputes the Model class as the + deserializer so ``_init_from_xml`` can call ``ModelClass(element)`` + directly instead of going through the expensive + ``_get_deserialize_callable_from_annotation`` chain at runtime. + """ + model_meta = getattr(cls, "_xml", {}) + model_ns = model_meta.get("ns") or model_meta.get("namespace") + plan = [] + + for rf in attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + deser = rf._deserializer + + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + is_optional = rf._is_optional + + # For Model / Optional[Model] fields without a scalar deserializer, + # precompute the Model class as the deserializer. + if deser is None and rf._type is not None: + model_cls = _extract_xml_model_type(rf._type) + if model_cls is not None: + deser = model_cls + + if prop_meta.get("attribute", False): + plan.append((rf._rest_name, xml_name, 1, deser, rf._type, is_optional, None)) + elif prop_meta.get("unwrapped", False): + items_name = prop_meta.get("itemsName") + if items_name: + items_ns = prop_meta.get("itemsNs") + if items_ns is not None: + xml_ns = items_ns + if xml_ns: + items_name = "{" + xml_ns + "}" + items_name + else: + items_name = xml_name + plan.append((rf._rest_name, xml_name, 2, deser, rf._type, is_optional, items_name)) + elif prop_meta.get("text", False): + plan.append((rf._rest_name, xml_name, 3, deser, rf._type, is_optional, None)) + else: + plan.append((rf._rest_name, xml_name, 0, deser, rf._type, is_optional, None)) + + return plan + + +# pylint: enable=docstring-missing-param +class Model(_MyMutableMapping): + _is_model = True + # label whether current class's _attr_to_rest_field has been calculated + # could not see _attr_to_rest_field directly because subclass inherits it from parent class + _calculated: set[str] = set() + + def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None: + class_name = self.__class__.__name__ + if len(args) > 1: + raise TypeError(f"{class_name}.__init__() takes 2 positional arguments but {len(args) + 1} were given") + dict_to_pass: dict[str, typing.Any] = {} + if args: + if isinstance(args[0], ET.Element): + dict_to_pass.update(self._init_from_xml(args[0])) + else: + dict_to_pass.update( + {k: _create_value(_get_rest_field(self._attr_to_rest_field, k), v) for k, v in args[0].items()} + ) + else: + non_attr_kwargs = [k for k in kwargs if k not in self._attr_to_rest_field] + if non_attr_kwargs: + # actual type errors only throw the first wrong keyword arg they see, so following that. + raise TypeError(f"{class_name}.__init__() got an unexpected keyword argument '{non_attr_kwargs[0]}'") + dict_to_pass.update( + { + self._attr_to_rest_field[k]._rest_name: _create_value(self._attr_to_rest_field[k], v) + for k, v in kwargs.items() + if v is not None + } + ) + # Apply client default values for fields the caller didn't set so that + # defaults are part of `_data` and therefore included during serialization. + for rf in self._attr_to_rest_field.values(): + if rf._default is _UNSET: + continue + if rf._rest_name in dict_to_pass: + continue + dict_to_pass[rf._rest_name] = _create_value(rf, rf._default) + super().__init__(dict_to_pass) + + def _init_from_xml( # pylint: disable=too-many-branches, too-many-statements + self, element: ET.Element + ) -> dict[str, typing.Any]: + """Deserialize an XML element into a dict mapping rest field names to values. + + :param ET.Element element: The XML element to deserialize from. + :returns: A dictionary of rest_name to deserialized value pairs. + :rtype: dict + """ + result: dict[str, typing.Any] = {} + existed_attr_keys: list[str] = [] + + field_plan = getattr(self, "_xml_field_plan", None) + if field_plan: + for rest_name, xml_name, kind, deser, rf_type, is_optional, items_name in field_plan: + if kind == 0: # wrapped element (most common) + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(item) + else: + result[rest_name] = _deserialize(rf_type, item) + elif kind == 1: # attribute + attr_val = element.get(xml_name) + if attr_val is not None: + existed_attr_keys.append(xml_name) + if deser: + result[rest_name] = deser(attr_val) + else: + result[rest_name] = attr_val + elif kind == 2: # unwrapped array + items = element.findall(items_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(items_name) + if deser: + result[rest_name] = deser(items) + else: + result[rest_name] = _deserialize(rf_type, items) + elif not is_optional: + existed_attr_keys.append(items_name) + result[rest_name] = [] + elif kind == 3: # text + if element.text is not None: + if deser: + result[rest_name] = deser(element.text) + else: + result[rest_name] = element.text + else: + model_meta = getattr(self, "_xml", {}) + for rf in self._attr_to_rest_field.values(): + prop_meta = getattr(rf, "_xml", {}) + xml_name = prop_meta.get("name", rf._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + # attribute + if prop_meta.get("attribute", False) and element.get(xml_name) is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, element.get(xml_name)) + continue + + # unwrapped element is array + if prop_meta.get("unwrapped", False): + _items_name = prop_meta.get("itemsName") + if _items_name: + xml_name = _items_name + _items_ns = prop_meta.get("itemsNs") + if _items_ns is not None: + xml_ns = _items_ns + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + items = element.findall(xml_name) # pyright: ignore + if len(items) > 0: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, items) + elif not rf._is_optional: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = [] + continue + + # text element is primitive type + if prop_meta.get("text", False): + if element.text is not None: + result[rf._rest_name] = _deserialize(rf._type, element.text) + continue + + # wrapped element could be normal property or array + item = element.find(xml_name) + if item is not None: + existed_attr_keys.append(xml_name) + result[rf._rest_name] = _deserialize(rf._type, item) + + # rest thing is additional properties + for e in element: + if e.tag not in existed_attr_keys: + result[e.tag] = _convert_element(e) + + return result + + def copy(self) -> "Model": + return Model(self.__dict__) + + def __new__(cls, *args: typing.Any, **kwargs: typing.Any) -> Self: + if f"{cls.__module__}.{cls.__qualname__}" not in cls._calculated: + # we know the last nine classes in mro are going to be 'Model', '_MyMutableMapping', 'MutableMapping', + # 'Mapping', 'Collection', 'Sized', 'Iterable', 'Container' and 'object' + mros = cls.__mro__[:-9][::-1] # ignore parents, and reverse the mro order + attr_to_rest_field: dict[str, _RestField] = { # map attribute name to rest_field property + k: v for mro_class in mros for k, v in mro_class.__dict__.items() if k[0] != "_" and hasattr(v, "_type") + } + annotations = { + k: v + for mro_class in mros + if hasattr(mro_class, "__annotations__") + for k, v in mro_class.__annotations__.items() + } + for attr, rf in attr_to_rest_field.items(): + rf._module = cls.__module__ + if not rf._type: + rf._type = rf._get_deserialize_callable_from_annotation(annotations.get(attr, None)) + if not rf._rest_name_input: + rf._rest_name_input = attr + cls._attr_to_rest_field: dict[str, _RestField] = dict(attr_to_rest_field.items()) + cls._backcompat_attr_to_rest_field: dict[str, _RestField] = { + Model._get_backcompat_attribute_name(cls._attr_to_rest_field, attr): rf + for attr, rf in cls._attr_to_rest_field.items() + } + # Build XML field plan for fast _init_from_xml (only for XML models) + if getattr(cls, "_xml", None): + cls._xml_field_plan = _build_xml_field_plan(cls, attr_to_rest_field) + cls._calculated.add(f"{cls.__module__}.{cls.__qualname__}") + + return super().__new__(cls) + + def __init_subclass__(cls, discriminator: typing.Optional[str] = None) -> None: + for base in cls.__bases__: + if hasattr(base, "__mapping__"): + base.__mapping__[discriminator or cls.__name__] = cls # type: ignore + + @classmethod + def _get_backcompat_attribute_name(cls, attr_to_rest_field: dict[str, "_RestField"], attr_name: str) -> str: + rest_field_obj = attr_to_rest_field.get(attr_name) # pylint: disable=protected-access + if rest_field_obj is None: + return attr_name + original_tsp_name = getattr(rest_field_obj, "_original_tsp_name", None) # pylint: disable=protected-access + if original_tsp_name: + return original_tsp_name + return attr_name + + @classmethod + def _get_discriminator(cls, exist_discriminators) -> typing.Optional["_RestField"]: + for v in cls.__dict__.values(): + if isinstance(v, _RestField) and v._is_discriminator and v._rest_name not in exist_discriminators: + return v + return None + + @classmethod + def _deserialize(cls, data, exist_discriminators): + if not hasattr(cls, "__mapping__"): + return cls(data) + discriminator = cls._get_discriminator(exist_discriminators) + if discriminator is None: + return cls(data) + exist_discriminators.append(discriminator._rest_name) + if isinstance(data, ET.Element): + model_meta = getattr(cls, "_xml", {}) + prop_meta = getattr(discriminator, "_xml", {}) + xml_name = prop_meta.get("name", discriminator._rest_name) + xml_ns = _resolve_xml_ns(prop_meta, model_meta) + if xml_ns: + xml_name = "{" + xml_ns + "}" + xml_name + + if data.get(xml_name) is not None: + discriminator_value = data.get(xml_name) + else: + discriminator_value = data.find(xml_name).text # pyright: ignore + else: + discriminator_value = data.get(discriminator._rest_name) + mapped_cls = cls.__mapping__.get(discriminator_value, cls) # pyright: ignore # pylint: disable=no-member + return mapped_cls._deserialize(data, exist_discriminators) + + def as_dict(self, *, exclude_readonly: bool = False) -> dict[str, typing.Any]: + """Return a dict that can be turned into json using json.dump. + + :keyword bool exclude_readonly: Whether to remove the readonly properties. + :returns: A dict JSON compatible object + :rtype: dict + """ + + result = {} + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)] + for k, v in self.items(): + if exclude_readonly and k in readonly_props: # pyright: ignore + continue + is_multipart_file_input = False + try: + is_multipart_file_input = next( + rf for rf in self._attr_to_rest_field.values() if rf._rest_name == k + )._is_multipart_file_input + except StopIteration: + pass + result[k] = v if is_multipart_file_input else Model._as_dict_value(v, exclude_readonly=exclude_readonly) + return result + + @staticmethod + def _as_dict_value(v: typing.Any, exclude_readonly: bool = False) -> typing.Any: + if v is None or isinstance(v, _Null): + return None + if isinstance(v, (list, tuple, set)): + return type(v)(Model._as_dict_value(x, exclude_readonly=exclude_readonly) for x in v) + if isinstance(v, dict): + return {dk: Model._as_dict_value(dv, exclude_readonly=exclude_readonly) for dk, dv in v.items()} + return v.as_dict(exclude_readonly=exclude_readonly) if hasattr(v, "as_dict") else v + + +def _deserialize_model(model_deserializer: typing.Optional[typing.Callable], obj): + if _is_model(obj): + return obj + return _deserialize(model_deserializer, obj) + + +def _deserialize_with_optional(if_obj_deserializer: typing.Optional[typing.Callable], obj): + if obj is None: + return obj + return _deserialize_with_callable(if_obj_deserializer, obj) + + +def _deserialize_with_union(deserializers, obj): + for deserializer in deserializers: + try: + return _deserialize(deserializer, obj) + except DeserializationError: + pass + raise DeserializationError() + + +def _deserialize_dict( + value_deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj: dict[typing.Any, typing.Any], +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = {child.tag: child for child in obj} + return {k: _deserialize(value_deserializer, v, module) for k, v in obj.items()} + + +def _deserialize_multiple_sequence( + entry_deserializers: list[typing.Optional[typing.Callable]], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + return type(obj)(_deserialize(deserializer, entry, module) for entry, deserializer in zip(obj, entry_deserializers)) + + +def _is_array_encoded_deserializer(deserializer: functools.partial) -> bool: + return ( + isinstance(deserializer, functools.partial) + and isinstance(deserializer.args[0], functools.partial) + and deserializer.args[0].func == _deserialize_array_encoded # pylint: disable=comparison-with-callable + ) + + +def _deserialize_sequence( + deserializer: typing.Optional[typing.Callable], + module: typing.Optional[str], + obj, +): + if obj is None: + return obj + if isinstance(obj, ET.Element): + obj = list(obj) + + # encoded string may be deserialized to sequence + if isinstance(obj, str) and isinstance(deserializer, functools.partial): + # for list[str] + if _is_array_encoded_deserializer(deserializer): + return deserializer(obj) + + # for list[Union[...]] + if isinstance(deserializer.args[0], list): + for sub_deserializer in deserializer.args[0]: + if _is_array_encoded_deserializer(sub_deserializer): + return sub_deserializer(obj) + + return type(obj)(_deserialize(deserializer, entry, module) for entry in obj) + + +def _sorted_annotations(types: list[typing.Any]) -> list[typing.Any]: + return sorted( + types, + key=lambda x: hasattr(x, "__name__") and x.__name__.lower() in ("str", "float", "int", "bool"), + ) + + +def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-return-statements, too-many-statements, too-many-branches + annotation: typing.Any, + module: typing.Optional[str], + rf: typing.Optional["_RestField"] = None, +) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + if not annotation: + return None + + # is it a type alias? + if isinstance(annotation, str): + if module is not None: + annotation = _get_type_alias_type(module, annotation) + + # is it a forward ref / in quotes? + if isinstance(annotation, (str, typing.ForwardRef)): + try: + model_name = annotation.__forward_arg__ # type: ignore + except AttributeError: + model_name = annotation + if module is not None: + annotation = _get_model(module, model_name) # type: ignore + + try: + if module and _is_model(annotation): + if rf: + rf._is_model = True + + return functools.partial(_deserialize_model, annotation) # pyright: ignore + except Exception: + pass + + # is it a literal? + try: + if annotation.__origin__ is typing.Literal: # pyright: ignore + return None + except AttributeError: + pass + + # is it optional? + try: + if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore + if rf: + rf._is_optional = True + if len(annotation.__args__) <= 2: # pyright: ignore + if_obj_deserializer = _get_deserialize_callable_from_annotation( + next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_with_optional, if_obj_deserializer) + # the type is Optional[Union[...]], we need to remove the None type from the Union + annotation_copy = copy.copy(annotation) + annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a is not _NONE_TYPE] # pyright: ignore + return _get_deserialize_callable_from_annotation(annotation_copy, module, rf) + except AttributeError: + pass + + # is it union? + if getattr(annotation, "__origin__", None) is typing.Union: + # initial ordering is we make `string` the last deserialization option, because it is often them most generic + deserializers = [ + _get_deserialize_callable_from_annotation(arg, module, rf) + for arg in _sorted_annotations(annotation.__args__) # pyright: ignore + ] + + return functools.partial(_deserialize_with_union, deserializers) + + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() == "dict": + value_deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[1], module, rf # pyright: ignore + ) + + return functools.partial( + _deserialize_dict, + value_deserializer, + module, + ) + except (AttributeError, IndexError): + pass + try: + annotation_name = ( + annotation.__name__ if hasattr(annotation, "__name__") else annotation._name # pyright: ignore + ) + if annotation_name.lower() in ["list", "set", "tuple", "sequence"]: + if len(annotation.__args__) > 1: # pyright: ignore + entry_deserializers = [ + _get_deserialize_callable_from_annotation(dt, module, rf) + for dt in annotation.__args__ # pyright: ignore + ] + return functools.partial(_deserialize_multiple_sequence, entry_deserializers, module) + deserializer = _get_deserialize_callable_from_annotation( + annotation.__args__[0], module, rf # pyright: ignore + ) + + return functools.partial(_deserialize_sequence, deserializer, module) + except (TypeError, IndexError, AttributeError, SyntaxError): + pass + + def _deserialize_default( + deserializer, + obj, + ): + if obj is None: + return obj + try: + return _deserialize_with_callable(deserializer, obj) + except Exception: + pass + return obj + + if get_deserializer(annotation, rf): + return functools.partial(_deserialize_default, get_deserializer(annotation, rf)) + + return functools.partial(_deserialize_default, annotation) + + +def _deserialize_with_callable( + deserializer: typing.Optional[typing.Callable[[typing.Any], typing.Any]], + value: typing.Any, +): # pylint: disable=too-many-return-statements + try: + if value is None or isinstance(value, _Null): + return None + if isinstance(value, ET.Element): + if deserializer is str: + return value.text or "" + if deserializer is int: + return int(value.text) if value.text else None + if deserializer is float: + return float(value.text) if value.text else None + if deserializer is bool: + return value.text == "true" if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING.values(): + return deserializer(value.text) if value.text else None + if deserializer and deserializer in _DESERIALIZE_MAPPING_WITHFORMAT.values(): + return deserializer(value.text) if value.text else None + if deserializer is None: + return value + if deserializer in [int, float, bool]: + return deserializer(value) + if isinstance(deserializer, CaseInsensitiveEnumMeta): + try: + return deserializer(value.text if isinstance(value, ET.Element) else value) + except ValueError: + # for unknown value, return raw value + return value.text if isinstance(value, ET.Element) else value + if isinstance(deserializer, type) and issubclass(deserializer, Model): + return deserializer._deserialize(value, []) + return typing.cast(typing.Callable[[typing.Any], typing.Any], deserializer)(value) + except Exception as e: + raise DeserializationError() from e + + +def _deserialize( + deserializer: typing.Any, + value: typing.Any, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + if isinstance(value, PipelineResponse): + value = value.http_response.json() + if rf is None and format: + rf = _RestField(format=format) + if not isinstance(deserializer, functools.partial): + deserializer = _get_deserialize_callable_from_annotation(deserializer, module, rf) + return _deserialize_with_callable(deserializer, value) + + +def _failsafe_deserialize( + deserializer: typing.Any, + response: HttpResponse, + module: typing.Optional[str] = None, + rf: typing.Optional["_RestField"] = None, + format: typing.Optional[str] = None, +) -> typing.Any: + try: + return _deserialize(deserializer, response.json(), module, rf, format) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +def _failsafe_deserialize_xml( + deserializer: typing.Any, + response: HttpResponse, +) -> typing.Any: + try: + return _deserialize_xml(deserializer, response.text()) + except Exception: # pylint: disable=broad-except + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + +# pylint: disable=too-many-instance-attributes +class _RestField: + def __init__( + self, + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + is_discriminator: bool = False, + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, + original_tsp_name: typing.Optional[str] = None, + ): + self._type = type + self._rest_name_input = name + self._module: typing.Optional[str] = None + self._is_discriminator = is_discriminator + self._visibility = visibility + self._is_model = False + self._is_optional = False + self._default = default + self._format = format + self._is_multipart_file_input = is_multipart_file_input + self._xml = xml if xml is not None else {} + self._deserializer = deserializer + self._original_tsp_name = original_tsp_name + + @property + def _class_type(self) -> typing.Any: + result = getattr(self._type, "args", [None])[0] + # type may be wrapped by nested functools.partial so we need to check for that + if isinstance(result, functools.partial): + return getattr(result, "args", [None])[0] + return result + + @property + def _rest_name(self) -> str: + if self._rest_name_input is None: + raise ValueError("Rest name was never set") + return self._rest_name_input + + def __get__(self, obj: Model, type=None): # pylint: disable=redefined-builtin + # by this point, type and rest_name will have a value bc we default + # them in __new__ of the Model class + # Use _data.get() directly to avoid triggering __getitem__ which clears the cache + item = obj._data.get(self._rest_name, _UNSET) + if item is _UNSET: + # Field not set by user; return the client default if one exists, otherwise None + return self._default if self._default is not _UNSET else None + if item is None: + return item + if self._is_model: + return item + + # For mutable types, we want mutations to directly affect _data + # Check if we've already deserialized this value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + # Return the value from _data directly (it's been deserialized in place) + return obj._data.get(self._rest_name) + + # Fast path: use _deserializer directly (avoids _serialize/_deserialize chain) + if self._deserializer: + deserialized = self._deserializer(item) + else: + deserialized = _deserialize(self._type, _serialize(item, self._format), rf=self) + + # For mutable types, store the deserialized value back in _data + # so mutations directly affect _data + if isinstance(deserialized, (dict, list, set)): + obj._data[self._rest_name] = deserialized + object.__setattr__(obj, cache_attr, True) # Mark as deserialized + return deserialized + + return deserialized + + def __set__(self, obj: Model, value) -> None: + # Clear the cached deserialized object when setting a new value + cache_attr = f"_deserialized_{self._rest_name}" + if hasattr(obj, cache_attr): + object.__delattr__(obj, cache_attr) + + if value is None: + # we want to wipe out entries if users set attr to None + try: + obj.__delitem__(self._rest_name) + except KeyError: + pass + return + if self._is_model: + if not _is_model(value): + value = _deserialize(self._type, value) + obj.__setitem__(self._rest_name, value) + return + obj.__setitem__(self._rest_name, _serialize(value, self._format)) + + def _get_deserialize_callable_from_annotation( + self, annotation: typing.Any + ) -> typing.Optional[typing.Callable[[typing.Any], typing.Any]]: + return _get_deserialize_callable_from_annotation(annotation, self._module, self) + + +def rest_field( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + default: typing.Any = _UNSET, + format: typing.Optional[str] = None, + is_multipart_file_input: bool = False, + xml: typing.Optional[dict[str, typing.Any]] = None, + deserializer: typing.Optional[typing.Callable] = None, + original_tsp_name: typing.Optional[str] = None, +) -> typing.Any: + return _RestField( + name=name, + type=type, + visibility=visibility, + default=default, + format=format, + is_multipart_file_input=is_multipart_file_input, + xml=xml, + deserializer=deserializer, + original_tsp_name=original_tsp_name, + ) + + +def rest_discriminator( + *, + name: typing.Optional[str] = None, + type: typing.Optional[typing.Callable] = None, # pylint: disable=redefined-builtin + visibility: typing.Optional[list[str]] = None, + xml: typing.Optional[dict[str, typing.Any]] = None, +) -> typing.Any: + return _RestField(name=name, type=type, is_discriminator=True, visibility=visibility, xml=xml) + + +def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: + """Serialize a model to XML. + + :param Model model: The model to serialize. + :param bool exclude_readonly: Whether to exclude readonly properties. + :returns: The XML representation of the model. + :rtype: str + """ + return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore + + +def _get_xml_ns(meta: dict[str, typing.Any]) -> typing.Optional[str]: + """Return the XML namespace from a metadata dict, checking both 'ns' (old-style) and 'namespace' (DPG) keys. + + :param dict meta: The metadata dictionary to extract namespace from. + :returns: The namespace string if 'ns' or 'namespace' key is present, None otherwise. + :rtype: str or None + """ + ns = meta.get("ns") + if ns is None: + ns = meta.get("namespace") + return ns + + +def _resolve_xml_ns( + prop_meta: dict[str, typing.Any], model_meta: typing.Optional[dict[str, typing.Any]] = None +) -> typing.Optional[str]: + """Resolve XML namespace for a property, falling back to model namespace when appropriate. + + Checks the property metadata first; if no namespace is found and the model does not declare + an explicit prefix, falls back to the model-level namespace. + + :param dict prop_meta: The property metadata dictionary. + :param dict model_meta: The model metadata dictionary, used as fallback. + :returns: The resolved namespace string, or None. + :rtype: str or None + """ + ns = _get_xml_ns(prop_meta) + if ns is None and model_meta is not None and not model_meta.get("prefix"): + ns = _get_xml_ns(model_meta) + return ns + + +def _set_xml_attribute(element: ET.Element, name: str, value: typing.Any, prop_meta: dict[str, typing.Any]) -> None: + """Set an XML attribute on an element, handling namespace prefix registration. + + :param ET.Element element: The element to set the attribute on. + :param str name: The default attribute name (wire name). + :param any value: The attribute value. + :param dict prop_meta: The property metadata dictionary. + """ + xml_name = prop_meta.get("name", name) + _attr_ns = _get_xml_ns(prop_meta) + if _attr_ns: + _attr_prefix = prop_meta.get("prefix") + if _attr_prefix: + _safe_register_namespace(_attr_prefix, _attr_ns) + xml_name = "{" + _attr_ns + "}" + xml_name + element.set(xml_name, _get_primitive_type_value(value)) + + +def _get_element( + o: typing.Any, + exclude_readonly: bool = False, + parent_meta: typing.Optional[dict[str, typing.Any]] = None, + wrapped_element: typing.Optional[ET.Element] = None, +) -> typing.Union[ET.Element, list[ET.Element]]: + if _is_model(o): + model_meta = getattr(o, "_xml", {}) + + # if prop is a model, then use the prop element directly, else generate a wrapper of model + if wrapped_element is None: + # When serializing as an array item (parent_meta is set), check if the parent has an + # explicit itemsName. This ensures correct element names for unwrapped arrays (where + # the element tag is the property/items name, not the model type name). + _items_name = parent_meta.get("itemsName") if parent_meta is not None else None + element_name = _items_name if _items_name else (model_meta.get("name") or o.__class__.__name__) + _model_ns = _get_xml_ns(model_meta) + wrapped_element = _create_xml_element( + element_name, + model_meta.get("prefix"), + _model_ns, + ) + + readonly_props = [] + if exclude_readonly: + readonly_props = [p._rest_name for p in o._attr_to_rest_field.values() if _is_readonly(p)] + + for k, v in o.items(): + # do not serialize readonly properties + if exclude_readonly and k in readonly_props: + continue + + prop_rest_field = _get_rest_field(o._attr_to_rest_field, k) + if prop_rest_field: + prop_meta = getattr(prop_rest_field, "_xml").copy() + # use the wire name as xml name if no specific name is set + if prop_meta.get("name") is None: + prop_meta["name"] = k + else: + # additional properties will not have rest field, use the wire name as xml name + prop_meta = {"name": k} + + # Propagate model namespace to properties only for old-style "ns"-keyed models. + # DPG-generated models use the "namespace" key and explicitly declare namespace on + # each property that needs it, so propagation is intentionally skipped for them. + if prop_meta.get("ns") is None and model_meta.get("ns"): + prop_meta["ns"] = model_meta.get("ns") + prop_meta["prefix"] = model_meta.get("prefix") + + if prop_meta.get("unwrapped", False): + # unwrapped could only set on array + wrapped_element.extend(_get_element(v, exclude_readonly, prop_meta)) + elif prop_meta.get("text", False): + # text could only set on primitive type + wrapped_element.text = _get_primitive_type_value(v) + elif prop_meta.get("attribute", False): + _set_xml_attribute(wrapped_element, k, v, prop_meta) + else: + # other wrapped prop element + wrapped_element.append(_get_wrapped_element(v, exclude_readonly, prop_meta)) + return wrapped_element + if isinstance(o, list): + return [_get_element(x, exclude_readonly, parent_meta) for x in o] # type: ignore + if isinstance(o, dict): + result = [] + _dict_ns = _get_xml_ns(parent_meta) if parent_meta else None + for k, v in o.items(): + result.append( + _get_wrapped_element( + v, + exclude_readonly, + { + "name": k, + "ns": _dict_ns, + "prefix": parent_meta.get("prefix") if parent_meta else None, + }, + ) + ) + return result + + # primitive case need to create element based on parent_meta + if parent_meta: + _items_ns = parent_meta.get("itemsNs") + if _items_ns is None: + _items_ns = _get_xml_ns(parent_meta) + return _get_wrapped_element( + o, + exclude_readonly, + { + "name": parent_meta.get("itemsName", parent_meta.get("name")), + "prefix": parent_meta.get("itemsPrefix", parent_meta.get("prefix")), + "ns": _items_ns, + }, + ) + + raise ValueError("Could not serialize value into xml: " + o) + + +def _get_wrapped_element( + v: typing.Any, + exclude_readonly: bool, + meta: typing.Optional[dict[str, typing.Any]], +) -> ET.Element: + _meta_ns = _get_xml_ns(meta) if meta else None + wrapped_element = _create_xml_element( + meta.get("name") if meta else None, meta.get("prefix") if meta else None, _meta_ns + ) + if isinstance(v, (dict, list)): + wrapped_element.extend(_get_element(v, exclude_readonly, meta)) + elif _is_model(v): + _get_element(v, exclude_readonly, meta, wrapped_element) + else: + wrapped_element.text = _get_primitive_type_value(v) + return wrapped_element # type: ignore[no-any-return] + + +def _get_primitive_type_value(v) -> str: + if v is True: + return "true" + if v is False: + return "false" + if isinstance(v, _Null): + return "" + return str(v) + + +def _safe_register_namespace(prefix: str, ns: str) -> None: + """Register an XML namespace prefix, handling reserved prefix patterns. + + Some prefixes (e.g. 'ns2') match Python's reserved 'ns\\d+' pattern used for + auto-generated prefixes, causing register_namespace to raise ValueError. + Falls back to directly registering in the internal namespace map. + + :param str prefix: The namespace prefix to register. + :param str ns: The namespace URI. + """ + try: + ET.register_namespace(prefix, ns) + except ValueError: + _ns_map = getattr(ET, "_namespace_map", None) + if _ns_map is not None: + _ns_map[ns] = prefix + + +def _create_xml_element( + tag: typing.Any, prefix: typing.Optional[str] = None, ns: typing.Optional[str] = None +) -> ET.Element: + if prefix and ns: + _safe_register_namespace(prefix, ns) + if ns: + return ET.Element("{" + ns + "}" + tag) + return ET.Element(tag) + + +def _deserialize_xml( + deserializer: typing.Any, + value: str, +) -> typing.Any: + element = ET.fromstring(value) # nosec + if _is_model(deserializer): + return deserializer._deserialize(element, []) + return _deserialize(deserializer, element) + + +def _convert_element(e: ET.Element): + # dict case + if len(e.attrib) > 0 or len({child.tag for child in e}) > 1: + dict_result: dict[str, typing.Any] = {} + for child in e: + if dict_result.get(child.tag) is not None: + if isinstance(dict_result[child.tag], list): + dict_result[child.tag].append(_convert_element(child)) + else: + dict_result[child.tag] = [dict_result[child.tag], _convert_element(child)] + else: + dict_result[child.tag] = _convert_element(child) + dict_result.update(e.attrib) + return dict_result + # array case + if len(e) > 0: + array_result: list[typing.Any] = [] + for child in e: + array_result.append(_convert_element(child)) + return array_result + # primitive case + return e.text diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py index 6da830e0cf4a..a088671e9c51 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,11 +39,15 @@ import xml.etree.ElementTree as ET import isodate # type: ignore -from typing_extensions import Self from azure.core.exceptions import DeserializationError, SerializationError from azure.core.serialization import NULL as CoreNull +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self + _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") JSON = MutableMapping[str, Any] @@ -1401,7 +1405,7 @@ def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: # Otherwise, result are unexpected self.additional_properties_detection = True - def __call__(self, target_obj, response_data, content_type=None): + def __call__(self, target_obj, response_data, content_type=None): # pylint: disable=too-many-return-statements """Call the deserializer to process a REST response. :param str target_obj: Target data type to deserialize to. @@ -1411,6 +1415,27 @@ def __call__(self, target_obj, response_data, content_type=None): :return: Deserialized object. :rtype: object """ + # Fast path for header deserialization: response_data is a plain str or None + # and target_obj is a simple scalar type. This avoids the expensive + # _unpack_content → _deserialize → _classify_target → deserialize_data chain. + if response_data is None: + return None + if target_obj == "str" and isinstance(response_data, str): + return response_data + if isinstance(response_data, str): + if target_obj == "int": + return int(response_data) + if target_obj == "bool": + if response_data in ("true", "1", "True"): + return True + if response_data in ("false", "0", "False"): + return False + return bool(response_data) + if target_obj == "rfc-1123": + return Deserializer.deserialize_rfc(response_data) + if target_obj == "bytearray": + return Deserializer.deserialize_bytearray(response_data) + data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_version.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_version.py index 13fcaff38832..1298cba4f125 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_version.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_version.py @@ -2,9 +2,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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- - -VERSION = "1.0.1" +VERSION = "1.1.0b6" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py index 78e779b05c32..577146739dc2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,7 +12,7 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._policy_insights_client import PolicyInsightsClient # type: ignore +from ._client import PolicyInsightsClient # type: ignore try: from ._patch import __all__ as _patch_all diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_client.py similarity index 81% rename from sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py rename to sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_client.py index 70f14b8c4799..ceebb8bad151 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_client.py @@ -2,13 +2,13 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from copy import deepcopy +import sys from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast -from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -17,10 +17,11 @@ from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from azure.mgmt.core.tools import get_arm_endpoints -from .. import models as _models from .._utils.serialization import Deserializer, Serializer from ._configuration import PolicyInsightsClientConfiguration from .operations import ( + AttestationsOperations, + ComponentPolicyStatesOperations, Operations, PolicyEventsOperations, PolicyMetadataOperations, @@ -30,6 +31,11 @@ RemediationsOperations, ) +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # type: ignore + if TYPE_CHECKING: from azure.core import AzureClouds from azure.core.credentials_async import AsyncTokenCredential @@ -38,27 +44,32 @@ class PolicyInsightsClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """PolicyInsightsClient. - :ivar policy_tracked_resources: PolicyTrackedResourcesOperations operations - :vartype policy_tracked_resources: - azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.policyinsights.aio.operations.Operations :ivar remediations: RemediationsOperations operations :vartype remediations: azure.mgmt.policyinsights.aio.operations.RemediationsOperations + :ivar attestations: AttestationsOperations operations + :vartype attestations: azure.mgmt.policyinsights.aio.operations.AttestationsOperations + :ivar policy_metadata: PolicyMetadataOperations operations + :vartype policy_metadata: azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations :ivar policy_events: PolicyEventsOperations operations :vartype policy_events: azure.mgmt.policyinsights.aio.operations.PolicyEventsOperations :ivar policy_states: PolicyStatesOperations operations :vartype policy_states: azure.mgmt.policyinsights.aio.operations.PolicyStatesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.policyinsights.aio.operations.Operations - :ivar policy_metadata: PolicyMetadataOperations operations - :vartype policy_metadata: azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations :ivar policy_restrictions: PolicyRestrictionsOperations operations :vartype policy_restrictions: azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations - :param credential: Credential needed for the client to connect to Azure. Required. + :ivar component_policy_states: ComponentPolicyStatesOperations operations + :vartype component_policy_states: + azure.mgmt.policyinsights.aio.operations.ComponentPolicyStatesOperations + :ivar policy_tracked_resources: PolicyTrackedResourcesOperations operations + :vartype policy_tracked_resources: + azure.mgmt.policyinsights.aio.operations.PolicyTrackedResourcesOperations + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Microsoft Azure subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is None. + :param base_url: Service host. Default value is None. :type base_url: str :keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. @@ -76,6 +87,7 @@ def __init__( cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: + _endpoint = "{endpoint}" _cloud = cloud_setting or settings.current.azure_cloud # type: ignore _endpoints = get_arm_endpoints(_cloud) if not base_url: @@ -84,6 +96,7 @@ def __init__( self._config = PolicyInsightsClientConfiguration( credential=credential, subscription_id=subscription_id, + base_url=cast(str, base_url), cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs @@ -108,26 +121,29 @@ def __init__( self._config.http_logging_policy, ] self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( - base_url=cast(str, base_url), policies=_policies, **kwargs + base_url=cast(str, _endpoint), policies=_policies, **kwargs ) - client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._deserialize = Deserializer(client_models) + self._serialize = Serializer() + self._deserialize = Deserializer() self._serialize.client_side_validation = False - self.policy_tracked_resources = PolicyTrackedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.remediations = RemediationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.attestations = AttestationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policy_metadata = PolicyMetadataOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_events = PolicyEventsOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_states = PolicyStatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.policy_metadata = PolicyMetadataOperations(self._client, self._config, self._serialize, self._deserialize) self.policy_restrictions = PolicyRestrictionsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.component_policy_states = ComponentPolicyStatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.policy_tracked_resources = PolicyTrackedResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( + def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -135,7 +151,7 @@ def _send_request( >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") - >>> response = await client._send_request(request) + >>> response = await client.send_request(request) For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request @@ -148,7 +164,11 @@ def _send_request( """ request_copy = deepcopy(request) - request_copy.url = self._client.format_url(request_copy.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py index a9ce14e4eb58..554783ca0c7a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -24,10 +24,12 @@ class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-at Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. Required. + :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Microsoft Azure subscription ID. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str + :param base_url: Service host. Default value is "https://management.azure.com". + :type base_url: str :param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is None. :type cloud_setting: ~azure.core.AzureClouds @@ -37,6 +39,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, + base_url: str = "https://management.azure.com", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any ) -> None: @@ -47,6 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id + self.base_url = base_url self.cloud_setting = cloud_setting self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-policyinsights/{}".format(VERSION)) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_patch.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_patch.py index 49900f6ab120..ea765788358a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_patch.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_patch.py @@ -1,15 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py index 767d5e51c452..0da3fdcef222 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,26 +12,30 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._policy_tracked_resources_operations import PolicyTrackedResourcesOperations # type: ignore -from ._remediations_operations import RemediationsOperations # type: ignore -from ._policy_events_operations import PolicyEventsOperations # type: ignore -from ._policy_states_operations import PolicyStatesOperations # type: ignore from ._operations import Operations # type: ignore -from ._policy_metadata_operations import PolicyMetadataOperations # type: ignore -from ._policy_restrictions_operations import PolicyRestrictionsOperations # type: ignore +from ._operations import RemediationsOperations # type: ignore +from ._operations import AttestationsOperations # type: ignore +from ._operations import PolicyMetadataOperations # type: ignore +from ._operations import PolicyEventsOperations # type: ignore +from ._operations import PolicyStatesOperations # type: ignore +from ._operations import PolicyRestrictionsOperations # type: ignore +from ._operations import ComponentPolicyStatesOperations # type: ignore +from ._operations import PolicyTrackedResourcesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "PolicyTrackedResourcesOperations", + "Operations", "RemediationsOperations", + "AttestationsOperations", + "PolicyMetadataOperations", "PolicyEventsOperations", "PolicyStatesOperations", - "Operations", - "PolicyMetadataOperations", "PolicyRestrictionsOperations", + "ComponentPolicyStatesOperations", + "PolicyTrackedResourcesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py index c7b490abe083..734d19a7a4ef 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py @@ -1,35 +1,126 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +import datetime +from io import IOBase +import json +from typing import Any, AsyncIterator, Callable, IO, Literal, Optional, TypeVar, Union, cast, overload from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models +from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer -from ...operations._operations import build_list_request +from ...operations._operations import ( + build_attestations_create_or_update_at_resource_group_request, + build_attestations_create_or_update_at_resource_request, + build_attestations_create_or_update_at_subscription_request, + build_attestations_delete_at_resource_group_request, + build_attestations_delete_at_resource_request, + build_attestations_delete_at_subscription_request, + build_attestations_get_at_resource_group_request, + build_attestations_get_at_resource_request, + build_attestations_get_at_subscription_request, + build_attestations_list_for_resource_group_request, + build_attestations_list_for_resource_request, + build_attestations_list_for_subscription_request, + build_component_policy_states_list_query_results_for_policy_definition_request, + build_component_policy_states_list_query_results_for_resource_group_level_policy_assignment_request, + build_component_policy_states_list_query_results_for_resource_group_request, + build_component_policy_states_list_query_results_for_resource_request, + build_component_policy_states_list_query_results_for_subscription_level_policy_assignment_request, + build_component_policy_states_list_query_results_for_subscription_request, + build_operations_list_request, + build_policy_events_list_query_results_for_management_group_request, + build_policy_events_list_query_results_for_policy_definition_request, + build_policy_events_list_query_results_for_policy_set_definition_request, + build_policy_events_list_query_results_for_resource_group_level_policy_assignment_request, + build_policy_events_list_query_results_for_resource_group_request, + build_policy_events_list_query_results_for_resource_request, + build_policy_events_list_query_results_for_subscription_level_policy_assignment_request, + build_policy_events_list_query_results_for_subscription_request, + build_policy_metadata_get_resource_request, + build_policy_metadata_list_request, + build_policy_restrictions_check_at_management_group_scope_request, + build_policy_restrictions_check_at_resource_group_scope_request, + build_policy_restrictions_check_at_subscription_scope_request, + build_policy_states_list_query_results_for_management_group_request, + build_policy_states_list_query_results_for_policy_definition_request, + build_policy_states_list_query_results_for_policy_set_definition_request, + build_policy_states_list_query_results_for_resource_group_level_policy_assignment_request, + build_policy_states_list_query_results_for_resource_group_request, + build_policy_states_list_query_results_for_resource_request, + build_policy_states_list_query_results_for_subscription_level_policy_assignment_request, + build_policy_states_list_query_results_for_subscription_request, + build_policy_states_summarize_for_management_group_request, + build_policy_states_summarize_for_policy_definition_request, + build_policy_states_summarize_for_policy_set_definition_request, + build_policy_states_summarize_for_resource_group_level_policy_assignment_request, + build_policy_states_summarize_for_resource_group_request, + build_policy_states_summarize_for_resource_request, + build_policy_states_summarize_for_subscription_level_policy_assignment_request, + build_policy_states_summarize_for_subscription_request, + build_policy_states_trigger_resource_group_evaluation_request, + build_policy_states_trigger_subscription_evaluation_request, + build_policy_tracked_resources_list_query_results_for_management_group_request, + build_policy_tracked_resources_list_query_results_for_resource_group_request, + build_policy_tracked_resources_list_query_results_for_resource_request, + build_policy_tracked_resources_list_query_results_for_subscription_request, + build_remediations_cancel_at_management_group_request, + build_remediations_cancel_at_resource_group_request, + build_remediations_cancel_at_resource_request, + build_remediations_cancel_at_subscription_request, + build_remediations_create_or_update_at_management_group_request, + build_remediations_create_or_update_at_resource_group_request, + build_remediations_create_or_update_at_resource_request, + build_remediations_create_or_update_at_subscription_request, + build_remediations_delete_at_management_group_request, + build_remediations_delete_at_resource_group_request, + build_remediations_delete_at_resource_request, + build_remediations_delete_at_subscription_request, + build_remediations_get_at_management_group_request, + build_remediations_get_at_resource_group_request, + build_remediations_get_at_resource_request, + build_remediations_get_at_subscription_request, + build_remediations_list_deployments_at_management_group_request, + build_remediations_list_deployments_at_resource_group_request, + build_remediations_list_deployments_at_resource_request, + build_remediations_list_deployments_at_subscription_request, + build_remediations_list_for_management_group_request, + build_remediations_list_for_resource_group_request, + build_remediations_list_for_resource_request, + build_remediations_list_for_subscription_request, +) from .._configuration import PolicyInsightsClientConfiguration T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list @@ -43,8 +134,6 @@ class Operations: :attr:`operations` 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") @@ -56,7 +145,7 @@ def __init__(self, *args, **kwargs) -> None: async def list(self, **kwargs: Any) -> _models.OperationsListResults: """Lists available operations. - :return: OperationsListResults or the result of cls(response) + :return: OperationsListResults. The OperationsListResults is compatible with MutableMapping :rtype: ~azure.mgmt.policyinsights.models.OperationsListResults :raises ~azure.core.exceptions.HttpResponseError: """ @@ -71,17 +160,21 @@ async def list(self, **kwargs: Any) -> _models.OperationsListResults: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.OperationsListResults] = kwargs.pop("cls", None) - _request = build_list_request( + _request = build_operations_list_request( api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -89,16 +182,8663 @@ async def list(self, **kwargs: Any) -> _models.OperationsListResults: response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( + error = _failsafe_deserialize( _models.QueryFailure, - pipeline_response, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationsListResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class RemediationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`remediations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_at_management_group( + self, management_group_id: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Gets an existing remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: Union[_models.Remediation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_at_management_group( + self, management_group_id: str, remediation_name: str, **kwargs: Any + ) -> Optional[_models.Remediation]: + """Deletes an existing remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_management_group( + self, management_group_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Remediation"]: + """Gets all remediations for the management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_management_group_request( + management_group_id=management_group_id, + top=top, + filter=filter, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Gets an existing remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationsListResults", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + @overload + async def create_or_update_at_subscription( + self, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_subscription( + self, remediation_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_subscription( + self, remediation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_subscription( + self, remediation_name: str, parameters: Union[_models.Remediation, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Optional[_models.Remediation]: + """Deletes an existing remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_subscription( + self, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Remediation"]: + """Gets all remediations for the subscription. + + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_deployments_at_subscription( + self, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :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", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Cancels a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_at_resource_group( + self, resource_group_name: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Gets an existing remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: Union[_models.Remediation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_at_resource_group( + self, resource_group_name: str, remediation_name: str, **kwargs: Any + ) -> Optional[_models.Remediation]: + """Deletes an existing remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Remediation"]: + """Gets all remediations for the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_deployments_at_resource_group( + self, resource_group_name: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :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", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel_at_resource_group( + self, resource_group_name: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Cancels a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Gets an existing remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: Union[_models.Remediation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete_at_resource( + self, resource_id: str, remediation_name: str, **kwargs: Any + ) -> Optional[_models.Remediation]: + """Deletes an existing remediation at individual resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_resource( + self, resource_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Remediation"]: + """Gets all remediations for a resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_resource_request( + resource_id=resource_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_deployments_at_resource( + self, resource_id: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :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", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Cancel a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_deployments_at_management_group( + self, management_group_id: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + top=top, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def cancel_at_management_group( + self, management_group_id: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Cancels a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class AttestationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`attestations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.Attestation: + """Gets an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: Attestation. The Attestation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :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", "2024-10-01")) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + + _request = build_attestations_get_at_subscription_request( + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Attestation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_at_subscription_initial( # pylint: disable=name-too-long + self, attestation_name: str, parameters: Union[_models.Attestation, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_attestations_create_or_update_at_subscription_request( + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update_at_subscription( + self, + attestation_name: str, + parameters: _models.Attestation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_at_subscription( + self, attestation_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_at_subscription( + self, attestation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. 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: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_subscription( + self, attestation_name: str, parameters: Union[_models.Attestation, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Is one of the following types: Attestation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_at_subscription_initial( + attestation_name=attestation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Attestation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Attestation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete_at_subscription(self, attestation_name: str, **kwargs: Any) -> None: + """Deletes an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_attestations_delete_at_subscription_request( + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_for_subscription( + self, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Attestation"]: + """Gets all attestations for the subscription. + + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Attestation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Attestation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Attestation]] = 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_attestations_list_for_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Attestation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_at_resource_group( + self, resource_group_name: str, attestation_name: str, **kwargs: Any + ) -> _models.Attestation: + """Gets an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: Attestation. The Attestation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :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", "2024-10-01")) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + + _request = build_attestations_get_at_resource_group_request( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Attestation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_at_resource_group_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_attestations_create_or_update_at_resource_group_request( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: _models.Attestation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. 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: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Is one of the following types: Attestation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_at_resource_group_initial( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Attestation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Attestation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete_at_resource_group(self, resource_group_name: str, attestation_name: str, **kwargs: Any) -> None: + """Deletes an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_attestations_delete_at_resource_group_request( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_for_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Attestation"]: + """Gets all attestations for the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Attestation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Attestation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Attestation]] = 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_attestations_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Attestation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any) -> _models.Attestation: + """Gets an existing attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: Attestation. The Attestation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :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", "2024-10-01")) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + + _request = build_attestations_get_at_resource_request( + resource_id=resource_id, + attestation_name=attestation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Attestation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_at_resource_initial( + self, + resource_id: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_attestations_create_or_update_at_resource_request( + resource_id=resource_id, + attestation_name=attestation_name, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: _models.Attestation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. 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: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Is one of the following types: Attestation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns Attestation. The Attestation is compatible + with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_at_resource_initial( + resource_id=resource_id, + attestation_name=attestation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Attestation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Attestation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def delete_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any) -> None: + """Deletes an existing attestation at individual resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_attestations_delete_at_resource_request( + resource_id=resource_id, + attestation_name=attestation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_for_resource( + self, resource_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.Attestation"]: + """Gets all attestations for a resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Attestation + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Attestation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Attestation]] = 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_attestations_list_for_resource_request( + resource_id=resource_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Attestation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PolicyMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`policy_metadata` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetadata: + """Get policy metadata resource. + + :param resource_name: The name of the policy metadata resource. Required. + :type resource_name: str + :return: PolicyMetadata. The PolicyMetadata is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.PolicyMetadata + :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", "2024-10-01")) + cls: ClsType[_models.PolicyMetadata] = kwargs.pop("cls", None) + + _request = build_policy_metadata_get_resource_request( + resource_name=resource_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyMetadata, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, *, top: Optional[int] = None, **kwargs: Any) -> AsyncItemPaged["_models.SlimPolicyMetadata"]: + """Get a list of the policy metadata resources. + + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of SlimPolicyMetadata + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] + :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", "2024-10-01")) + cls: ClsType[List[_models.SlimPolicyMetadata]] = 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_metadata_list_request( + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SlimPolicyMetadata], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PolicyEventsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`policy_events` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( # pylint: disable=too-many-locals + self, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + management_group_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resources under the management group. + + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param management_group_name: Management group name. Required. + :type management_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_management_group_request( + policy_events_resource=policy_events_resource, + management_group_name=management_group_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_subscription( + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_subscription_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource_group( # pylint: disable=too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_events_resource=policy_events_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource( # pylint: disable=too-many-locals + self, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + resource_id: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resource. + + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword expand: The $expand query parameter. For example, to expand components use + $expand=components. Default value is None. + :paramtype expand: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_resource_request( + policy_events_resource=policy_events_resource, + resource_id=resource_id, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + expand=expand, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the subscription level policy set definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_set_definition_name: Policy set definition name. Required. + :type policy_set_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_policy_set_definition_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + policy_set_definition_name=policy_set_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_policy_definition( # pylint: disable=too-many-locals + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_policy_definition_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + policy_definition_name=policy_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_events_resource=policy_events_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class PolicyStatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`policy_states` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( # pylint: disable=too-many-locals + self, + policy_states_resource: Union[str, _models.PolicyStatesResource], + management_group_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the resources under the management group. + + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param management_group_name: Management group name. Required. + :type management_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_management_group_request( + policy_states_resource=policy_states_resource, + management_group_name=management_group_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_management_group( + self, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + management_group_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resources under the management group. + + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param management_group_name: Management group name. Required. + :type management_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_management_group_request( + policy_states_summary_resource=policy_states_summary_resource, + management_group_name=management_group_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_subscription( + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_subscription_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_subscription( + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_subscription_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource_group( # pylint: disable=too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_resource=policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_resource_group( + self, + subscription_id: str, + resource_group_name: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_summary_resource=policy_states_summary_resource, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource( # pylint: disable=too-many-locals + self, + policy_states_resource: Union[str, _models.PolicyStatesResource], + resource_id: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the resource. + + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword expand: The $expand query parameter. For example, to expand components use + $expand=components. Default value is None. + :paramtype expand: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_resource_request( + policy_states_resource=policy_states_resource, + resource_id=resource_id, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + expand=expand, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_resource( + self, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + resource_id: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resource. + + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_resource_request( + policy_states_summary_resource=policy_states_summary_resource, + resource_id=resource_id, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _trigger_subscription_evaluation_initial( + self, subscription_id: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-10-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_policy_states_trigger_subscription_evaluation_request( + subscription_id=subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Triggers a policy evaluation scan for all the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[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", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._trigger_subscription_evaluation_initial( + subscription_id=subscription_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _trigger_resource_group_evaluation_initial( # pylint: disable=name-too-long + self, subscription_id: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + 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", "2024-10-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_policy_states_trigger_resource_group_evaluation_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_trigger_resource_group_evaluation( + self, subscription_id: str, resource_group_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Triggers a policy evaluation scan for all the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :return: An instance of AsyncLROPoller that returns None + :rtype: ~azure.core.polling.AsyncLROPoller[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", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._trigger_resource_group_evaluation_initial( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the subscription level policy set definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_set_definition_name: Policy set definition name. Required. + :type policy_set_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_policy_set_definition_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + policy_set_definition_name=policy_set_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_policy_set_definition( + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the subscription level policy set definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_set_definition_name: Policy set definition name. Required. + :type policy_set_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_policy_set_definition_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + policy_set_definition_name=policy_set_definition_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_policy_definition( # pylint: disable=too-many-locals + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_policy_definition_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + policy_definition_name=policy_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_policy_definition( + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_definition_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_policy_definition_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + policy_definition_name=policy_definition_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_subscription_level_policy_assignment( # pylint: disable=name-too-long + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + policy_assignment_name=policy_assignment_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyState"]: + """Queries policy states for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_resource=policy_states_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def summarize_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long + self, + subscription_id: str, + resource_group_name: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_summary_resource=policy_states_summary_resource, + policy_assignment_name=policy_assignment_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyRestrictionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`policy_restrictions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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 check_at_subscription_scope( + self, parameters: _models.CheckRestrictionsRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_at_subscription_scope( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_at_subscription_scope( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :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: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_at_subscription_scope( + self, parameters: Union[_models.CheckRestrictionsRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :param parameters: The request body. Is one of the following types: CheckRestrictionsRequest, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or JSON or + IO[bytes] + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restrictions_check_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckRestrictionsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_at_resource_group_scope( + self, + resource_group_name: str, + parameters: _models.CheckRestrictionsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_at_resource_group_scope( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_at_resource_group_scope( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_at_resource_group_scope( + self, + resource_group_name: str, + parameters: Union[_models.CheckRestrictionsRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The request body. Is one of the following types: CheckRestrictionsRequest, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or JSON or + IO[bytes] + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restrictions_check_at_resource_group_scope_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckRestrictionsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def check_at_management_group_scope( + self, + management_group_id: str, + parameters: _models.CheckManagementGroupRestrictionsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_at_management_group_scope( + self, management_group_id: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_at_management_group_scope( + self, management_group_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. 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: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_at_management_group_scope( + self, + management_group_id: str, + parameters: Union[_models.CheckManagementGroupRestrictionsRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. Is one of the following types: + CheckManagementGroupRestrictionsRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest or + JSON or IO[bytes] + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restrictions_check_at_management_group_scope_request( + management_group_id=management_group_id, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckRestrictionsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ComponentPolicyStatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`component_policy_states` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_subscription( + self, + subscription_id: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states under subscription scope. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_subscription_request( + subscription_id=subscription_id, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_query_results_for_resource_group( + self, + subscription_id: str, + resource_group_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states under resource group scope. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_query_results_for_resource( + self, + resource_id: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword expand: The $expand query parameter. Default value is None. + :paramtype expand: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_resource_request( + resource_id=resource_id, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_query_results_for_policy_definition( # pylint: disable=too-many-locals + self, + subscription_id: str, + policy_definition_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_policy_definition_request( + subscription_id=subscription_id, + policy_definition_name=policy_definition_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_assignment_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_assignment_name=policy_assignment_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_assignment_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_assignment_name=policy_assignment_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyTrackedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s + :attr:`policy_tracked_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( + self, + management_group_name: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the management group. + + :param management_group_name: Management group name. Required. + :type management_group_name: str + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_management_group_request( + management_group_name=management_group_name, + policy_tracked_resources_resource=policy_tracked_resources_resource, + top=top, + filter=filter, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_subscription( + self, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the subscription. + + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :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", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_subscription_request( + policy_tracked_resources_resource=policy_tracked_resources_resource, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource_group( + self, + resource_group_name: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :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", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_resource_group_request( + resource_group_name=resource_group_name, + policy_tracked_resources_resource=policy_tracked_resources_resource, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource( + self, + resource_id: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :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", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_resource_request( + resource_id=resource_id, + policy_tracked_resources_resource=policy_tracked_resources_resource, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_patch.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_patch.py index 49900f6ab120..ea765788358a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_patch.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_patch.py @@ -1,15 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py deleted file mode 100644 index 1ece5a7efa7f..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py +++ /dev/null @@ -1,1154 +0,0 @@ -# pylint: disable=too-many-lines -# 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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._policy_events_operations import ( - build_list_query_results_for_management_group_request, - build_list_query_results_for_policy_definition_request, - build_list_query_results_for_policy_set_definition_request, - build_list_query_results_for_resource_group_level_policy_assignment_request, - build_list_query_results_for_resource_group_request, - build_list_query_results_for_resource_request, - build_list_query_results_for_subscription_level_policy_assignment_request, - build_list_query_results_for_subscription_request, - build_next_link_request, -) -from .._configuration import PolicyInsightsClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PolicyEventsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s - :attr:`policy_events` 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: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - management_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resources under the management group. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_management_group_request( - policy_events_resource=policy_events_resource, - management_group_name=management_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - management_groups_namespace=management_groups_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_subscription( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resources under the subscription. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource_group( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - resource_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resources under the resource group. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - resource_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resource. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_request( - policy_events_resource=policy_events_resource, - resource_id=resource_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - expand=_expand, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_set_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the subscription level policy set definition. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_set_definition_name: Policy set definition name. Required. - :type policy_set_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_set_definition_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - policy_set_definition_name=policy_set_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_policy_definition( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the subscription level policy definition. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_definition_name: Policy definition name. Required. - :type policy_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_definition_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - policy_definition_name=policy_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the subscription level policy assignment. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_level_policy_assignment_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resource group level policy assignment. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_level_policy_assignment_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py deleted file mode 100644 index 725ef5767b9f..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py +++ /dev/null @@ -1,184 +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. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._policy_metadata_operations import build_get_resource_request, build_list_request -from .._configuration import PolicyInsightsClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PolicyMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s - :attr:`policy_metadata` 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: PolicyInsightsClientConfiguration = 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_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetadata: - """Get policy metadata resource. - - :param resource_name: The name of the policy metadata resource. Required. - :type resource_name: str - :return: PolicyMetadata or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.PolicyMetadata - :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", "2019-10-01")) - cls: ClsType[_models.PolicyMetadata] = kwargs.pop("cls", None) - - _request = build_get_resource_request( - resource_name=resource_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyMetadata", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.SlimPolicyMetadata"]: - """Get a list of the policy metadata resources. - - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either SlimPolicyMetadata or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyMetadataCollection] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_request( - 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("PolicyMetadataCollection", 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.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py deleted file mode 100644 index 3032b961afc9..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py +++ /dev/null @@ -1,277 +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. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._policy_restrictions_operations import ( - build_check_at_resource_group_scope_request, - build_check_at_subscription_scope_request, -) -from .._configuration import PolicyInsightsClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PolicyRestrictionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s - :attr:`policy_restrictions` 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: PolicyInsightsClientConfiguration = 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 check_at_subscription_scope( - self, parameters: _models.CheckRestrictionsRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a subscription. - - :param parameters: The check policy restrictions parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_at_subscription_scope( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a subscription. - - :param parameters: The check policy restrictions parameters. 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: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_at_subscription_scope( - self, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a subscription. - - :param parameters: The check policy restrictions parameters. Is either a - CheckRestrictionsRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :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", "2020-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckRestrictionsResult] = 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, "CheckRestrictionsRequest") - - _request = build_check_at_subscription_scope_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.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def check_at_resource_group_scope( - self, - resource_group_name: str, - parameters: _models.CheckRestrictionsRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a resource group. Use - this when the resource group the resource will be created in is already known. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: The check policy restrictions parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_at_resource_group_scope( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a resource group. Use - this when the resource group the resource will be created in is already known. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: The check policy restrictions parameters. 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: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def check_at_resource_group_scope( - self, resource_group_name: str, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a resource group. Use - this when the resource group the resource will be created in is already known. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: The check policy restrictions parameters. Is either a - CheckRestrictionsRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :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", "2020-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckRestrictionsResult] = 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, "CheckRestrictionsRequest") - - _request = build_check_at_resource_group_scope_request( - resource_group_name=resource_group_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 = 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.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py deleted file mode 100644 index ddcb15bdb90a..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py +++ /dev/null @@ -1,2089 +0,0 @@ -# pylint: disable=too-many-lines -# 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 collections.abc import MutableMapping -from typing import Any, AsyncIterator, Callable, Literal, Optional, TypeVar, Union, cast - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._policy_states_operations import ( - build_list_query_results_for_management_group_request, - build_list_query_results_for_policy_definition_request, - build_list_query_results_for_policy_set_definition_request, - build_list_query_results_for_resource_group_level_policy_assignment_request, - build_list_query_results_for_resource_group_request, - build_list_query_results_for_resource_request, - build_list_query_results_for_subscription_level_policy_assignment_request, - build_list_query_results_for_subscription_request, - build_next_link_request, - build_summarize_for_management_group_request, - build_summarize_for_policy_definition_request, - build_summarize_for_policy_set_definition_request, - build_summarize_for_resource_group_level_policy_assignment_request, - build_summarize_for_resource_group_request, - build_summarize_for_resource_request, - build_summarize_for_subscription_level_policy_assignment_request, - build_summarize_for_subscription_request, - build_trigger_resource_group_evaluation_request, - build_trigger_subscription_evaluation_request, -) -from .._configuration import PolicyInsightsClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PolicyStatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s - :attr:`policy_states` 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: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - management_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the resources under the management group. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_management_group_request( - policy_states_resource=policy_states_resource, - management_group_name=management_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - management_groups_namespace=management_groups_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_management_group( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - management_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resources under the management group. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_management_group_request( - policy_states_summary_resource=policy_states_summary_resource, - management_group_name=management_group_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - management_groups_namespace=management_groups_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_subscription( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the resources under the subscription. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_subscription( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resources under the subscription. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_subscription_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_resource_group( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - resource_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the resources under the resource group. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_resource_group( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - resource_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resources under the resource group. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_resource_group_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_resource( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - resource_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the resource. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_request( - policy_states_resource=policy_states_resource, - resource_id=resource_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - expand=_expand, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_resource( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - resource_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resource. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_resource_request( - policy_states_summary_resource=policy_states_summary_resource, - resource_id=resource_id, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _trigger_subscription_evaluation_initial( - self, subscription_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - 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", "2019-10-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_trigger_subscription_evaluation_request( - subscription_id=subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Triggers a policy evaluation scan for all the resources under the subscription. - - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[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", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._trigger_subscription_evaluation_initial( - subscription_id=subscription_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _trigger_resource_group_evaluation_initial( # pylint: disable=name-too-long - self, subscription_id: str, resource_group_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - 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", "2019-10-01")) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_trigger_resource_group_evaluation_request( - subscription_id=subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_trigger_resource_group_evaluation( - self, subscription_id: str, resource_group_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Triggers a policy evaluation scan for all the resources under the resource group. - - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[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", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._trigger_resource_group_evaluation_initial( - subscription_id=subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_set_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the subscription level policy set definition. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_set_definition_name: Policy set definition name. Required. - :type policy_set_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_set_definition_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - policy_set_definition_name=policy_set_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_policy_set_definition( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_set_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the subscription level policy set definition. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_set_definition_name: Policy set definition name. Required. - :type policy_set_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_policy_set_definition_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - policy_set_definition_name=policy_set_definition_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_policy_definition( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the subscription level policy definition. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_definition_name: Policy definition name. Required. - :type policy_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_definition_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - policy_definition_name=policy_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_policy_definition( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the subscription level policy definition. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_definition_name: Policy definition name. Required. - :type policy_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_policy_definition_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - policy_definition_name=policy_definition_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the subscription level policy assignment. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_level_policy_assignment_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_subscription_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the subscription level policy assignment. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_subscription_level_policy_assignment_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - policy_assignment_name=policy_assignment_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyState"]: - """Queries policy states for the resource group level policy assignment. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_level_policy_assignment_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - 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 summarize_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resource group level policy assignment. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_resource_group_level_policy_assignment_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - policy_assignment_name=policy_assignment_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py deleted file mode 100644 index 5066352e64f0..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py +++ /dev/null @@ -1,425 +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. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._policy_tracked_resources_operations import ( - build_list_query_results_for_management_group_request, - build_list_query_results_for_resource_group_request, - build_list_query_results_for_resource_request, - build_list_query_results_for_subscription_request, -) -from .._configuration import PolicyInsightsClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class PolicyTrackedResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s - :attr:`policy_tracked_resources` 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: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( - self, - management_group_name: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the management group. - - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_management_group_request( - management_group_name=management_group_name, - policy_tracked_resources_resource=policy_tracked_resources_resource, - top=_top, - filter=_filter, - management_groups_namespace=management_groups_namespace, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_subscription( - self, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the subscription. - - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :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", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_subscription_request( - policy_tracked_resources_resource=policy_tracked_resources_resource, - subscription_id=self._config.subscription_id, - top=_top, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource_group( - self, - resource_group_name: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the resource group. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :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", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_resource_group_request( - resource_group_name=resource_group_name, - policy_tracked_resources_resource=policy_tracked_resources_resource, - subscription_id=self._config.subscription_id, - top=_top, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource( - self, - resource_id: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the resource. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :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", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_resource_request( - resource_id=resource_id, - policy_tracked_resources_resource=policy_tracked_resources_resource, - top=_top, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py deleted file mode 100644 index 6ab8ceb09184..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py +++ /dev/null @@ -1,1967 +0,0 @@ -# pylint: disable=too-many-lines -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import AsyncPipelineClient -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._utils.serialization import Deserializer, Serializer -from ...operations._remediations_operations import ( - build_cancel_at_management_group_request, - build_cancel_at_resource_group_request, - build_cancel_at_resource_request, - build_cancel_at_subscription_request, - build_create_or_update_at_management_group_request, - build_create_or_update_at_resource_group_request, - build_create_or_update_at_resource_request, - build_create_or_update_at_subscription_request, - build_delete_at_management_group_request, - build_delete_at_resource_group_request, - build_delete_at_resource_request, - build_delete_at_subscription_request, - build_get_at_management_group_request, - build_get_at_resource_group_request, - build_get_at_resource_request, - build_get_at_subscription_request, - build_list_deployments_at_management_group_request, - build_list_deployments_at_resource_group_request, - build_list_deployments_at_resource_request, - build_list_deployments_at_subscription_request, - build_list_for_management_group_request, - build_list_for_resource_group_request, - build_list_for_resource_request, - build_list_for_subscription_request, -) -from .._configuration import PolicyInsightsClientConfiguration - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] -List = list - - -class RemediationsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.aio.PolicyInsightsClient`'s - :attr:`remediations` 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: PolicyInsightsClientConfiguration = 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_deployments_at_management_group( - self, - management_group_id: str, - remediation_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - top=_top, - management_groups_namespace=management_groups_namespace, - 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("RemediationDeploymentsListResult", 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 cancel_at_management_group( - self, management_group_id: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Cancels a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_management_group( - self, management_group_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Remediation"]: - """Gets all remediations for the management group. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_management_group_request( - management_group_id=management_group_id, - top=_top, - filter=_filter, - management_groups_namespace=management_groups_namespace, - 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("RemediationListResult", 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) - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_management_group( - self, - management_group_id: str, - remediation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_at_management_group( - self, - management_group_id: str, - remediation_name: str, - parameters: Union[_models.Remediation, IO[bytes]], - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_at_management_group( - self, management_group_id: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Gets an existing remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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("Remediation", 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, remediation_name: str, **kwargs: Any - ) -> Optional[_models.Remediation]: - """Deletes an existing remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_deployments_at_subscription( - self, remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_subscription_request( - remediation_name=remediation_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RemediationDeploymentsListResult", 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 cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Cancels a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_subscription_request( - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_subscription( - self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Remediation"]: - """Gets all remediations for the subscription. - - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_subscription_request( - subscription_id=self._config.subscription_id, - top=_top, - 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("RemediationListResult", 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) - - @overload - async def create_or_update_at_subscription( - self, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_subscription( - self, remediation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_at_subscription( - self, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_subscription_request( - remediation_name=remediation_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 = 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, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Gets an existing remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_subscription_request( - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Optional[_models.Remediation]: - """Deletes an existing remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_subscription_request( - remediation_name=remediation_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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_deployments_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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 - - async def extract_data(pipeline_response): - deserialized = self._deserialize("RemediationDeploymentsListResult", 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 cancel_at_resource_group( - self, resource_group_name: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Cancels a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", 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, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Remediation"]: - """Gets all remediations for the subscription. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - top=_top, - 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("RemediationListResult", 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) - - @overload - async def create_or_update_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - parameters: Union[_models.Remediation, IO[bytes]], - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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 = 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, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_at_resource_group( - self, resource_group_name: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Gets an existing remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_at_resource_group( - self, resource_group_name: str, remediation_name: str, **kwargs: Any - ) -> Optional[_models.Remediation]: - """Deletes an existing remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_deployments_at_resource( - self, - resource_id: str, - remediation_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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("RemediationDeploymentsListResult", 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 cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Cancel a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_resource( - self, resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Remediation"]: - """Gets all remediations for a resource. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_resource_request( - resource_id=resource_id, - top=_top, - 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("RemediationListResult", 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) - - @overload - async def create_or_update_at_resource( - self, - resource_id: str, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update_at_resource( - self, - resource_id: str, - remediation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update_at_resource( - self, resource_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Gets an existing remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def delete_at_resource( - self, resource_id: str, remediation_name: str, **kwargs: Any - ) -> Optional[_models.Remediation]: - """Deletes an existing remediation at individual resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py index 9efd1863cdca..018198456914 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -13,18 +13,25 @@ from ._patch import * # pylint: disable=unused-wildcard-import -from ._models_py3 import ( # type: ignore +from ._models import ( # type: ignore + Attestation, + AttestationEvidence, + AttestationProperties, + CheckManagementGroupRestrictionsRequest, + CheckRestrictionEvaluationDetails, CheckRestrictionsRequest, CheckRestrictionsResourceDetails, CheckRestrictionsResult, CheckRestrictionsResultContentEvaluationResult, ComplianceDetail, ComponentEventDetails, + ComponentExpressionEvaluationDetails, + ComponentPolicyEvaluationDetails, + ComponentPolicyState, + ComponentPolicyStatesQueryResults, ComponentStateDetails, ErrorDefinition, - ErrorDefinitionAutoGenerated, ErrorResponse, - ErrorResponseAutoGenerated, ExpressionEvaluationDetails, FieldRestriction, FieldRestrictions, @@ -36,38 +43,40 @@ PolicyAssignmentSummary, PolicyDefinitionSummary, PolicyDetails, + PolicyEffectDetails, PolicyEvaluationDetails, PolicyEvaluationResult, PolicyEvent, - PolicyEventsQueryResults, PolicyGroupSummary, PolicyMetadata, - PolicyMetadataCollection, PolicyMetadataProperties, PolicyMetadataSlimProperties, PolicyReference, PolicyState, - PolicyStatesQueryResults, PolicyTrackedResource, - PolicyTrackedResourcesQueryResults, + ProxyResource, QueryFailure, QueryFailureError, - QueryOptions, Remediation, RemediationDeployment, RemediationDeploymentSummary, - RemediationDeploymentsListResult, RemediationFilters, - RemediationListResult, + RemediationProperties, + RemediationPropertiesFailureThreshold, + Resource, SlimPolicyMetadata, SummarizeResults, Summary, SummaryResults, + SystemData, TrackedResourceModificationDetails, TypedErrorInfo, ) -from ._policy_insights_client_enums import ( # type: ignore +from ._enums import ( # type: ignore + ComplianceState, + ComponentPolicyStatesResource, + CreatedByType, FieldRestrictionResult, PolicyEventsResourceType, PolicyStatesResource, @@ -80,17 +89,24 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "Attestation", + "AttestationEvidence", + "AttestationProperties", + "CheckManagementGroupRestrictionsRequest", + "CheckRestrictionEvaluationDetails", "CheckRestrictionsRequest", "CheckRestrictionsResourceDetails", "CheckRestrictionsResult", "CheckRestrictionsResultContentEvaluationResult", "ComplianceDetail", "ComponentEventDetails", + "ComponentExpressionEvaluationDetails", + "ComponentPolicyEvaluationDetails", + "ComponentPolicyState", + "ComponentPolicyStatesQueryResults", "ComponentStateDetails", "ErrorDefinition", - "ErrorDefinitionAutoGenerated", "ErrorResponse", - "ErrorResponseAutoGenerated", "ExpressionEvaluationDetails", "FieldRestriction", "FieldRestrictions", @@ -102,35 +118,37 @@ "PolicyAssignmentSummary", "PolicyDefinitionSummary", "PolicyDetails", + "PolicyEffectDetails", "PolicyEvaluationDetails", "PolicyEvaluationResult", "PolicyEvent", - "PolicyEventsQueryResults", "PolicyGroupSummary", "PolicyMetadata", - "PolicyMetadataCollection", "PolicyMetadataProperties", "PolicyMetadataSlimProperties", "PolicyReference", "PolicyState", - "PolicyStatesQueryResults", "PolicyTrackedResource", - "PolicyTrackedResourcesQueryResults", + "ProxyResource", "QueryFailure", "QueryFailureError", - "QueryOptions", "Remediation", "RemediationDeployment", "RemediationDeploymentSummary", - "RemediationDeploymentsListResult", "RemediationFilters", - "RemediationListResult", + "RemediationProperties", + "RemediationPropertiesFailureThreshold", + "Resource", "SlimPolicyMetadata", "SummarizeResults", "Summary", "SummaryResults", + "SystemData", "TrackedResourceModificationDetails", "TypedErrorInfo", + "ComplianceState", + "ComponentPolicyStatesResource", + "CreatedByType", "FieldRestrictionResult", "PolicyEventsResourceType", "PolicyStatesResource", diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_enums.py similarity index 54% rename from sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py rename to sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_enums.py index 70689deeabd7..c7477d0d0258 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_enums.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -10,6 +10,37 @@ from azure.core import CaseInsensitiveEnumMeta +class ComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The compliance state that should be set on the resource.""" + + COMPLIANT = "Compliant" + """The resource is in compliance with the policy.""" + NON_COMPLIANT = "NonCompliant" + """The resource is not in compliance with the policy.""" + UNKNOWN = "Unknown" + """The compliance state of the resource is not known.""" + + +class ComponentPolicyStatesResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ComponentPolicyStatesResource.""" + + LATEST = "latest" + """latest.""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of entity that created the resource.""" + + USER = "User" + """The entity was created by a user.""" + APPLICATION = "Application" + """The entity was created by an application.""" + MANAGED_IDENTITY = "ManagedIdentity" + """The entity was created by a managed identity.""" + KEY = "Key" + """The entity was created by a key.""" + + class FieldRestrictionResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restriction that is imposed on the field.""" @@ -19,31 +50,38 @@ class FieldRestrictionResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The field will be removed by policy.""" DENY = "Deny" """The field and/or values will be denied by policy.""" + AUDIT = "Audit" + """The field and/or values will be audited by policy.""" class PolicyEventsResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyEventsResourceType.""" + """Type of PolicyEventsResourceType.""" DEFAULT = "default" + """default.""" class PolicyStatesResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyStatesResource.""" + """Type of PolicyStatesResource.""" DEFAULT = "default" + """default.""" LATEST = "latest" + """latest.""" class PolicyStatesSummaryResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyStatesSummaryResourceType.""" + """Type of PolicyStatesSummaryResourceType.""" LATEST = "latest" + """latest.""" class PolicyTrackedResourcesResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """PolicyTrackedResourcesResourceType.""" + """Type of PolicyTrackedResourcesResourceType.""" DEFAULT = "default" + """default.""" class ResourceDiscoveryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -55,4 +93,4 @@ class ResourceDiscoveryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Remediate resources that are already known to be non-compliant.""" RE_EVALUATE_COMPLIANCE = "ReEvaluateCompliance" """Re-evaluate the compliance state of resources and then remediate the resources found to be - non-compliant.""" + non-compliant. The resourceIds filter cannot be used in this mode.""" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py new file mode 100644 index 000000000000..c31b11882708 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py @@ -0,0 +1,2998 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=useless-super-delegation + +import datetime +from typing import Any, Mapping, Optional, TYPE_CHECKING, Union, overload + +from .._utils.model_base import Model as _Model, rest_field + +if TYPE_CHECKING: + from .. import models as _models + + +class Resource(_Model): + """Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + """ + + id: Optional[str] = rest_field(visibility=["read"]) + """Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the resource.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or + \"Microsoft.Storage/storageAccounts\".""" + system_data: Optional["_models.SystemData"] = rest_field(name="systemData", visibility=["read"]) + """Azure Resource Manager metadata containing createdBy and modifiedBy information.""" + + +class ProxyResource(Resource): + """Proxy Resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + """ + + +class Attestation(ProxyResource): + """An attestation resource. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + :ivar properties: Properties for the attestation. Required. + :vartype properties: ~azure.mgmt.policyinsights.models.AttestationProperties + """ + + properties: "_models.AttestationProperties" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Properties for the attestation. Required.""" + + __flattened_items = [ + "policy_assignment_id", + "policy_definition_reference_id", + "compliance_state", + "expires_on", + "owner", + "comments", + "evidence", + "provisioning_state", + "last_compliance_state_change_at", + "assessment_date", + "metadata", + ] + + @overload + def __init__( + self, + *, + properties: "_models.AttestationProperties", + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class AttestationEvidence(_Model): + """A piece of evidence supporting the compliance state set in the attestation. + + :ivar description: The description for this piece of evidence. + :vartype description: str + :ivar source_uri: The URI location of the evidence. + :vartype source_uri: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The description for this piece of evidence.""" + source_uri: Optional[str] = rest_field(name="sourceUri", visibility=["read", "create", "update", "delete", "query"]) + """The URI location of the evidence.""" + + @overload + def __init__( + self, + *, + description: Optional[str] = None, + source_uri: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AttestationProperties(_Model): + """The properties of an attestation resource. + + :ivar policy_assignment_id: The resource ID of the policy assignment that the attestation is + setting the state for. Required. + :vartype policy_assignment_id: str + :ivar policy_definition_reference_id: The policy definition reference ID from a policy set + definition that the attestation is setting the state for. If the policy assignment assigns a + policy set definition the attestation can choose a definition within the set definition with + this property or omit this and set the state for the entire set definition. + :vartype policy_definition_reference_id: str + :ivar compliance_state: The compliance state that should be set on the resource. Known values + are: "Compliant", "NonCompliant", and "Unknown". + :vartype compliance_state: str or ~azure.mgmt.policyinsights.models.ComplianceState + :ivar expires_on: The time the compliance state should expire. + :vartype expires_on: ~datetime.datetime + :ivar owner: The person responsible for setting the state of the resource. This value is + typically an Azure Active Directory object ID. + :vartype owner: str + :ivar comments: Comments describing why this attestation was created. + :vartype comments: str + :ivar evidence: The evidence supporting the compliance state set in this attestation. + :vartype evidence: list[~azure.mgmt.policyinsights.models.AttestationEvidence] + :ivar provisioning_state: The status of the attestation. + :vartype provisioning_state: str + :ivar last_compliance_state_change_at: The time the compliance state was last changed in this + attestation. + :vartype last_compliance_state_change_at: ~datetime.datetime + :ivar assessment_date: The time the evidence was assessed. + :vartype assessment_date: ~datetime.datetime + :ivar metadata: Additional metadata for this attestation. + :vartype metadata: any + """ + + policy_assignment_id: str = rest_field( + name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ID of the policy assignment that the attestation is setting the state for. + Required.""" + policy_definition_reference_id: Optional[str] = rest_field( + name="policyDefinitionReferenceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The policy definition reference ID from a policy set definition that the attestation is setting + the state for. If the policy assignment assigns a policy set definition the attestation can + choose a definition within the set definition with this property or omit this and set the state + for the entire set definition.""" + compliance_state: Optional[Union[str, "_models.ComplianceState"]] = rest_field( + name="complianceState", visibility=["read", "create", "update", "delete", "query"] + ) + """The compliance state that should be set on the resource. Known values are: \"Compliant\", + \"NonCompliant\", and \"Unknown\".""" + expires_on: Optional[datetime.datetime] = rest_field( + name="expiresOn", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The time the compliance state should expire.""" + owner: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The person responsible for setting the state of the resource. This value is typically an Azure + Active Directory object ID.""" + comments: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Comments describing why this attestation was created.""" + evidence: Optional[list["_models.AttestationEvidence"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The evidence supporting the compliance state set in this attestation.""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The status of the attestation.""" + last_compliance_state_change_at: Optional[datetime.datetime] = rest_field( + name="lastComplianceStateChangeAt", visibility=["read"], format="rfc3339" + ) + """The time the compliance state was last changed in this attestation.""" + assessment_date: Optional[datetime.datetime] = rest_field( + name="assessmentDate", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The time the evidence was assessed.""" + metadata: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Additional metadata for this attestation.""" + + @overload + def __init__( + self, + *, + policy_assignment_id: str, + policy_definition_reference_id: Optional[str] = None, + compliance_state: Optional[Union[str, "_models.ComplianceState"]] = None, + expires_on: Optional[datetime.datetime] = None, + owner: Optional[str] = None, + comments: Optional[str] = None, + evidence: Optional[list["_models.AttestationEvidence"]] = None, + assessment_date: Optional[datetime.datetime] = None, + metadata: Optional[Any] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckManagementGroupRestrictionsRequest(_Model): + """The check policy restrictions parameters describing the resource that is being evaluated. + + :ivar resource_details: The information about the resource that will be evaluated. + :vartype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails + :ivar pending_fields: The list of fields and values that should be evaluated for potential + restrictions. + :vartype pending_fields: list[~azure.mgmt.policyinsights.models.PendingField] + """ + + resource_details: Optional["_models.CheckRestrictionsResourceDetails"] = rest_field( + name="resourceDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """The information about the resource that will be evaluated.""" + pending_fields: Optional[list["_models.PendingField"]] = rest_field( + name="pendingFields", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of fields and values that should be evaluated for potential restrictions.""" + + @overload + def __init__( + self, + *, + resource_details: Optional["_models.CheckRestrictionsResourceDetails"] = None, + pending_fields: Optional[list["_models.PendingField"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckRestrictionEvaluationDetails(_Model): + """Policy evaluation details. + + :ivar evaluated_expressions: Details of the evaluated expressions. + :vartype evaluated_expressions: + list[~azure.mgmt.policyinsights.models.ExpressionEvaluationDetails] + :ivar if_not_exists_details: Evaluation details of IfNotExists effect. + :vartype if_not_exists_details: ~azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails + :ivar reason: The reason for the evaluation result. + :vartype reason: str + """ + + evaluated_expressions: Optional[list["_models.ExpressionEvaluationDetails"]] = rest_field( + name="evaluatedExpressions", visibility=["read", "create", "update", "delete", "query"] + ) + """Details of the evaluated expressions.""" + if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = rest_field( + name="ifNotExistsDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Evaluation details of IfNotExists effect.""" + reason: Optional[str] = rest_field(visibility=["read"]) + """The reason for the evaluation result.""" + + @overload + def __init__( + self, + *, + evaluated_expressions: Optional[list["_models.ExpressionEvaluationDetails"]] = None, + if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckRestrictionsRequest(_Model): + """The check policy restrictions parameters describing the resource that is being evaluated. + + :ivar resource_details: The information about the resource that will be evaluated. Required. + :vartype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails + :ivar pending_fields: The list of fields and values that should be evaluated for potential + restrictions. + :vartype pending_fields: list[~azure.mgmt.policyinsights.models.PendingField] + :ivar include_audit_effect: Whether to include policies with the 'audit' effect in the results. + Defaults to false. + :vartype include_audit_effect: bool + """ + + resource_details: "_models.CheckRestrictionsResourceDetails" = rest_field( + name="resourceDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """The information about the resource that will be evaluated. Required.""" + pending_fields: Optional[list["_models.PendingField"]] = rest_field( + name="pendingFields", visibility=["read", "create", "update", "delete", "query"] + ) + """The list of fields and values that should be evaluated for potential restrictions.""" + include_audit_effect: Optional[bool] = rest_field( + name="includeAuditEffect", visibility=["read", "create", "update", "delete", "query"] + ) + """Whether to include policies with the 'audit' effect in the results. Defaults to false.""" + + @overload + def __init__( + self, + *, + resource_details: "_models.CheckRestrictionsResourceDetails", + pending_fields: Optional[list["_models.PendingField"]] = None, + include_audit_effect: Optional[bool] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckRestrictionsResourceDetails(_Model): + """The information about the resource that will be evaluated. + + :ivar resource_content: The resource content. This should include whatever properties are + already known and can be a partial set of all resource properties. Required. + :vartype resource_content: any + :ivar api_version: The api-version of the resource content. + :vartype api_version: str + :ivar scope: The scope where the resource is being created. For example, if the resource is a + child resource this would be the parent resource's resource ID. + :vartype scope: str + """ + + resource_content: Any = rest_field( + name="resourceContent", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource content. This should include whatever properties are already known and can be a + partial set of all resource properties. Required.""" + api_version: Optional[str] = rest_field( + name="apiVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The api-version of the resource content.""" + scope: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The scope where the resource is being created. For example, if the resource is a child resource + this would be the parent resource's resource ID.""" + + @overload + def __init__( + self, + *, + resource_content: Any, + api_version: Optional[str] = None, + scope: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class CheckRestrictionsResult(_Model): + """The result of a check policy restrictions evaluation on a resource. + + :ivar field_restrictions: The restrictions that will be placed on various fields in the + resource by policy. + :vartype field_restrictions: list[~azure.mgmt.policyinsights.models.FieldRestrictions] + :ivar content_evaluation_result: Evaluation results for the provided partial resource content. + :vartype content_evaluation_result: + ~azure.mgmt.policyinsights.models.CheckRestrictionsResultContentEvaluationResult + """ + + field_restrictions: Optional[list["_models.FieldRestrictions"]] = rest_field( + name="fieldRestrictions", visibility=["read"] + ) + """The restrictions that will be placed on various fields in the resource by policy.""" + content_evaluation_result: Optional["_models.CheckRestrictionsResultContentEvaluationResult"] = rest_field( + name="contentEvaluationResult", visibility=["read"] + ) + """Evaluation results for the provided partial resource content.""" + + +class CheckRestrictionsResultContentEvaluationResult(_Model): # pylint: disable=name-too-long + """Evaluation results for the provided partial resource content. + + :ivar policy_evaluations: Policy evaluation results against the given resource content. This + will indicate if the partial content that was provided will be denied as-is. + :vartype policy_evaluations: list[~azure.mgmt.policyinsights.models.PolicyEvaluationResult] + """ + + policy_evaluations: Optional[list["_models.PolicyEvaluationResult"]] = rest_field( + name="policyEvaluations", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy evaluation results against the given resource content. This will indicate if the partial + content that was provided will be denied as-is.""" + + @overload + def __init__( + self, + *, + policy_evaluations: Optional[list["_models.PolicyEvaluationResult"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComplianceDetail(_Model): + """The compliance state rollup. + + :ivar compliance_state: The compliance state. + :vartype compliance_state: str + :ivar count: Summarized count value for this compliance state. + :vartype count: int + """ + + compliance_state: Optional[str] = rest_field( + name="complianceState", visibility=["read", "create", "update", "delete", "query"] + ) + """The compliance state.""" + count: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Summarized count value for this compliance state.""" + + @overload + def __init__( + self, + *, + compliance_state: Optional[str] = None, + count: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentEventDetails(_Model): + """Component event details. + + :ivar id: Component Id. + :vartype id: str + :ivar type: Component type. + :vartype type: str + :ivar name: Component name. + :vartype name: str + :ivar timestamp: Timestamp for component policy event record. + :vartype timestamp: ~datetime.datetime + :ivar tenant_id: Tenant ID for the policy event record. + :vartype tenant_id: str + :ivar principal_oid: Principal object ID for the user who initiated the resource component + operation that triggered the policy event. + :vartype principal_oid: str + :ivar policy_definition_action: Policy definition action, i.e. effect. + :vartype policy_definition_action: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Component Id.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Component type.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Component name.""" + timestamp: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Timestamp for component policy event record.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Tenant ID for the policy event record.""" + principal_oid: Optional[str] = rest_field( + name="principalOid", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal object ID for the user who initiated the resource component operation that triggered + the policy event.""" + policy_definition_action: Optional[str] = rest_field( + name="policyDefinitionAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition action, i.e. effect.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + name: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + tenant_id: Optional[str] = None, + principal_oid: Optional[str] = None, + policy_definition_action: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentExpressionEvaluationDetails(_Model): + """Evaluation details of policy language expressions. + + :ivar result: Evaluation result. + :vartype result: str + :ivar expression: Expression evaluated. + :vartype expression: str + :ivar expression_kind: The kind of expression that was evaluated. + :vartype expression_kind: str + :ivar path: Property path if the expression is a field or an alias. + :vartype path: str + :ivar expression_value: Value of the expression. + :vartype expression_value: any + :ivar target_value: Target value to be compared with the expression value. + :vartype target_value: any + :ivar operator: Operator to compare the expression value and the target value. + :vartype operator: str + """ + + result: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Evaluation result.""" + expression: Optional[str] = rest_field(visibility=["read"]) + """Expression evaluated.""" + expression_kind: Optional[str] = rest_field(name="expressionKind", visibility=["read"]) + """The kind of expression that was evaluated.""" + path: Optional[str] = rest_field(visibility=["read"]) + """Property path if the expression is a field or an alias.""" + expression_value: Optional[Any] = rest_field(name="expressionValue", visibility=["read"]) + """Value of the expression.""" + target_value: Optional[Any] = rest_field(name="targetValue", visibility=["read"]) + """Target value to be compared with the expression value.""" + operator: Optional[str] = rest_field(visibility=["read"]) + """Operator to compare the expression value and the target value.""" + + @overload + def __init__( + self, + *, + result: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentPolicyEvaluationDetails(_Model): + """Policy evaluation details. + + :ivar evaluated_expressions: Details of the evaluated expressions. + :vartype evaluated_expressions: + list[~azure.mgmt.policyinsights.models.ComponentExpressionEvaluationDetails] + :ivar reason: Additional textual reason for the evaluation outcome. + :vartype reason: str + """ + + evaluated_expressions: Optional[list["_models.ComponentExpressionEvaluationDetails"]] = rest_field( + name="evaluatedExpressions", visibility=["read"] + ) + """Details of the evaluated expressions.""" + reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Additional textual reason for the evaluation outcome.""" + + @overload + def __init__( + self, + *, + reason: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentPolicyState(_Model): + """Component Policy State record. + + :ivar odata_id: OData entity ID; always set to null since component policy state records do not + have an entity ID. + :vartype odata_id: str + :ivar odata_context: OData context string; used by OData clients to resolve type information + based on metadata. + :vartype odata_context: str + :ivar timestamp: Timestamp for the component policy state record. + :vartype timestamp: ~datetime.datetime + :ivar component_id: Component Id. + :vartype component_id: str + :ivar component_type: Component type. + :vartype component_type: str + :ivar component_name: Component name. + :vartype component_name: str + :ivar resource_id: Resource ID. + :vartype resource_id: str + :ivar policy_assignment_id: Policy assignment ID. + :vartype policy_assignment_id: str + :ivar policy_definition_id: Policy definition ID. + :vartype policy_definition_id: str + :ivar subscription_id: Subscription ID. + :vartype subscription_id: str + :ivar resource_type: Resource type. + :vartype resource_type: str + :ivar resource_location: Resource location. + :vartype resource_location: str + :ivar resource_group: Resource group name. + :vartype resource_group: str + :ivar policy_assignment_name: Policy assignment name. + :vartype policy_assignment_name: str + :ivar policy_assignment_owner: Policy assignment owner. + :vartype policy_assignment_owner: str + :ivar policy_assignment_parameters: Policy assignment parameters. + :vartype policy_assignment_parameters: str + :ivar policy_assignment_scope: Policy assignment scope. + :vartype policy_assignment_scope: str + :ivar policy_definition_name: Policy definition name. + :vartype policy_definition_name: str + :ivar policy_definition_action: Policy definition action, i.e. effect. + :vartype policy_definition_action: str + :ivar policy_definition_category: Policy definition category. + :vartype policy_definition_category: str + :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a + policy set. + :vartype policy_set_definition_id: str + :ivar policy_set_definition_name: Policy set definition name, if the policy assignment is for a + policy set. + :vartype policy_set_definition_name: str + :ivar policy_set_definition_owner: Policy set definition owner, if the policy assignment is for + a policy set. + :vartype policy_set_definition_owner: str + :ivar policy_set_definition_category: Policy set definition category, if the policy assignment + is for a policy set. + :vartype policy_set_definition_category: str + :ivar policy_set_definition_parameters: Policy set definition parameters, if the policy + assignment is for a policy set. + :vartype policy_set_definition_parameters: str + :ivar policy_definition_reference_id: Reference ID for the policy definition inside the policy + set, if the policy assignment is for a policy set. + :vartype policy_definition_reference_id: str + :ivar compliance_state: Compliance state of the resource. + :vartype compliance_state: str + :ivar policy_evaluation_details: Policy evaluation details. This is only included in the + response if the request contains $expand=PolicyEvaluationDetails. + :vartype policy_evaluation_details: + ~azure.mgmt.policyinsights.models.ComponentPolicyEvaluationDetails + :ivar policy_definition_group_names: Policy definition group names. + :vartype policy_definition_group_names: list[str] + :ivar policy_definition_version: Evaluated policy definition version. + :vartype policy_definition_version: str + :ivar policy_set_definition_version: Evaluated policy set definition version. + :vartype policy_set_definition_version: str + :ivar policy_assignment_version: Evaluated policy assignment version. + :vartype policy_assignment_version: str + """ + + odata_id: Optional[str] = rest_field(name="@odata.id", visibility=["read"]) + """OData entity ID; always set to null since component policy state records do not have an entity + ID.""" + odata_context: Optional[str] = rest_field(name="@odata.context", visibility=["read"]) + """OData context string; used by OData clients to resolve type information based on metadata.""" + timestamp: Optional[datetime.datetime] = rest_field(visibility=["read"], format="rfc3339") + """Timestamp for the component policy state record.""" + component_id: Optional[str] = rest_field(name="componentId", visibility=["read"]) + """Component Id.""" + component_type: Optional[str] = rest_field(name="componentType", visibility=["read"]) + """Component type.""" + component_name: Optional[str] = rest_field(name="componentName", visibility=["read"]) + """Component name.""" + resource_id: Optional[str] = rest_field(name="resourceId", visibility=["read"]) + """Resource ID.""" + policy_assignment_id: Optional[str] = rest_field(name="policyAssignmentId", visibility=["read"]) + """Policy assignment ID.""" + policy_definition_id: Optional[str] = rest_field(name="policyDefinitionId", visibility=["read"]) + """Policy definition ID.""" + subscription_id: Optional[str] = rest_field(name="subscriptionId", visibility=["read"]) + """Subscription ID.""" + resource_type: Optional[str] = rest_field(name="resourceType", visibility=["read"]) + """Resource type.""" + resource_location: Optional[str] = rest_field(name="resourceLocation", visibility=["read"]) + """Resource location.""" + resource_group: Optional[str] = rest_field(name="resourceGroup", visibility=["read"]) + """Resource group name.""" + policy_assignment_name: Optional[str] = rest_field(name="policyAssignmentName", visibility=["read"]) + """Policy assignment name.""" + policy_assignment_owner: Optional[str] = rest_field(name="policyAssignmentOwner", visibility=["read"]) + """Policy assignment owner.""" + policy_assignment_parameters: Optional[str] = rest_field(name="policyAssignmentParameters", visibility=["read"]) + """Policy assignment parameters.""" + policy_assignment_scope: Optional[str] = rest_field(name="policyAssignmentScope", visibility=["read"]) + """Policy assignment scope.""" + policy_definition_name: Optional[str] = rest_field(name="policyDefinitionName", visibility=["read"]) + """Policy definition name.""" + policy_definition_action: Optional[str] = rest_field(name="policyDefinitionAction", visibility=["read"]) + """Policy definition action, i.e. effect.""" + policy_definition_category: Optional[str] = rest_field(name="policyDefinitionCategory", visibility=["read"]) + """Policy definition category.""" + policy_set_definition_id: Optional[str] = rest_field(name="policySetDefinitionId", visibility=["read"]) + """Policy set definition ID, if the policy assignment is for a policy set.""" + policy_set_definition_name: Optional[str] = rest_field(name="policySetDefinitionName", visibility=["read"]) + """Policy set definition name, if the policy assignment is for a policy set.""" + policy_set_definition_owner: Optional[str] = rest_field(name="policySetDefinitionOwner", visibility=["read"]) + """Policy set definition owner, if the policy assignment is for a policy set.""" + policy_set_definition_category: Optional[str] = rest_field(name="policySetDefinitionCategory", visibility=["read"]) + """Policy set definition category, if the policy assignment is for a policy set.""" + policy_set_definition_parameters: Optional[str] = rest_field( + name="policySetDefinitionParameters", visibility=["read"] + ) + """Policy set definition parameters, if the policy assignment is for a policy set.""" + policy_definition_reference_id: Optional[str] = rest_field(name="policyDefinitionReferenceId", visibility=["read"]) + """Reference ID for the policy definition inside the policy set, if the policy assignment is for a + policy set.""" + compliance_state: Optional[str] = rest_field(name="complianceState", visibility=["read"]) + """Compliance state of the resource.""" + policy_evaluation_details: Optional["_models.ComponentPolicyEvaluationDetails"] = rest_field( + name="policyEvaluationDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy evaluation details. This is only included in the response if the request contains + $expand=PolicyEvaluationDetails.""" + policy_definition_group_names: Optional[list[str]] = rest_field( + name="policyDefinitionGroupNames", visibility=["read"] + ) + """Policy definition group names.""" + policy_definition_version: Optional[str] = rest_field(name="policyDefinitionVersion", visibility=["read"]) + """Evaluated policy definition version.""" + policy_set_definition_version: Optional[str] = rest_field(name="policySetDefinitionVersion", visibility=["read"]) + """Evaluated policy set definition version.""" + policy_assignment_version: Optional[str] = rest_field(name="policyAssignmentVersion", visibility=["read"]) + """Evaluated policy assignment version.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + policy_evaluation_details: Optional["_models.ComponentPolicyEvaluationDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentPolicyStatesQueryResults(_Model): + """Query results. + + :ivar odata_context: OData context string; used by OData clients to resolve type information + based on metadata. + :vartype odata_context: str + :ivar odata_count: OData entity count; represents the number of policy state records returned. + :vartype odata_count: int + :ivar value: Query results. + :vartype value: list[~azure.mgmt.policyinsights.models.ComponentPolicyState] + """ + + odata_context: Optional[str] = rest_field( + name="@odata.context", visibility=["read", "create", "update", "delete", "query"] + ) + """OData context string; used by OData clients to resolve type information based on metadata.""" + odata_count: Optional[int] = rest_field( + name="@odata.count", visibility=["read", "create", "update", "delete", "query"] + ) + """OData entity count; represents the number of policy state records returned.""" + value: Optional[list["_models.ComponentPolicyState"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Query results.""" + + @overload + def __init__( + self, + *, + odata_context: Optional[str] = None, + odata_count: Optional[int] = None, + value: Optional[list["_models.ComponentPolicyState"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ComponentStateDetails(_Model): + """Component state details. + + :ivar id: Component Id. + :vartype id: str + :ivar type: Component type. + :vartype type: str + :ivar name: Component name. + :vartype name: str + :ivar timestamp: Component compliance evaluation timestamp. + :vartype timestamp: ~datetime.datetime + :ivar compliance_state: Component compliance state. + :vartype compliance_state: str + """ + + id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Component Id.""" + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Component type.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Component name.""" + timestamp: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Component compliance evaluation timestamp.""" + compliance_state: Optional[str] = rest_field( + name="complianceState", visibility=["read", "create", "update", "delete", "query"] + ) + """Component compliance state.""" + + @overload + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + type: Optional[str] = None, + name: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + compliance_state: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ErrorDefinition(_Model): + """Error definition. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.policyinsights.models.ErrorDefinition] + :ivar additional_info: Additional scenario specific error details. + :vartype additional_info: list[~azure.mgmt.policyinsights.models.TypedErrorInfo] + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """Service specific error code which serves as the substatus for the HTTP error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """Description of the error.""" + target: Optional[str] = rest_field(visibility=["read"]) + """The target of the error.""" + details: Optional[list["_models.ErrorDefinition"]] = rest_field(visibility=["read"]) + """Internal error details.""" + additional_info: Optional[list["_models.TypedErrorInfo"]] = rest_field(name="additionalInfo", visibility=["read"]) + """Additional scenario specific error details.""" + + +class ErrorResponse(_Model): + """Error response. + + :ivar error: The error details. + :vartype error: ~azure.mgmt.policyinsights.models.ErrorDefinition + """ + + error: Optional["_models.ErrorDefinition"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The error details.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.ErrorDefinition"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class ExpressionEvaluationDetails(_Model): + """Evaluation details of policy language expressions. + + :ivar result: Evaluation result. + :vartype result: str + :ivar expression: Expression evaluated. + :vartype expression: str + :ivar expression_kind: The kind of expression that was evaluated. + :vartype expression_kind: str + :ivar path: Property path if the expression is a field or an alias. + :vartype path: str + :ivar expression_value: Value of the expression. + :vartype expression_value: any + :ivar target_value: Target value to be compared with the expression value. + :vartype target_value: any + :ivar operator: Operator to compare the expression value and the target value. + :vartype operator: str + """ + + result: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Evaluation result.""" + expression: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Expression evaluated.""" + expression_kind: Optional[str] = rest_field(name="expressionKind", visibility=["read"]) + """The kind of expression that was evaluated.""" + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Property path if the expression is a field or an alias.""" + expression_value: Optional[Any] = rest_field( + name="expressionValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Value of the expression.""" + target_value: Optional[Any] = rest_field( + name="targetValue", visibility=["read", "create", "update", "delete", "query"] + ) + """Target value to be compared with the expression value.""" + operator: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operator to compare the expression value and the target value.""" + + @overload + def __init__( + self, + *, + result: Optional[str] = None, + expression: Optional[str] = None, + path: Optional[str] = None, + expression_value: Optional[Any] = None, + target_value: Optional[Any] = None, + operator: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class FieldRestriction(_Model): + """The restrictions on a field imposed by a specific policy. + + :ivar result: The type of restriction that is imposed on the field. Known values are: + "Required", "Removed", "Deny", and "Audit". + :vartype result: str or ~azure.mgmt.policyinsights.models.FieldRestrictionResult + :ivar default_value: The value that policy will set for the field if the user does not provide + a value. + :vartype default_value: str + :ivar values_property: The values that policy either requires or denies for the field. + :vartype values_property: list[str] + :ivar policy: The details of the policy that is causing the field restriction. + :vartype policy: ~azure.mgmt.policyinsights.models.PolicyReference + :ivar policy_effect: The effect of the policy that is causing the field restriction. + `http://aka.ms/policyeffects `_. + :vartype policy_effect: str + :ivar reason: The reason for the restriction. + :vartype reason: str + """ + + result: Optional[Union[str, "_models.FieldRestrictionResult"]] = rest_field(visibility=["read"]) + """The type of restriction that is imposed on the field. Known values are: \"Required\", + \"Removed\", \"Deny\", and \"Audit\".""" + default_value: Optional[str] = rest_field(name="defaultValue", visibility=["read"]) + """The value that policy will set for the field if the user does not provide a value.""" + values_property: Optional[list[str]] = rest_field(name="values", visibility=["read"], original_tsp_name="values") + """The values that policy either requires or denies for the field.""" + policy: Optional["_models.PolicyReference"] = rest_field(visibility=["read"]) + """The details of the policy that is causing the field restriction.""" + policy_effect: Optional[str] = rest_field(name="policyEffect", visibility=["read"]) + """The effect of the policy that is causing the field restriction. `http://aka.ms/policyeffects + `_.""" + reason: Optional[str] = rest_field(visibility=["read"]) + """The reason for the restriction.""" + + +class FieldRestrictions(_Model): + """The restrictions that will be placed on a field in the resource by policy. + + :ivar field: The name of the field. This can be a top-level property like 'name' or 'type' or + an Azure Policy field alias. + :vartype field: str + :ivar restrictions: The restrictions placed on that field by policy. + :vartype restrictions: list[~azure.mgmt.policyinsights.models.FieldRestriction] + """ + + field: Optional[str] = rest_field(visibility=["read"]) + """The name of the field. This can be a top-level property like 'name' or 'type' or an Azure + Policy field alias.""" + restrictions: Optional[list["_models.FieldRestriction"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The restrictions placed on that field by policy.""" + + @overload + def __init__( + self, + *, + restrictions: Optional[list["_models.FieldRestriction"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class IfNotExistsEvaluationDetails(_Model): + """Evaluation details of IfNotExists effect. + + :ivar resource_id: ID of the last evaluated resource for IfNotExists effect. + :vartype resource_id: str + :ivar total_resources: Total number of resources to which the existence condition is + applicable. + :vartype total_resources: int + """ + + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """ID of the last evaluated resource for IfNotExists effect.""" + total_resources: Optional[int] = rest_field( + name="totalResources", visibility=["read", "create", "update", "delete", "query"] + ) + """Total number of resources to which the existence condition is applicable.""" + + @overload + def __init__( + self, + *, + resource_id: Optional[str] = None, + total_resources: Optional[int] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Operation(_Model): + """Operation definition. + + :ivar name: Operation name. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.policyinsights.models.OperationDisplay + """ + + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation name.""" + is_data_action: Optional[bool] = rest_field( + name="isDataAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Indicates whether the operation is a data action.""" + display: Optional["_models.OperationDisplay"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Display metadata associated with the operation.""" + + @overload + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationDisplay(_Model): + """Display metadata associated with the operation. + + :ivar provider: Resource provider name. + :vartype provider: str + :ivar resource: Resource name on which the operation is performed. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str + """ + + provider: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource provider name.""" + resource: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Resource name on which the operation is performed.""" + operation: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation name.""" + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Operation description.""" + + @overload + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class OperationsListResults(_Model): + """List of available operations. + + :ivar odata_count: OData entity count; represents the number of operations returned. + :vartype odata_count: int + :ivar value: List of available operations. + :vartype value: list[~azure.mgmt.policyinsights.models.Operation] + """ + + odata_count: Optional[int] = rest_field( + name="@odata.count", visibility=["read", "create", "update", "delete", "query"] + ) + """OData entity count; represents the number of operations returned.""" + value: Optional[list["_models.Operation"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """List of available operations.""" + + @overload + def __init__( + self, + *, + odata_count: Optional[int] = None, + value: Optional[list["_models.Operation"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PendingField(_Model): + """A field that should be evaluated against Azure Policy to determine restrictions. + + :ivar field: The name of the field. This can be a top-level property like 'name' or 'type' or + an Azure Policy field alias. Required. + :vartype field: str + :ivar values_property: The list of potential values for the field that should be evaluated + against Azure Policy. + :vartype values_property: list[str] + """ + + field: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the field. This can be a top-level property like 'name' or 'type' or an Azure + Policy field alias. Required.""" + values_property: Optional[list[str]] = rest_field( + name="values", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="values" + ) + """The list of potential values for the field that should be evaluated against Azure Policy.""" + + @overload + def __init__( + self, + *, + field: str, + values_property: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyAssignmentSummary(_Model): + """Policy assignment summary. + + :ivar policy_assignment_id: Policy assignment ID. + :vartype policy_assignment_id: str + :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a + policy set. + :vartype policy_set_definition_id: str + :ivar results: Compliance summary for the policy assignment. + :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults + :ivar policy_definitions: Policy definitions summary. + :vartype policy_definitions: list[~azure.mgmt.policyinsights.models.PolicyDefinitionSummary] + :ivar policy_groups: Policy definition group summary. + :vartype policy_groups: list[~azure.mgmt.policyinsights.models.PolicyGroupSummary] + """ + + policy_assignment_id: Optional[str] = rest_field( + name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment ID.""" + policy_set_definition_id: Optional[str] = rest_field( + name="policySetDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition ID, if the policy assignment is for a policy set.""" + results: Optional["_models.SummaryResults"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compliance summary for the policy assignment.""" + policy_definitions: Optional[list["_models.PolicyDefinitionSummary"]] = rest_field( + name="policyDefinitions", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definitions summary.""" + policy_groups: Optional[list["_models.PolicyGroupSummary"]] = rest_field( + name="policyGroups", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition group summary.""" + + @overload + def __init__( + self, + *, + policy_assignment_id: Optional[str] = None, + policy_set_definition_id: Optional[str] = None, + results: Optional["_models.SummaryResults"] = None, + policy_definitions: Optional[list["_models.PolicyDefinitionSummary"]] = None, + policy_groups: Optional[list["_models.PolicyGroupSummary"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyDefinitionSummary(_Model): + """Policy definition summary. + + :ivar policy_definition_id: Policy definition ID. + :vartype policy_definition_id: str + :ivar policy_definition_reference_id: Policy definition reference ID. + :vartype policy_definition_reference_id: str + :ivar policy_definition_group_names: Policy definition group names. + :vartype policy_definition_group_names: list[str] + :ivar effect: Policy effect, i.e. policy definition action. + :vartype effect: str + :ivar results: Compliance summary for the policy definition. + :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults + """ + + policy_definition_id: Optional[str] = rest_field( + name="policyDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition ID.""" + policy_definition_reference_id: Optional[str] = rest_field( + name="policyDefinitionReferenceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition reference ID.""" + policy_definition_group_names: Optional[list[str]] = rest_field( + name="policyDefinitionGroupNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition group names.""" + effect: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Policy effect, i.e. policy definition action.""" + results: Optional["_models.SummaryResults"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compliance summary for the policy definition.""" + + @overload + def __init__( + self, + *, + policy_definition_id: Optional[str] = None, + policy_definition_reference_id: Optional[str] = None, + policy_definition_group_names: Optional[list[str]] = None, + effect: Optional[str] = None, + results: Optional["_models.SummaryResults"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyDetails(_Model): + """The policy details. + + :ivar policy_definition_id: The ID of the policy definition. + :vartype policy_definition_id: str + :ivar policy_assignment_id: The ID of the policy assignment. + :vartype policy_assignment_id: str + :ivar policy_assignment_display_name: The display name of the policy assignment. + :vartype policy_assignment_display_name: str + :ivar policy_assignment_scope: The scope of the policy assignment. + :vartype policy_assignment_scope: str + :ivar policy_set_definition_id: The ID of the policy set definition. + :vartype policy_set_definition_id: str + :ivar policy_definition_reference_id: The policy definition reference ID within the policy set + definition. + :vartype policy_definition_reference_id: str + """ + + policy_definition_id: Optional[str] = rest_field(name="policyDefinitionId", visibility=["read"]) + """The ID of the policy definition.""" + policy_assignment_id: Optional[str] = rest_field(name="policyAssignmentId", visibility=["read"]) + """The ID of the policy assignment.""" + policy_assignment_display_name: Optional[str] = rest_field(name="policyAssignmentDisplayName", visibility=["read"]) + """The display name of the policy assignment.""" + policy_assignment_scope: Optional[str] = rest_field(name="policyAssignmentScope", visibility=["read"]) + """The scope of the policy assignment.""" + policy_set_definition_id: Optional[str] = rest_field(name="policySetDefinitionId", visibility=["read"]) + """The ID of the policy set definition.""" + policy_definition_reference_id: Optional[str] = rest_field(name="policyDefinitionReferenceId", visibility=["read"]) + """The policy definition reference ID within the policy set definition.""" + + +class PolicyEffectDetails(_Model): + """The details of the effect that was applied to the resource. + + :ivar policy_effect: The effect that was applied to the resource. `http://aka.ms/policyeffects + `_. + :vartype policy_effect: str + """ + + policy_effect: Optional[str] = rest_field(name="policyEffect", visibility=["read"]) + """The effect that was applied to the resource. `http://aka.ms/policyeffects + `_.""" + + +class PolicyEvaluationDetails(_Model): + """Policy evaluation details. + + :ivar evaluated_expressions: Details of the evaluated expressions. + :vartype evaluated_expressions: + list[~azure.mgmt.policyinsights.models.ExpressionEvaluationDetails] + :ivar if_not_exists_details: Evaluation details of IfNotExists effect. + :vartype if_not_exists_details: ~azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails + """ + + evaluated_expressions: Optional[list["_models.ExpressionEvaluationDetails"]] = rest_field( + name="evaluatedExpressions", visibility=["read", "create", "update", "delete", "query"] + ) + """Details of the evaluated expressions.""" + if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = rest_field( + name="ifNotExistsDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Evaluation details of IfNotExists effect.""" + + @overload + def __init__( + self, + *, + evaluated_expressions: Optional[list["_models.ExpressionEvaluationDetails"]] = None, + if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyEvaluationResult(_Model): + """The result of a non-compliant policy evaluation against the given resource content. + + :ivar policy_info: The details of the policy that was evaluated. + :vartype policy_info: ~azure.mgmt.policyinsights.models.PolicyReference + :ivar evaluation_result: The result of the policy evaluation against the resource. This will + typically be 'NonCompliant' but may contain other values if errors were encountered. + :vartype evaluation_result: str + :ivar evaluation_details: The detailed results of the policy expressions and values that were + evaluated. + :vartype evaluation_details: + ~azure.mgmt.policyinsights.models.CheckRestrictionEvaluationDetails + :ivar effect_details: The details of the effect that was applied to the resource. + :vartype effect_details: ~azure.mgmt.policyinsights.models.PolicyEffectDetails + """ + + policy_info: Optional["_models.PolicyReference"] = rest_field(name="policyInfo", visibility=["read"]) + """The details of the policy that was evaluated.""" + evaluation_result: Optional[str] = rest_field(name="evaluationResult", visibility=["read"]) + """The result of the policy evaluation against the resource. This will typically be 'NonCompliant' + but may contain other values if errors were encountered.""" + evaluation_details: Optional["_models.CheckRestrictionEvaluationDetails"] = rest_field( + name="evaluationDetails", visibility=["read"] + ) + """The detailed results of the policy expressions and values that were evaluated.""" + effect_details: Optional["_models.PolicyEffectDetails"] = rest_field(name="effectDetails", visibility=["read"]) + """The details of the effect that was applied to the resource.""" + + +class PolicyEvent(_Model): + """Policy event record. + + :ivar odata_id: OData entity ID; always set to null since policy event records do not have an + entity ID. + :vartype odata_id: str + :ivar odata_context: OData context string; used by OData clients to resolve type information + based on metadata. + :vartype odata_context: str + :ivar timestamp: Timestamp for the policy event record. + :vartype timestamp: ~datetime.datetime + :ivar resource_id: Resource ID. + :vartype resource_id: str + :ivar policy_assignment_id: Policy assignment ID. + :vartype policy_assignment_id: str + :ivar policy_definition_id: Policy definition ID. + :vartype policy_definition_id: str + :ivar effective_parameters: Effective parameters for the policy assignment. + :vartype effective_parameters: str + :ivar is_compliant: Flag which states whether the resource is compliant against the policy + assignment it was evaluated against. + :vartype is_compliant: bool + :ivar subscription_id: Subscription ID. + :vartype subscription_id: str + :ivar resource_type: Resource type. + :vartype resource_type: str + :ivar resource_location: Resource location. + :vartype resource_location: str + :ivar resource_group: Resource group name. + :vartype resource_group: str + :ivar resource_tags: List of resource tags. + :vartype resource_tags: str + :ivar policy_assignment_name: Policy assignment name. + :vartype policy_assignment_name: str + :ivar policy_assignment_owner: Policy assignment owner. + :vartype policy_assignment_owner: str + :ivar policy_assignment_parameters: Policy assignment parameters. + :vartype policy_assignment_parameters: str + :ivar policy_assignment_scope: Policy assignment scope. + :vartype policy_assignment_scope: str + :ivar policy_definition_name: Policy definition name. + :vartype policy_definition_name: str + :ivar policy_definition_action: Policy definition action, i.e. effect. + :vartype policy_definition_action: str + :ivar policy_definition_category: Policy definition category. + :vartype policy_definition_category: str + :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a + policy set. + :vartype policy_set_definition_id: str + :ivar policy_set_definition_name: Policy set definition name, if the policy assignment is for a + policy set. + :vartype policy_set_definition_name: str + :ivar policy_set_definition_owner: Policy set definition owner, if the policy assignment is for + a policy set. + :vartype policy_set_definition_owner: str + :ivar policy_set_definition_category: Policy set definition category, if the policy assignment + is for a policy set. + :vartype policy_set_definition_category: str + :ivar policy_set_definition_parameters: Policy set definition parameters, if the policy + assignment is for a policy set. + :vartype policy_set_definition_parameters: str + :ivar management_group_ids: Comma separated list of management group IDs, which represent the + hierarchy of the management groups the resource is under. + :vartype management_group_ids: str + :ivar policy_definition_reference_id: Reference ID for the policy definition inside the policy + set, if the policy assignment is for a policy set. + :vartype policy_definition_reference_id: str + :ivar compliance_state: Compliance state of the resource. + :vartype compliance_state: str + :ivar tenant_id: Tenant ID for the policy event record. + :vartype tenant_id: str + :ivar principal_oid: Principal object ID for the user who initiated the resource operation that + triggered the policy event. + :vartype principal_oid: str + :ivar components: Components events records populated only when URL contains $expand=components + clause. + :vartype components: list[~azure.mgmt.policyinsights.models.ComponentEventDetails] + """ + + odata_id: Optional[str] = rest_field(name="@odata.id", visibility=["read", "create", "update", "delete", "query"]) + """OData entity ID; always set to null since policy event records do not have an entity ID.""" + odata_context: Optional[str] = rest_field( + name="@odata.context", visibility=["read", "create", "update", "delete", "query"] + ) + """OData context string; used by OData clients to resolve type information based on metadata.""" + timestamp: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Timestamp for the policy event record.""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource ID.""" + policy_assignment_id: Optional[str] = rest_field( + name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment ID.""" + policy_definition_id: Optional[str] = rest_field( + name="policyDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition ID.""" + effective_parameters: Optional[str] = rest_field( + name="effectiveParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Effective parameters for the policy assignment.""" + is_compliant: Optional[bool] = rest_field( + name="isCompliant", visibility=["read", "create", "update", "delete", "query"] + ) + """Flag which states whether the resource is compliant against the policy assignment it was + evaluated against.""" + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription ID.""" + resource_type: Optional[str] = rest_field( + name="resourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource type.""" + resource_location: Optional[str] = rest_field( + name="resourceLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource location.""" + resource_group: Optional[str] = rest_field( + name="resourceGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource group name.""" + resource_tags: Optional[str] = rest_field( + name="resourceTags", visibility=["read", "create", "update", "delete", "query"] + ) + """List of resource tags.""" + policy_assignment_name: Optional[str] = rest_field( + name="policyAssignmentName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment name.""" + policy_assignment_owner: Optional[str] = rest_field( + name="policyAssignmentOwner", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment owner.""" + policy_assignment_parameters: Optional[str] = rest_field( + name="policyAssignmentParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment parameters.""" + policy_assignment_scope: Optional[str] = rest_field( + name="policyAssignmentScope", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment scope.""" + policy_definition_name: Optional[str] = rest_field( + name="policyDefinitionName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition name.""" + policy_definition_action: Optional[str] = rest_field( + name="policyDefinitionAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition action, i.e. effect.""" + policy_definition_category: Optional[str] = rest_field( + name="policyDefinitionCategory", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition category.""" + policy_set_definition_id: Optional[str] = rest_field( + name="policySetDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition ID, if the policy assignment is for a policy set.""" + policy_set_definition_name: Optional[str] = rest_field( + name="policySetDefinitionName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition name, if the policy assignment is for a policy set.""" + policy_set_definition_owner: Optional[str] = rest_field( + name="policySetDefinitionOwner", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition owner, if the policy assignment is for a policy set.""" + policy_set_definition_category: Optional[str] = rest_field( + name="policySetDefinitionCategory", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition category, if the policy assignment is for a policy set.""" + policy_set_definition_parameters: Optional[str] = rest_field( + name="policySetDefinitionParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition parameters, if the policy assignment is for a policy set.""" + management_group_ids: Optional[str] = rest_field( + name="managementGroupIds", visibility=["read", "create", "update", "delete", "query"] + ) + """Comma separated list of management group IDs, which represent the hierarchy of the management + groups the resource is under.""" + policy_definition_reference_id: Optional[str] = rest_field( + name="policyDefinitionReferenceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Reference ID for the policy definition inside the policy set, if the policy assignment is for a + policy set.""" + compliance_state: Optional[str] = rest_field( + name="complianceState", visibility=["read", "create", "update", "delete", "query"] + ) + """Compliance state of the resource.""" + tenant_id: Optional[str] = rest_field(name="tenantId", visibility=["read", "create", "update", "delete", "query"]) + """Tenant ID for the policy event record.""" + principal_oid: Optional[str] = rest_field( + name="principalOid", visibility=["read", "create", "update", "delete", "query"] + ) + """Principal object ID for the user who initiated the resource operation that triggered the policy + event.""" + components: Optional[list["_models.ComponentEventDetails"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Components events records populated only when URL contains $expand=components clause.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + odata_id: Optional[str] = None, + odata_context: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + resource_id: Optional[str] = None, + policy_assignment_id: Optional[str] = None, + policy_definition_id: Optional[str] = None, + effective_parameters: Optional[str] = None, + is_compliant: Optional[bool] = None, + subscription_id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_location: Optional[str] = None, + resource_group: Optional[str] = None, + resource_tags: Optional[str] = None, + policy_assignment_name: Optional[str] = None, + policy_assignment_owner: Optional[str] = None, + policy_assignment_parameters: Optional[str] = None, + policy_assignment_scope: Optional[str] = None, + policy_definition_name: Optional[str] = None, + policy_definition_action: Optional[str] = None, + policy_definition_category: Optional[str] = None, + policy_set_definition_id: Optional[str] = None, + policy_set_definition_name: Optional[str] = None, + policy_set_definition_owner: Optional[str] = None, + policy_set_definition_category: Optional[str] = None, + policy_set_definition_parameters: Optional[str] = None, + management_group_ids: Optional[str] = None, + policy_definition_reference_id: Optional[str] = None, + compliance_state: Optional[str] = None, + tenant_id: Optional[str] = None, + principal_oid: Optional[str] = None, + components: Optional[list["_models.ComponentEventDetails"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyGroupSummary(_Model): + """Policy definition group summary. + + :ivar policy_group_name: Policy group name. + :vartype policy_group_name: str + :ivar results: Compliance summary for the policy definition group. + :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults + """ + + policy_group_name: Optional[str] = rest_field( + name="policyGroupName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy group name.""" + results: Optional["_models.SummaryResults"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compliance summary for the policy definition group.""" + + @overload + def __init__( + self, + *, + policy_group_name: Optional[str] = None, + results: Optional["_models.SummaryResults"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyMetadata(ProxyResource): + """Policy metadata resource definition. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + :ivar properties: Properties of the policy metadata. + :vartype properties: ~azure.mgmt.policyinsights.models.PolicyMetadataProperties + """ + + properties: Optional["_models.PolicyMetadataProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the policy metadata.""" + + __flattened_items = [ + "metadata_id", + "category", + "title", + "owner", + "additional_content_url", + "metadata", + "description", + "requirements", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyMetadataProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class PolicyMetadataSlimProperties(_Model): + """The properties of the policy metadata, excluding properties containing large strings. + + :ivar metadata_id: The policy metadata identifier. + :vartype metadata_id: str + :ivar category: The category of the policy metadata. + :vartype category: str + :ivar title: The title of the policy metadata. + :vartype title: str + :ivar owner: The owner of the policy metadata. + :vartype owner: str + :ivar additional_content_url: Url for getting additional content about the resource metadata. + :vartype additional_content_url: str + :ivar metadata: Additional metadata. + :vartype metadata: any + """ + + metadata_id: Optional[str] = rest_field(name="metadataId", visibility=["read"]) + """The policy metadata identifier.""" + category: Optional[str] = rest_field(visibility=["read"]) + """The category of the policy metadata.""" + title: Optional[str] = rest_field(visibility=["read"]) + """The title of the policy metadata.""" + owner: Optional[str] = rest_field(visibility=["read"]) + """The owner of the policy metadata.""" + additional_content_url: Optional[str] = rest_field(name="additionalContentUrl", visibility=["read"]) + """Url for getting additional content about the resource metadata.""" + metadata: Optional[Any] = rest_field(visibility=["read"]) + """Additional metadata.""" + + +class PolicyMetadataProperties(PolicyMetadataSlimProperties): + """The properties of the policy metadata. + + :ivar metadata_id: The policy metadata identifier. + :vartype metadata_id: str + :ivar category: The category of the policy metadata. + :vartype category: str + :ivar title: The title of the policy metadata. + :vartype title: str + :ivar owner: The owner of the policy metadata. + :vartype owner: str + :ivar additional_content_url: Url for getting additional content about the resource metadata. + :vartype additional_content_url: str + :ivar metadata: Additional metadata. + :vartype metadata: any + :ivar description: The description of the policy metadata. + :vartype description: str + :ivar requirements: The requirements of the policy metadata. + :vartype requirements: str + """ + + description: Optional[str] = rest_field(visibility=["read"]) + """The description of the policy metadata.""" + requirements: Optional[str] = rest_field(visibility=["read"]) + """The requirements of the policy metadata.""" + + +class PolicyReference(_Model): + """Resource identifiers for a policy. + + :ivar policy_definition_id: The resource identifier of the policy definition. + :vartype policy_definition_id: str + :ivar policy_set_definition_id: The resource identifier of the policy set definition. + :vartype policy_set_definition_id: str + :ivar policy_definition_reference_id: The reference identifier of a specific policy definition + within a policy set definition. + :vartype policy_definition_reference_id: str + :ivar policy_assignment_id: The resource identifier of the policy assignment. + :vartype policy_assignment_id: str + """ + + policy_definition_id: Optional[str] = rest_field(name="policyDefinitionId", visibility=["read"]) + """The resource identifier of the policy definition.""" + policy_set_definition_id: Optional[str] = rest_field(name="policySetDefinitionId", visibility=["read"]) + """The resource identifier of the policy set definition.""" + policy_definition_reference_id: Optional[str] = rest_field(name="policyDefinitionReferenceId", visibility=["read"]) + """The reference identifier of a specific policy definition within a policy set definition.""" + policy_assignment_id: Optional[str] = rest_field(name="policyAssignmentId", visibility=["read"]) + """The resource identifier of the policy assignment.""" + + +class PolicyState(_Model): + """Policy state record. + + :ivar odata_id: OData entity ID; always set to null since policy state records do not have an + entity ID. + :vartype odata_id: str + :ivar odata_context: OData context string; used by OData clients to resolve type information + based on metadata. + :vartype odata_context: str + :ivar timestamp: Timestamp for the policy state record. + :vartype timestamp: ~datetime.datetime + :ivar resource_id: Resource ID. + :vartype resource_id: str + :ivar policy_assignment_id: Policy assignment ID. + :vartype policy_assignment_id: str + :ivar policy_definition_id: Policy definition ID. + :vartype policy_definition_id: str + :ivar effective_parameters: Effective parameters for the policy assignment. + :vartype effective_parameters: str + :ivar is_compliant: Flag which states whether the resource is compliant against the policy + assignment it was evaluated against. This property is deprecated; please use ComplianceState + instead. + :vartype is_compliant: bool + :ivar subscription_id: Subscription ID. + :vartype subscription_id: str + :ivar resource_type: Resource type. + :vartype resource_type: str + :ivar resource_location: Resource location. + :vartype resource_location: str + :ivar resource_group: Resource group name. + :vartype resource_group: str + :ivar resource_tags: List of resource tags. + :vartype resource_tags: str + :ivar policy_assignment_name: Policy assignment name. + :vartype policy_assignment_name: str + :ivar policy_assignment_owner: Policy assignment owner. + :vartype policy_assignment_owner: str + :ivar policy_assignment_parameters: Policy assignment parameters. + :vartype policy_assignment_parameters: str + :ivar policy_assignment_scope: Policy assignment scope. + :vartype policy_assignment_scope: str + :ivar policy_definition_name: Policy definition name. + :vartype policy_definition_name: str + :ivar policy_definition_action: Policy definition action, i.e. effect. + :vartype policy_definition_action: str + :ivar policy_definition_category: Policy definition category. + :vartype policy_definition_category: str + :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a + policy set. + :vartype policy_set_definition_id: str + :ivar policy_set_definition_name: Policy set definition name, if the policy assignment is for a + policy set. + :vartype policy_set_definition_name: str + :ivar policy_set_definition_owner: Policy set definition owner, if the policy assignment is for + a policy set. + :vartype policy_set_definition_owner: str + :ivar policy_set_definition_category: Policy set definition category, if the policy assignment + is for a policy set. + :vartype policy_set_definition_category: str + :ivar policy_set_definition_parameters: Policy set definition parameters, if the policy + assignment is for a policy set. + :vartype policy_set_definition_parameters: str + :ivar management_group_ids: Comma separated list of management group IDs, which represent the + hierarchy of the management groups the resource is under. + :vartype management_group_ids: str + :ivar policy_definition_reference_id: Reference ID for the policy definition inside the policy + set, if the policy assignment is for a policy set. + :vartype policy_definition_reference_id: str + :ivar compliance_state: Compliance state of the resource. + :vartype compliance_state: str + :ivar policy_evaluation_details: Policy evaluation details. + :vartype policy_evaluation_details: ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails + :ivar policy_definition_group_names: Policy definition group names. + :vartype policy_definition_group_names: list[str] + :ivar components: Components state compliance records populated only when URL contains + $expand=components clause. + :vartype components: list[~azure.mgmt.policyinsights.models.ComponentStateDetails] + :ivar policy_definition_version: Evaluated policy definition version. + :vartype policy_definition_version: str + :ivar policy_set_definition_version: Evaluated policy set definition version. + :vartype policy_set_definition_version: str + :ivar policy_assignment_version: Evaluated policy assignment version. + :vartype policy_assignment_version: str + """ + + odata_id: Optional[str] = rest_field(name="@odata.id", visibility=["read", "create", "update", "delete", "query"]) + """OData entity ID; always set to null since policy state records do not have an entity ID.""" + odata_context: Optional[str] = rest_field( + name="@odata.context", visibility=["read", "create", "update", "delete", "query"] + ) + """OData context string; used by OData clients to resolve type information based on metadata.""" + timestamp: Optional[datetime.datetime] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """Timestamp for the policy state record.""" + resource_id: Optional[str] = rest_field( + name="resourceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource ID.""" + policy_assignment_id: Optional[str] = rest_field( + name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment ID.""" + policy_definition_id: Optional[str] = rest_field( + name="policyDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition ID.""" + effective_parameters: Optional[str] = rest_field( + name="effectiveParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Effective parameters for the policy assignment.""" + is_compliant: Optional[bool] = rest_field( + name="isCompliant", visibility=["read", "create", "update", "delete", "query"] + ) + """Flag which states whether the resource is compliant against the policy assignment it was + evaluated against. This property is deprecated; please use ComplianceState instead.""" + subscription_id: Optional[str] = rest_field( + name="subscriptionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Subscription ID.""" + resource_type: Optional[str] = rest_field( + name="resourceType", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource type.""" + resource_location: Optional[str] = rest_field( + name="resourceLocation", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource location.""" + resource_group: Optional[str] = rest_field( + name="resourceGroup", visibility=["read", "create", "update", "delete", "query"] + ) + """Resource group name.""" + resource_tags: Optional[str] = rest_field( + name="resourceTags", visibility=["read", "create", "update", "delete", "query"] + ) + """List of resource tags.""" + policy_assignment_name: Optional[str] = rest_field( + name="policyAssignmentName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment name.""" + policy_assignment_owner: Optional[str] = rest_field( + name="policyAssignmentOwner", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment owner.""" + policy_assignment_parameters: Optional[str] = rest_field( + name="policyAssignmentParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment parameters.""" + policy_assignment_scope: Optional[str] = rest_field( + name="policyAssignmentScope", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignment scope.""" + policy_definition_name: Optional[str] = rest_field( + name="policyDefinitionName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition name.""" + policy_definition_action: Optional[str] = rest_field( + name="policyDefinitionAction", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition action, i.e. effect.""" + policy_definition_category: Optional[str] = rest_field( + name="policyDefinitionCategory", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition category.""" + policy_set_definition_id: Optional[str] = rest_field( + name="policySetDefinitionId", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition ID, if the policy assignment is for a policy set.""" + policy_set_definition_name: Optional[str] = rest_field( + name="policySetDefinitionName", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition name, if the policy assignment is for a policy set.""" + policy_set_definition_owner: Optional[str] = rest_field( + name="policySetDefinitionOwner", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition owner, if the policy assignment is for a policy set.""" + policy_set_definition_category: Optional[str] = rest_field( + name="policySetDefinitionCategory", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition category, if the policy assignment is for a policy set.""" + policy_set_definition_parameters: Optional[str] = rest_field( + name="policySetDefinitionParameters", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy set definition parameters, if the policy assignment is for a policy set.""" + management_group_ids: Optional[str] = rest_field( + name="managementGroupIds", visibility=["read", "create", "update", "delete", "query"] + ) + """Comma separated list of management group IDs, which represent the hierarchy of the management + groups the resource is under.""" + policy_definition_reference_id: Optional[str] = rest_field( + name="policyDefinitionReferenceId", visibility=["read", "create", "update", "delete", "query"] + ) + """Reference ID for the policy definition inside the policy set, if the policy assignment is for a + policy set.""" + compliance_state: Optional[str] = rest_field( + name="complianceState", visibility=["read", "create", "update", "delete", "query"] + ) + """Compliance state of the resource.""" + policy_evaluation_details: Optional["_models.PolicyEvaluationDetails"] = rest_field( + name="policyEvaluationDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy evaluation details.""" + policy_definition_group_names: Optional[list[str]] = rest_field( + name="policyDefinitionGroupNames", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy definition group names.""" + components: Optional[list["_models.ComponentStateDetails"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Components state compliance records populated only when URL contains $expand=components clause.""" + policy_definition_version: Optional[str] = rest_field(name="policyDefinitionVersion", visibility=["read"]) + """Evaluated policy definition version.""" + policy_set_definition_version: Optional[str] = rest_field(name="policySetDefinitionVersion", visibility=["read"]) + """Evaluated policy set definition version.""" + policy_assignment_version: Optional[str] = rest_field(name="policyAssignmentVersion", visibility=["read"]) + """Evaluated policy assignment version.""" + + @overload + def __init__( # pylint: disable=too-many-locals + self, + *, + odata_id: Optional[str] = None, + odata_context: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + resource_id: Optional[str] = None, + policy_assignment_id: Optional[str] = None, + policy_definition_id: Optional[str] = None, + effective_parameters: Optional[str] = None, + is_compliant: Optional[bool] = None, + subscription_id: Optional[str] = None, + resource_type: Optional[str] = None, + resource_location: Optional[str] = None, + resource_group: Optional[str] = None, + resource_tags: Optional[str] = None, + policy_assignment_name: Optional[str] = None, + policy_assignment_owner: Optional[str] = None, + policy_assignment_parameters: Optional[str] = None, + policy_assignment_scope: Optional[str] = None, + policy_definition_name: Optional[str] = None, + policy_definition_action: Optional[str] = None, + policy_definition_category: Optional[str] = None, + policy_set_definition_id: Optional[str] = None, + policy_set_definition_name: Optional[str] = None, + policy_set_definition_owner: Optional[str] = None, + policy_set_definition_category: Optional[str] = None, + policy_set_definition_parameters: Optional[str] = None, + management_group_ids: Optional[str] = None, + policy_definition_reference_id: Optional[str] = None, + compliance_state: Optional[str] = None, + policy_evaluation_details: Optional["_models.PolicyEvaluationDetails"] = None, + policy_definition_group_names: Optional[list[str]] = None, + components: Optional[list["_models.ComponentStateDetails"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class PolicyTrackedResource(_Model): + """Policy tracked resource record. + + :ivar tracked_resource_id: The ID of the policy tracked resource. + :vartype tracked_resource_id: str + :ivar policy_details: The details of the policy that require the tracked resource. + :vartype policy_details: ~azure.mgmt.policyinsights.models.PolicyDetails + :ivar created_by: The details of the policy triggered deployment that created the tracked + resource. + :vartype created_by: ~azure.mgmt.policyinsights.models.TrackedResourceModificationDetails + :ivar last_modified_by: The details of the policy triggered deployment that modified the + tracked resource. + :vartype last_modified_by: ~azure.mgmt.policyinsights.models.TrackedResourceModificationDetails + :ivar last_update_utc: Timestamp of the last update to the tracked resource. + :vartype last_update_utc: ~datetime.datetime + """ + + tracked_resource_id: Optional[str] = rest_field(name="trackedResourceId", visibility=["read"]) + """The ID of the policy tracked resource.""" + policy_details: Optional["_models.PolicyDetails"] = rest_field(name="policyDetails", visibility=["read"]) + """The details of the policy that require the tracked resource.""" + created_by: Optional["_models.TrackedResourceModificationDetails"] = rest_field( + name="createdBy", visibility=["read"] + ) + """The details of the policy triggered deployment that created the tracked resource.""" + last_modified_by: Optional["_models.TrackedResourceModificationDetails"] = rest_field( + name="lastModifiedBy", visibility=["read"] + ) + """The details of the policy triggered deployment that modified the tracked resource.""" + last_update_utc: Optional[datetime.datetime] = rest_field( + name="lastUpdateUtc", visibility=["read"], format="rfc3339" + ) + """Timestamp of the last update to the tracked resource.""" + + +class QueryFailure(_Model): + """Error response. + + :ivar error: Error definition. + :vartype error: ~azure.mgmt.policyinsights.models.QueryFailureError + """ + + error: Optional["_models.QueryFailureError"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Error definition.""" + + @overload + def __init__( + self, + *, + error: Optional["_models.QueryFailureError"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class QueryFailureError(_Model): + """Error definition. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + """ + + code: Optional[str] = rest_field(visibility=["read"]) + """Service specific error code which serves as the substatus for the HTTP error code.""" + message: Optional[str] = rest_field(visibility=["read"]) + """Description of the error.""" + + +class Remediation(ProxyResource): + """The remediation definition. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + :ivar properties: Properties for the remediation. + :vartype properties: ~azure.mgmt.policyinsights.models.RemediationProperties + """ + + properties: Optional["_models.RemediationProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties for the remediation.""" + + __flattened_items = [ + "policy_assignment_id", + "policy_definition_reference_id", + "resource_discovery_mode", + "provisioning_state", + "created_on", + "last_updated_on", + "filters", + "deployment_status", + "status_message", + "correlation_id", + "resource_count", + "parallel_deployments", + "failure_threshold", + ] + + @overload + def __init__( + self, + *, + properties: Optional["_models.RemediationProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class RemediationDeployment(_Model): + """Details of a single deployment created by the remediation. + + :ivar remediated_resource_id: Resource ID of the resource that is being remediated by the + deployment. + :vartype remediated_resource_id: str + :ivar deployment_id: Resource ID of the template deployment that will remediate the resource. + :vartype deployment_id: str + :ivar status: Status of the remediation deployment. + :vartype status: str + :ivar resource_location: Location of the resource that is being remediated. + :vartype resource_location: str + :ivar error: Error encountered while remediated the resource. + :vartype error: ~azure.mgmt.policyinsights.models.ErrorDefinition + :ivar created_on: The time at which the remediation was created. + :vartype created_on: ~datetime.datetime + :ivar last_updated_on: The time at which the remediation deployment was last updated. + :vartype last_updated_on: ~datetime.datetime + """ + + remediated_resource_id: Optional[str] = rest_field(name="remediatedResourceId", visibility=["read"]) + """Resource ID of the resource that is being remediated by the deployment.""" + deployment_id: Optional[str] = rest_field(name="deploymentId", visibility=["read"]) + """Resource ID of the template deployment that will remediate the resource.""" + status: Optional[str] = rest_field(visibility=["read"]) + """Status of the remediation deployment.""" + resource_location: Optional[str] = rest_field(name="resourceLocation", visibility=["read"]) + """Location of the resource that is being remediated.""" + error: Optional["_models.ErrorDefinition"] = rest_field(visibility=["read"]) + """Error encountered while remediated the resource.""" + created_on: Optional[datetime.datetime] = rest_field(name="createdOn", visibility=["read"], format="rfc3339") + """The time at which the remediation was created.""" + last_updated_on: Optional[datetime.datetime] = rest_field( + name="lastUpdatedOn", visibility=["read"], format="rfc3339" + ) + """The time at which the remediation deployment was last updated.""" + + +class RemediationDeploymentSummary(_Model): + """The deployment status summary for all deployments created by the remediation. + + :ivar total_deployments: The number of deployments required by the remediation. + :vartype total_deployments: int + :ivar successful_deployments: The number of deployments required by the remediation that have + succeeded. + :vartype successful_deployments: int + :ivar failed_deployments: The number of deployments required by the remediation that have + failed. + :vartype failed_deployments: int + """ + + total_deployments: Optional[int] = rest_field(name="totalDeployments", visibility=["read"]) + """The number of deployments required by the remediation.""" + successful_deployments: Optional[int] = rest_field(name="successfulDeployments", visibility=["read"]) + """The number of deployments required by the remediation that have succeeded.""" + failed_deployments: Optional[int] = rest_field(name="failedDeployments", visibility=["read"]) + """The number of deployments required by the remediation that have failed.""" + + +class RemediationFilters(_Model): + """The filters that will be applied to determine which resources to remediate. + + :ivar locations: The resource locations that will be remediated. + :vartype locations: list[str] + :ivar resource_ids: The IDs of the resources that will be remediated. Can specify at most 100 + IDs. This filter cannot be used when ReEvaluateCompliance is set to ReEvaluateCompliance, and + cannot be empty if provided. + :vartype resource_ids: list[str] + """ + + locations: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The resource locations that will be remediated.""" + resource_ids: Optional[list[str]] = rest_field( + name="resourceIds", visibility=["read", "create", "update", "delete", "query"] + ) + """The IDs of the resources that will be remediated. Can specify at most 100 IDs. This filter + cannot be used when ReEvaluateCompliance is set to ReEvaluateCompliance, and cannot be empty if + provided.""" + + @overload + def __init__( + self, + *, + locations: Optional[list[str]] = None, + resource_ids: Optional[list[str]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RemediationProperties(_Model): + """The remediation properties. + + :ivar policy_assignment_id: The resource ID of the policy assignment that should be remediated. + :vartype policy_assignment_id: str + :ivar policy_definition_reference_id: The policy definition reference ID of the individual + definition that should be remediated. Required when the policy assignment being remediated + assigns a policy set definition. + :vartype policy_definition_reference_id: str + :ivar resource_discovery_mode: The way resources to remediate are discovered. Defaults to + ExistingNonCompliant if not specified. Known values are: "ExistingNonCompliant" and + "ReEvaluateCompliance". + :vartype resource_discovery_mode: str or + ~azure.mgmt.policyinsights.models.ResourceDiscoveryMode + :ivar provisioning_state: The status of the remediation. This refers to the entire remediation + task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, + Complete, or Succeeded. + :vartype provisioning_state: str + :ivar created_on: The time at which the remediation was created. + :vartype created_on: ~datetime.datetime + :ivar last_updated_on: The time at which the remediation was last updated. + :vartype last_updated_on: ~datetime.datetime + :ivar filters: The filters that will be applied to determine which resources to remediate. + :vartype filters: ~azure.mgmt.policyinsights.models.RemediationFilters + :ivar deployment_status: The deployment status summary for all deployments created by the + remediation. + :vartype deployment_status: ~azure.mgmt.policyinsights.models.RemediationDeploymentSummary + :ivar status_message: The remediation status message. Provides additional details regarding the + state of the remediation. + :vartype status_message: str + :ivar correlation_id: The remediation correlation Id. Can be used to find events related to the + remediation in the activity log. + :vartype correlation_id: str + :ivar resource_count: Determines the max number of resources that can be remediated by the + remediation job. If not provided, the default resource count is used. + :vartype resource_count: int + :ivar parallel_deployments: Determines how many resources to remediate at any given time. Can + be used to increase or reduce the pace of the remediation. If not provided, the default + parallel deployments value is used. + :vartype parallel_deployments: int + :ivar failure_threshold: The remediation failure threshold settings. + :vartype failure_threshold: + ~azure.mgmt.policyinsights.models.RemediationPropertiesFailureThreshold + """ + + policy_assignment_id: Optional[str] = rest_field( + name="policyAssignmentId", visibility=["read", "create", "update", "delete", "query"] + ) + """The resource ID of the policy assignment that should be remediated.""" + policy_definition_reference_id: Optional[str] = rest_field( + name="policyDefinitionReferenceId", visibility=["read", "create", "update", "delete", "query"] + ) + """The policy definition reference ID of the individual definition that should be remediated. + Required when the policy assignment being remediated assigns a policy set definition.""" + resource_discovery_mode: Optional[Union[str, "_models.ResourceDiscoveryMode"]] = rest_field( + name="resourceDiscoveryMode", visibility=["read", "create", "update", "delete", "query"] + ) + """The way resources to remediate are discovered. Defaults to ExistingNonCompliant if not + specified. Known values are: \"ExistingNonCompliant\" and \"ReEvaluateCompliance\".""" + provisioning_state: Optional[str] = rest_field(name="provisioningState", visibility=["read"]) + """The status of the remediation. This refers to the entire remediation task, not individual + deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, Complete, or + Succeeded.""" + created_on: Optional[datetime.datetime] = rest_field(name="createdOn", visibility=["read"], format="rfc3339") + """The time at which the remediation was created.""" + last_updated_on: Optional[datetime.datetime] = rest_field( + name="lastUpdatedOn", visibility=["read"], format="rfc3339" + ) + """The time at which the remediation was last updated.""" + filters: Optional["_models.RemediationFilters"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The filters that will be applied to determine which resources to remediate.""" + deployment_status: Optional["_models.RemediationDeploymentSummary"] = rest_field( + name="deploymentStatus", visibility=["read"] + ) + """The deployment status summary for all deployments created by the remediation.""" + status_message: Optional[str] = rest_field(name="statusMessage", visibility=["read"]) + """The remediation status message. Provides additional details regarding the state of the + remediation.""" + correlation_id: Optional[str] = rest_field(name="correlationId", visibility=["read"]) + """The remediation correlation Id. Can be used to find events related to the remediation in the + activity log.""" + resource_count: Optional[int] = rest_field( + name="resourceCount", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines the max number of resources that can be remediated by the remediation job. If not + provided, the default resource count is used.""" + parallel_deployments: Optional[int] = rest_field( + name="parallelDeployments", visibility=["read", "create", "update", "delete", "query"] + ) + """Determines how many resources to remediate at any given time. Can be used to increase or reduce + the pace of the remediation. If not provided, the default parallel deployments value is used.""" + failure_threshold: Optional["_models.RemediationPropertiesFailureThreshold"] = rest_field( + name="failureThreshold", visibility=["read", "create", "update", "delete", "query"] + ) + """The remediation failure threshold settings.""" + + @overload + def __init__( + self, + *, + policy_assignment_id: Optional[str] = None, + policy_definition_reference_id: Optional[str] = None, + resource_discovery_mode: Optional[Union[str, "_models.ResourceDiscoveryMode"]] = None, + filters: Optional["_models.RemediationFilters"] = None, + resource_count: Optional[int] = None, + parallel_deployments: Optional[int] = None, + failure_threshold: Optional["_models.RemediationPropertiesFailureThreshold"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class RemediationPropertiesFailureThreshold(_Model): + """The remediation failure threshold settings. + + :ivar percentage: A number between 0.0 to 1.0 representing the percentage failure threshold. + The remediation will fail if the percentage of failed remediation operations (i.e. failed + deployments) exceeds this threshold. + :vartype percentage: float + """ + + percentage: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A number between 0.0 to 1.0 representing the percentage failure threshold. The remediation will + fail if the percentage of failed remediation operations (i.e. failed deployments) exceeds this + threshold.""" + + @overload + def __init__( + self, + *, + percentage: Optional[float] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SlimPolicyMetadata(_Model): + """Slim version of policy metadata resource definition, excluding properties with large strings. + + :ivar properties: Properties of the policy metadata. + :vartype properties: ~azure.mgmt.policyinsights.models.PolicyMetadataSlimProperties + :ivar id: The ID of the policy metadata. + :vartype id: str + :ivar type: The type of the policy metadata. + :vartype type: str + :ivar name: The name of the policy metadata. + :vartype name: str + """ + + properties: Optional["_models.PolicyMetadataSlimProperties"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Properties of the policy metadata.""" + id: Optional[str] = rest_field(visibility=["read"]) + """The ID of the policy metadata.""" + type: Optional[str] = rest_field(visibility=["read"]) + """The type of the policy metadata.""" + name: Optional[str] = rest_field(visibility=["read"]) + """The name of the policy metadata.""" + + __flattened_items = ["metadata_id", "category", "title", "owner", "additional_content_url", "metadata"] + + @overload + def __init__( + self, + *, + properties: Optional["_models.PolicyMetadataSlimProperties"] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + _flattened_input = {k: kwargs.pop(k) for k in kwargs.keys() & self.__flattened_items} + super().__init__(*args, **kwargs) + for k, v in _flattened_input.items(): + setattr(self, k, v) + + def __getattr__(self, name: str) -> Any: + if name in self.__flattened_items: + if self.properties is None: + return None + return getattr(self.properties, name) + raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'") + + def __setattr__(self, key: str, value: Any) -> None: + if key in self.__flattened_items: + if self.properties is None: + self.properties = self._attr_to_rest_field["properties"]._class_type() + setattr(self.properties, key, value) + else: + super().__setattr__(key, value) + + +class SummarizeResults(_Model): + """Summarize action results. + + :ivar odata_context: OData context string; used by OData clients to resolve type information + based on metadata. + :vartype odata_context: str + :ivar odata_count: OData entity count; represents the number of summaries returned; always set + to 1. + :vartype odata_count: int + :ivar value: Summarize action results. + :vartype value: list[~azure.mgmt.policyinsights.models.Summary] + """ + + odata_context: Optional[str] = rest_field( + name="@odata.context", visibility=["read", "create", "update", "delete", "query"] + ) + """OData context string; used by OData clients to resolve type information based on metadata.""" + odata_count: Optional[int] = rest_field( + name="@odata.count", visibility=["read", "create", "update", "delete", "query"] + ) + """OData entity count; represents the number of summaries returned; always set to 1.""" + value: Optional[list["_models.Summary"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Summarize action results.""" + + @overload + def __init__( + self, + *, + odata_context: Optional[str] = None, + odata_count: Optional[int] = None, + value: Optional[list["_models.Summary"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class Summary(_Model): + """Summary results. + + :ivar odata_id: OData entity ID; always set to null since summaries do not have an entity ID. + :vartype odata_id: str + :ivar odata_context: OData context string; used by OData clients to resolve type information + based on metadata. + :vartype odata_context: str + :ivar results: Compliance summary for all policy assignments. + :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults + :ivar policy_assignments: Policy assignments summary. + :vartype policy_assignments: list[~azure.mgmt.policyinsights.models.PolicyAssignmentSummary] + """ + + odata_id: Optional[str] = rest_field(name="@odata.id", visibility=["read", "create", "update", "delete", "query"]) + """OData entity ID; always set to null since summaries do not have an entity ID.""" + odata_context: Optional[str] = rest_field( + name="@odata.context", visibility=["read", "create", "update", "delete", "query"] + ) + """OData context string; used by OData clients to resolve type information based on metadata.""" + results: Optional["_models.SummaryResults"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Compliance summary for all policy assignments.""" + policy_assignments: Optional[list["_models.PolicyAssignmentSummary"]] = rest_field( + name="policyAssignments", visibility=["read", "create", "update", "delete", "query"] + ) + """Policy assignments summary.""" + + @overload + def __init__( + self, + *, + odata_id: Optional[str] = None, + odata_context: Optional[str] = None, + results: Optional["_models.SummaryResults"] = None, + policy_assignments: Optional[list["_models.PolicyAssignmentSummary"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SummaryResults(_Model): + """Compliance summary on a particular summary level. + + :ivar query_results_uri: HTTP POST URI for queryResults action on Microsoft.PolicyInsights to + retrieve raw results for the compliance summary. This property will not be available by default + in future API versions, but could be queried explicitly. + :vartype query_results_uri: str + :ivar non_compliant_resources: Number of non-compliant resources. + :vartype non_compliant_resources: int + :ivar non_compliant_policies: Number of non-compliant policies. + :vartype non_compliant_policies: int + :ivar resource_details: The resources summary at this level. + :vartype resource_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] + :ivar policy_details: The policy artifact summary at this level. For query scope level, it + represents policy assignment summary. For policy assignment level, it represents policy + definitions summary. + :vartype policy_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] + :ivar policy_group_details: The policy definition group summary at this level. + :vartype policy_group_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] + """ + + query_results_uri: Optional[str] = rest_field( + name="queryResultsUri", visibility=["read", "create", "update", "delete", "query"] + ) + """HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for + the compliance summary. This property will not be available by default in future API versions, + but could be queried explicitly.""" + non_compliant_resources: Optional[int] = rest_field( + name="nonCompliantResources", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of non-compliant resources.""" + non_compliant_policies: Optional[int] = rest_field( + name="nonCompliantPolicies", visibility=["read", "create", "update", "delete", "query"] + ) + """Number of non-compliant policies.""" + resource_details: Optional[list["_models.ComplianceDetail"]] = rest_field( + name="resourceDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """The resources summary at this level.""" + policy_details: Optional[list["_models.ComplianceDetail"]] = rest_field( + name="policyDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """The policy artifact summary at this level. For query scope level, it represents policy + assignment summary. For policy assignment level, it represents policy definitions summary.""" + policy_group_details: Optional[list["_models.ComplianceDetail"]] = rest_field( + name="policyGroupDetails", visibility=["read", "create", "update", "delete", "query"] + ) + """The policy definition group summary at this level.""" + + @overload + def __init__( + self, + *, + query_results_uri: Optional[str] = None, + non_compliant_resources: Optional[int] = None, + non_compliant_policies: Optional[int] = None, + resource_details: Optional[list["_models.ComplianceDetail"]] = None, + policy_details: Optional[list["_models.ComplianceDetail"]] = None, + policy_group_details: Optional[list["_models.ComplianceDetail"]] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class SystemData(_Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.policyinsights.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.policyinsights.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + created_by: Optional[str] = rest_field(name="createdBy", visibility=["read", "create", "update", "delete", "query"]) + """The identity that created the resource.""" + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="createdByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that created the resource. Known values are: \"User\", \"Application\", + \"ManagedIdentity\", and \"Key\".""" + created_at: Optional[datetime.datetime] = rest_field( + name="createdAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource creation (UTC).""" + last_modified_by: Optional[str] = rest_field( + name="lastModifiedBy", visibility=["read", "create", "update", "delete", "query"] + ) + """The identity that last modified the resource.""" + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = rest_field( + name="lastModifiedByType", visibility=["read", "create", "update", "delete", "query"] + ) + """The type of identity that last modified the resource. Known values are: \"User\", + \"Application\", \"ManagedIdentity\", and \"Key\".""" + last_modified_at: Optional[datetime.datetime] = rest_field( + name="lastModifiedAt", visibility=["read", "create", "update", "delete", "query"], format="rfc3339" + ) + """The timestamp of resource last modification (UTC).""" + + @overload + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class TrackedResourceModificationDetails(_Model): + """The details of the policy triggered deployment that created or modified the tracked resource. + + :ivar policy_details: The details of the policy that created or modified the tracked resource. + :vartype policy_details: ~azure.mgmt.policyinsights.models.PolicyDetails + :ivar deployment_id: The ID of the deployment that created or modified the tracked resource. + :vartype deployment_id: str + :ivar deployment_time: Timestamp of the deployment that created or modified the tracked + resource. + :vartype deployment_time: ~datetime.datetime + """ + + policy_details: Optional["_models.PolicyDetails"] = rest_field(name="policyDetails", visibility=["read"]) + """The details of the policy that created or modified the tracked resource.""" + deployment_id: Optional[str] = rest_field(name="deploymentId", visibility=["read"]) + """The ID of the deployment that created or modified the tracked resource.""" + deployment_time: Optional[datetime.datetime] = rest_field( + name="deploymentTime", visibility=["read"], format="rfc3339" + ) + """Timestamp of the deployment that created or modified the tracked resource.""" + + +class TypedErrorInfo(_Model): + """Scenario specific error details. + + :ivar type: The type of included error details. + :vartype type: str + :ivar info: The scenario specific error details. + :vartype info: any + """ + + type: Optional[str] = rest_field(visibility=["read"]) + """The type of included error details.""" + info: Optional[Any] = rest_field(visibility=["read"]) + """The scenario specific error details.""" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py deleted file mode 100644 index 6182fe8b057c..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py +++ /dev/null @@ -1,2702 +0,0 @@ -# pylint: disable=too-many-lines -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Optional, TYPE_CHECKING, Union - -from .._utils import serialization as _serialization - -if TYPE_CHECKING: - from .. import models as _models -JSON = MutableMapping[str, Any] - - -class CheckRestrictionsRequest(_serialization.Model): - """The check policy restrictions parameters describing the resource that is being evaluated. - - All required parameters must be populated in order to send to server. - - :ivar resource_details: The information about the resource that will be evaluated. Required. - :vartype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails - :ivar pending_fields: The list of fields and values that should be evaluated for potential - restrictions. - :vartype pending_fields: list[~azure.mgmt.policyinsights.models.PendingField] - """ - - _validation = { - "resource_details": {"required": True}, - } - - _attribute_map = { - "resource_details": {"key": "resourceDetails", "type": "CheckRestrictionsResourceDetails"}, - "pending_fields": {"key": "pendingFields", "type": "[PendingField]"}, - } - - def __init__( - self, - *, - resource_details: "_models.CheckRestrictionsResourceDetails", - pending_fields: Optional[list["_models.PendingField"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword resource_details: The information about the resource that will be evaluated. Required. - :paramtype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails - :keyword pending_fields: The list of fields and values that should be evaluated for potential - restrictions. - :paramtype pending_fields: list[~azure.mgmt.policyinsights.models.PendingField] - """ - super().__init__(**kwargs) - self.resource_details = resource_details - self.pending_fields = pending_fields - - -class CheckRestrictionsResourceDetails(_serialization.Model): - """The information about the resource that will be evaluated. - - All required parameters must be populated in order to send to server. - - :ivar resource_content: The resource content. This should include whatever properties are - already known and can be a partial set of all resource properties. Required. - :vartype resource_content: JSON - :ivar api_version: The api-version of the resource content. - :vartype api_version: str - :ivar scope: The scope where the resource is being created. For example, if the resource is a - child resource this would be the parent resource's resource ID. - :vartype scope: str - """ - - _validation = { - "resource_content": {"required": True}, - } - - _attribute_map = { - "resource_content": {"key": "resourceContent", "type": "object"}, - "api_version": {"key": "apiVersion", "type": "str"}, - "scope": {"key": "scope", "type": "str"}, - } - - def __init__( - self, *, resource_content: JSON, api_version: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword resource_content: The resource content. This should include whatever properties are - already known and can be a partial set of all resource properties. Required. - :paramtype resource_content: JSON - :keyword api_version: The api-version of the resource content. - :paramtype api_version: str - :keyword scope: The scope where the resource is being created. For example, if the resource is - a child resource this would be the parent resource's resource ID. - :paramtype scope: str - """ - super().__init__(**kwargs) - self.resource_content = resource_content - self.api_version = api_version - self.scope = scope - - -class CheckRestrictionsResult(_serialization.Model): - """The result of a check policy restrictions evaluation on a resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar field_restrictions: The restrictions that will be placed on various fields in the - resource by policy. - :vartype field_restrictions: list[~azure.mgmt.policyinsights.models.FieldRestrictions] - :ivar content_evaluation_result: Evaluation results for the provided partial resource content. - :vartype content_evaluation_result: - ~azure.mgmt.policyinsights.models.CheckRestrictionsResultContentEvaluationResult - """ - - _validation = { - "field_restrictions": {"readonly": True}, - "content_evaluation_result": {"readonly": True}, - } - - _attribute_map = { - "field_restrictions": {"key": "fieldRestrictions", "type": "[FieldRestrictions]"}, - "content_evaluation_result": { - "key": "contentEvaluationResult", - "type": "CheckRestrictionsResultContentEvaluationResult", - }, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.field_restrictions: Optional[list["_models.FieldRestrictions"]] = None - self.content_evaluation_result: Optional["_models.CheckRestrictionsResultContentEvaluationResult"] = None - - -class CheckRestrictionsResultContentEvaluationResult(_serialization.Model): # pylint: disable=name-too-long - """Evaluation results for the provided partial resource content. - - :ivar policy_evaluations: Policy evaluation results against the given resource content. This - will indicate if the partial content that was provided will be denied as-is. - :vartype policy_evaluations: list[~azure.mgmt.policyinsights.models.PolicyEvaluationResult] - """ - - _attribute_map = { - "policy_evaluations": {"key": "policyEvaluations", "type": "[PolicyEvaluationResult]"}, - } - - def __init__( - self, *, policy_evaluations: Optional[list["_models.PolicyEvaluationResult"]] = None, **kwargs: Any - ) -> None: - """ - :keyword policy_evaluations: Policy evaluation results against the given resource content. This - will indicate if the partial content that was provided will be denied as-is. - :paramtype policy_evaluations: list[~azure.mgmt.policyinsights.models.PolicyEvaluationResult] - """ - super().__init__(**kwargs) - self.policy_evaluations = policy_evaluations - - -class ComplianceDetail(_serialization.Model): - """The compliance state rollup. - - :ivar compliance_state: The compliance state. - :vartype compliance_state: str - :ivar count: Summarized count value for this compliance state. - :vartype count: int - """ - - _attribute_map = { - "compliance_state": {"key": "complianceState", "type": "str"}, - "count": {"key": "count", "type": "int"}, - } - - def __init__(self, *, compliance_state: Optional[str] = None, count: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword compliance_state: The compliance state. - :paramtype compliance_state: str - :keyword count: Summarized count value for this compliance state. - :paramtype count: int - """ - super().__init__(**kwargs) - self.compliance_state = compliance_state - self.count = count - - -class ComponentEventDetails(_serialization.Model): - """Component event details. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar id: Component Id. - :vartype id: str - :ivar type: Component type. - :vartype type: str - :ivar name: Component name. - :vartype name: str - :ivar timestamp: Timestamp for component policy event record. - :vartype timestamp: ~datetime.datetime - :ivar tenant_id: Tenant ID for the policy event record. - :vartype tenant_id: str - :ivar principal_oid: Principal object ID for the user who initiated the resource component - operation that triggered the policy event. - :vartype principal_oid: str - :ivar policy_definition_action: Policy definition action, i.e. effect. - :vartype policy_definition_action: str - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "principal_oid": {"key": "principalOid", "type": "str"}, - "policy_definition_action": {"key": "policyDefinitionAction", "type": "str"}, - } - - def __init__( - self, - *, - additional_properties: Optional[dict[str, Any]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - type: Optional[str] = None, - name: Optional[str] = None, - timestamp: Optional[datetime.datetime] = None, - tenant_id: Optional[str] = None, - principal_oid: Optional[str] = None, - policy_definition_action: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword id: Component Id. - :paramtype id: str - :keyword type: Component type. - :paramtype type: str - :keyword name: Component name. - :paramtype name: str - :keyword timestamp: Timestamp for component policy event record. - :paramtype timestamp: ~datetime.datetime - :keyword tenant_id: Tenant ID for the policy event record. - :paramtype tenant_id: str - :keyword principal_oid: Principal object ID for the user who initiated the resource component - operation that triggered the policy event. - :paramtype principal_oid: str - :keyword policy_definition_action: Policy definition action, i.e. effect. - :paramtype policy_definition_action: str - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.id = id - self.type = type - self.name = name - self.timestamp = timestamp - self.tenant_id = tenant_id - self.principal_oid = principal_oid - self.policy_definition_action = policy_definition_action - - -class ComponentStateDetails(_serialization.Model): - """Component state details. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar id: Component Id. - :vartype id: str - :ivar type: Component type. - :vartype type: str - :ivar name: Component name. - :vartype name: str - :ivar timestamp: Component compliance evaluation timestamp. - :vartype timestamp: ~datetime.datetime - :ivar compliance_state: Component compliance state. - :vartype compliance_state: str - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "compliance_state": {"key": "complianceState", "type": "str"}, - } - - def __init__( - self, - *, - additional_properties: Optional[dict[str, Any]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - type: Optional[str] = None, - name: Optional[str] = None, - timestamp: Optional[datetime.datetime] = None, - compliance_state: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword id: Component Id. - :paramtype id: str - :keyword type: Component type. - :paramtype type: str - :keyword name: Component name. - :paramtype name: str - :keyword timestamp: Component compliance evaluation timestamp. - :paramtype timestamp: ~datetime.datetime - :keyword compliance_state: Component compliance state. - :paramtype compliance_state: str - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.id = id - self.type = type - self.name = name - self.timestamp = timestamp - self.compliance_state = compliance_state - - -class ErrorDefinition(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar target: The target of the error. - :vartype target: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.policyinsights.models.ErrorDefinition] - :ivar additional_info: Additional scenario specific error details. - :vartype additional_info: list[~azure.mgmt.policyinsights.models.TypedErrorInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinition]"}, - "additional_info": {"key": "additionalInfo", "type": "[TypedErrorInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[list["_models.ErrorDefinition"]] = None - self.additional_info: Optional[list["_models.TypedErrorInfo"]] = None - - -class ErrorDefinitionAutoGenerated(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar target: The target of the error. - :vartype target: str - :ivar details: Internal error details. - :vartype details: list[~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated] - :ivar additional_info: Additional scenario specific error details. - :vartype additional_info: list[~azure.mgmt.policyinsights.models.TypedErrorInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDefinitionAutoGenerated]"}, - "additional_info": {"key": "additionalInfo", "type": "[TypedErrorInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - self.target: Optional[str] = None - self.details: Optional[list["_models.ErrorDefinitionAutoGenerated"]] = None - self.additional_info: Optional[list["_models.TypedErrorInfo"]] = None - - -class ErrorResponse(_serialization.Model): - """Error response. - - :ivar error: The error details. - :vartype error: ~azure.mgmt.policyinsights.models.ErrorDefinition - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinition"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error details. - :paramtype error: ~azure.mgmt.policyinsights.models.ErrorDefinition - """ - super().__init__(**kwargs) - self.error = error - - -class ErrorResponseAutoGenerated(_serialization.Model): - """Error response. - - :ivar error: The error details. - :vartype error: ~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDefinitionAutoGenerated"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDefinitionAutoGenerated"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error details. - :paramtype error: ~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated - """ - super().__init__(**kwargs) - self.error = error - - -class ExpressionEvaluationDetails(_serialization.Model): - """Evaluation details of policy language expressions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar result: Evaluation result. - :vartype result: str - :ivar expression: Expression evaluated. - :vartype expression: str - :ivar expression_kind: The kind of expression that was evaluated. - :vartype expression_kind: str - :ivar path: Property path if the expression is a field or an alias. - :vartype path: str - :ivar expression_value: Value of the expression. - :vartype expression_value: JSON - :ivar target_value: Target value to be compared with the expression value. - :vartype target_value: JSON - :ivar operator: Operator to compare the expression value and the target value. - :vartype operator: str - """ - - _validation = { - "expression_kind": {"readonly": True}, - } - - _attribute_map = { - "result": {"key": "result", "type": "str"}, - "expression": {"key": "expression", "type": "str"}, - "expression_kind": {"key": "expressionKind", "type": "str"}, - "path": {"key": "path", "type": "str"}, - "expression_value": {"key": "expressionValue", "type": "object"}, - "target_value": {"key": "targetValue", "type": "object"}, - "operator": {"key": "operator", "type": "str"}, - } - - def __init__( - self, - *, - result: Optional[str] = None, - expression: Optional[str] = None, - path: Optional[str] = None, - expression_value: Optional[JSON] = None, - target_value: Optional[JSON] = None, - operator: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword result: Evaluation result. - :paramtype result: str - :keyword expression: Expression evaluated. - :paramtype expression: str - :keyword path: Property path if the expression is a field or an alias. - :paramtype path: str - :keyword expression_value: Value of the expression. - :paramtype expression_value: JSON - :keyword target_value: Target value to be compared with the expression value. - :paramtype target_value: JSON - :keyword operator: Operator to compare the expression value and the target value. - :paramtype operator: str - """ - super().__init__(**kwargs) - self.result = result - self.expression = expression - self.expression_kind: Optional[str] = None - self.path = path - self.expression_value = expression_value - self.target_value = target_value - self.operator = operator - - -class FieldRestriction(_serialization.Model): - """The restrictions on a field imposed by a specific policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar result: The type of restriction that is imposed on the field. Known values are: - "Required", "Removed", and "Deny". - :vartype result: str or ~azure.mgmt.policyinsights.models.FieldRestrictionResult - :ivar default_value: The value that policy will set for the field if the user does not provide - a value. - :vartype default_value: str - :ivar values: The values that policy either requires or denies for the field. - :vartype values: list[str] - :ivar policy: The details of the policy that is causing the field restriction. - :vartype policy: ~azure.mgmt.policyinsights.models.PolicyReference - """ - - _validation = { - "result": {"readonly": True}, - "default_value": {"readonly": True}, - "values": {"readonly": True}, - "policy": {"readonly": True}, - } - - _attribute_map = { - "result": {"key": "result", "type": "str"}, - "default_value": {"key": "defaultValue", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - "policy": {"key": "policy", "type": "PolicyReference"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.result: Optional[Union[str, "_models.FieldRestrictionResult"]] = None - self.default_value: Optional[str] = None - self.values: Optional[list[str]] = None - self.policy: Optional["_models.PolicyReference"] = None - - -class FieldRestrictions(_serialization.Model): - """The restrictions that will be placed on a field in the resource by policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar field: The name of the field. This can be a top-level property like 'name' or 'type' or - an Azure Policy field alias. - :vartype field: str - :ivar restrictions: The restrictions placed on that field by policy. - :vartype restrictions: list[~azure.mgmt.policyinsights.models.FieldRestriction] - """ - - _validation = { - "field": {"readonly": True}, - } - - _attribute_map = { - "field": {"key": "field", "type": "str"}, - "restrictions": {"key": "restrictions", "type": "[FieldRestriction]"}, - } - - def __init__(self, *, restrictions: Optional[list["_models.FieldRestriction"]] = None, **kwargs: Any) -> None: - """ - :keyword restrictions: The restrictions placed on that field by policy. - :paramtype restrictions: list[~azure.mgmt.policyinsights.models.FieldRestriction] - """ - super().__init__(**kwargs) - self.field: Optional[str] = None - self.restrictions = restrictions - - -class IfNotExistsEvaluationDetails(_serialization.Model): - """Evaluation details of IfNotExists effect. - - :ivar resource_id: ID of the last evaluated resource for IfNotExists effect. - :vartype resource_id: str - :ivar total_resources: Total number of resources to which the existence condition is - applicable. - :vartype total_resources: int - """ - - _attribute_map = { - "resource_id": {"key": "resourceId", "type": "str"}, - "total_resources": {"key": "totalResources", "type": "int"}, - } - - def __init__( - self, *, resource_id: Optional[str] = None, total_resources: Optional[int] = None, **kwargs: Any - ) -> None: - """ - :keyword resource_id: ID of the last evaluated resource for IfNotExists effect. - :paramtype resource_id: str - :keyword total_resources: Total number of resources to which the existence condition is - applicable. - :paramtype total_resources: int - """ - super().__init__(**kwargs) - self.resource_id = resource_id - self.total_resources = total_resources - - -class Operation(_serialization.Model): - """Operation definition. - - :ivar name: Operation name. - :vartype name: str - :ivar display: Display metadata associated with the operation. - :vartype display: ~azure.mgmt.policyinsights.models.OperationDisplay - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, - } - - def __init__( - self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any - ) -> None: - """ - :keyword name: Operation name. - :paramtype name: str - :keyword display: Display metadata associated with the operation. - :paramtype display: ~azure.mgmt.policyinsights.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = name - self.display = display - - -class OperationDisplay(_serialization.Model): - """Display metadata associated with the operation. - - :ivar provider: Resource provider name. - :vartype provider: str - :ivar resource: Resource name on which the operation is performed. - :vartype resource: str - :ivar operation: Operation name. - :vartype operation: str - :ivar description: Operation description. - :vartype description: str - """ - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__( - self, - *, - provider: Optional[str] = None, - resource: Optional[str] = None, - operation: Optional[str] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword provider: Resource provider name. - :paramtype provider: str - :keyword resource: Resource name on which the operation is performed. - :paramtype resource: str - :keyword operation: Operation name. - :paramtype operation: str - :keyword description: Operation description. - :paramtype description: str - """ - super().__init__(**kwargs) - self.provider = provider - self.resource = resource - self.operation = operation - self.description = description - - -class OperationsListResults(_serialization.Model): - """List of available operations. - - :ivar odata_count: OData entity count; represents the number of operations returned. - :vartype odata_count: int - :ivar value: List of available operations. - :vartype value: list[~azure.mgmt.policyinsights.models.Operation] - """ - - _validation = { - "odata_count": {"minimum": 1}, - } - - _attribute_map = { - "odata_count": {"key": "@odata\\.count", "type": "int"}, - "value": {"key": "value", "type": "[Operation]"}, - } - - def __init__( - self, *, odata_count: Optional[int] = None, value: Optional[list["_models.Operation"]] = None, **kwargs: Any - ) -> None: - """ - :keyword odata_count: OData entity count; represents the number of operations returned. - :paramtype odata_count: int - :keyword value: List of available operations. - :paramtype value: list[~azure.mgmt.policyinsights.models.Operation] - """ - super().__init__(**kwargs) - self.odata_count = odata_count - self.value = value - - -class PendingField(_serialization.Model): - """A field that should be evaluated against Azure Policy to determine restrictions. - - All required parameters must be populated in order to send to server. - - :ivar field: The name of the field. This can be a top-level property like 'name' or 'type' or - an Azure Policy field alias. Required. - :vartype field: str - :ivar values: The list of potential values for the field that should be evaluated against Azure - Policy. - :vartype values: list[str] - """ - - _validation = { - "field": {"required": True}, - } - - _attribute_map = { - "field": {"key": "field", "type": "str"}, - "values": {"key": "values", "type": "[str]"}, - } - - def __init__(self, *, field: str, values: Optional[list[str]] = None, **kwargs: Any) -> None: - """ - :keyword field: The name of the field. This can be a top-level property like 'name' or 'type' - or an Azure Policy field alias. Required. - :paramtype field: str - :keyword values: The list of potential values for the field that should be evaluated against - Azure Policy. - :paramtype values: list[str] - """ - super().__init__(**kwargs) - self.field = field - self.values = values - - -class PolicyAssignmentSummary(_serialization.Model): - """Policy assignment summary. - - :ivar policy_assignment_id: Policy assignment ID. - :vartype policy_assignment_id: str - :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a - policy set. - :vartype policy_set_definition_id: str - :ivar results: Compliance summary for the policy assignment. - :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults - :ivar policy_definitions: Policy definitions summary. - :vartype policy_definitions: list[~azure.mgmt.policyinsights.models.PolicyDefinitionSummary] - :ivar policy_groups: Policy definition group summary. - :vartype policy_groups: list[~azure.mgmt.policyinsights.models.PolicyGroupSummary] - """ - - _attribute_map = { - "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, - "policy_set_definition_id": {"key": "policySetDefinitionId", "type": "str"}, - "results": {"key": "results", "type": "SummaryResults"}, - "policy_definitions": {"key": "policyDefinitions", "type": "[PolicyDefinitionSummary]"}, - "policy_groups": {"key": "policyGroups", "type": "[PolicyGroupSummary]"}, - } - - def __init__( - self, - *, - policy_assignment_id: Optional[str] = None, - policy_set_definition_id: Optional[str] = None, - results: Optional["_models.SummaryResults"] = None, - policy_definitions: Optional[list["_models.PolicyDefinitionSummary"]] = None, - policy_groups: Optional[list["_models.PolicyGroupSummary"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword policy_assignment_id: Policy assignment ID. - :paramtype policy_assignment_id: str - :keyword policy_set_definition_id: Policy set definition ID, if the policy assignment is for a - policy set. - :paramtype policy_set_definition_id: str - :keyword results: Compliance summary for the policy assignment. - :paramtype results: ~azure.mgmt.policyinsights.models.SummaryResults - :keyword policy_definitions: Policy definitions summary. - :paramtype policy_definitions: list[~azure.mgmt.policyinsights.models.PolicyDefinitionSummary] - :keyword policy_groups: Policy definition group summary. - :paramtype policy_groups: list[~azure.mgmt.policyinsights.models.PolicyGroupSummary] - """ - super().__init__(**kwargs) - self.policy_assignment_id = policy_assignment_id - self.policy_set_definition_id = policy_set_definition_id - self.results = results - self.policy_definitions = policy_definitions - self.policy_groups = policy_groups - - -class PolicyDefinitionSummary(_serialization.Model): - """Policy definition summary. - - :ivar policy_definition_id: Policy definition ID. - :vartype policy_definition_id: str - :ivar policy_definition_reference_id: Policy definition reference ID. - :vartype policy_definition_reference_id: str - :ivar policy_definition_group_names: Policy definition group names. - :vartype policy_definition_group_names: list[str] - :ivar effect: Policy effect, i.e. policy definition action. - :vartype effect: str - :ivar results: Compliance summary for the policy definition. - :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults - """ - - _attribute_map = { - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, - "policy_definition_group_names": {"key": "policyDefinitionGroupNames", "type": "[str]"}, - "effect": {"key": "effect", "type": "str"}, - "results": {"key": "results", "type": "SummaryResults"}, - } - - def __init__( - self, - *, - policy_definition_id: Optional[str] = None, - policy_definition_reference_id: Optional[str] = None, - policy_definition_group_names: Optional[list[str]] = None, - effect: Optional[str] = None, - results: Optional["_models.SummaryResults"] = None, - **kwargs: Any - ) -> None: - """ - :keyword policy_definition_id: Policy definition ID. - :paramtype policy_definition_id: str - :keyword policy_definition_reference_id: Policy definition reference ID. - :paramtype policy_definition_reference_id: str - :keyword policy_definition_group_names: Policy definition group names. - :paramtype policy_definition_group_names: list[str] - :keyword effect: Policy effect, i.e. policy definition action. - :paramtype effect: str - :keyword results: Compliance summary for the policy definition. - :paramtype results: ~azure.mgmt.policyinsights.models.SummaryResults - """ - super().__init__(**kwargs) - self.policy_definition_id = policy_definition_id - self.policy_definition_reference_id = policy_definition_reference_id - self.policy_definition_group_names = policy_definition_group_names - self.effect = effect - self.results = results - - -class PolicyDetails(_serialization.Model): - """The policy details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar policy_definition_id: The ID of the policy definition. - :vartype policy_definition_id: str - :ivar policy_assignment_id: The ID of the policy assignment. - :vartype policy_assignment_id: str - :ivar policy_assignment_display_name: The display name of the policy assignment. - :vartype policy_assignment_display_name: str - :ivar policy_assignment_scope: The scope of the policy assignment. - :vartype policy_assignment_scope: str - :ivar policy_set_definition_id: The ID of the policy set definition. - :vartype policy_set_definition_id: str - :ivar policy_definition_reference_id: The policy definition reference ID within the policy set - definition. - :vartype policy_definition_reference_id: str - """ - - _validation = { - "policy_definition_id": {"readonly": True}, - "policy_assignment_id": {"readonly": True}, - "policy_assignment_display_name": {"readonly": True}, - "policy_assignment_scope": {"readonly": True}, - "policy_set_definition_id": {"readonly": True}, - "policy_definition_reference_id": {"readonly": True}, - } - - _attribute_map = { - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, - "policy_assignment_display_name": {"key": "policyAssignmentDisplayName", "type": "str"}, - "policy_assignment_scope": {"key": "policyAssignmentScope", "type": "str"}, - "policy_set_definition_id": {"key": "policySetDefinitionId", "type": "str"}, - "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.policy_definition_id: Optional[str] = None - self.policy_assignment_id: Optional[str] = None - self.policy_assignment_display_name: Optional[str] = None - self.policy_assignment_scope: Optional[str] = None - self.policy_set_definition_id: Optional[str] = None - self.policy_definition_reference_id: Optional[str] = None - - -class PolicyEvaluationDetails(_serialization.Model): - """Policy evaluation details. - - :ivar evaluated_expressions: Details of the evaluated expressions. - :vartype evaluated_expressions: - list[~azure.mgmt.policyinsights.models.ExpressionEvaluationDetails] - :ivar if_not_exists_details: Evaluation details of IfNotExists effect. - :vartype if_not_exists_details: ~azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails - """ - - _attribute_map = { - "evaluated_expressions": {"key": "evaluatedExpressions", "type": "[ExpressionEvaluationDetails]"}, - "if_not_exists_details": {"key": "ifNotExistsDetails", "type": "IfNotExistsEvaluationDetails"}, - } - - def __init__( - self, - *, - evaluated_expressions: Optional[list["_models.ExpressionEvaluationDetails"]] = None, - if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = None, - **kwargs: Any - ) -> None: - """ - :keyword evaluated_expressions: Details of the evaluated expressions. - :paramtype evaluated_expressions: - list[~azure.mgmt.policyinsights.models.ExpressionEvaluationDetails] - :keyword if_not_exists_details: Evaluation details of IfNotExists effect. - :paramtype if_not_exists_details: - ~azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails - """ - super().__init__(**kwargs) - self.evaluated_expressions = evaluated_expressions - self.if_not_exists_details = if_not_exists_details - - -class PolicyEvaluationResult(_serialization.Model): - """The result of a non-compliant policy evaluation against the given resource content. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar policy_info: The details of the policy that was evaluated. - :vartype policy_info: ~azure.mgmt.policyinsights.models.PolicyReference - :ivar evaluation_result: The result of the policy evaluation against the resource. This will - typically be 'NonCompliant' but may contain other values if errors were encountered. - :vartype evaluation_result: str - :ivar evaluation_details: The detailed results of the policy expressions and values that were - evaluated. - :vartype evaluation_details: ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails - """ - - _validation = { - "policy_info": {"readonly": True}, - "evaluation_result": {"readonly": True}, - "evaluation_details": {"readonly": True}, - } - - _attribute_map = { - "policy_info": {"key": "policyInfo", "type": "PolicyReference"}, - "evaluation_result": {"key": "evaluationResult", "type": "str"}, - "evaluation_details": {"key": "evaluationDetails", "type": "PolicyEvaluationDetails"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.policy_info: Optional["_models.PolicyReference"] = None - self.evaluation_result: Optional[str] = None - self.evaluation_details: Optional["_models.PolicyEvaluationDetails"] = None - - -class PolicyEvent(_serialization.Model): - """Policy event record. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar odata_id: OData entity ID; always set to null since policy event records do not have an - entity ID. - :vartype odata_id: str - :ivar odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :vartype odata_context: str - :ivar timestamp: Timestamp for the policy event record. - :vartype timestamp: ~datetime.datetime - :ivar resource_id: Resource ID. - :vartype resource_id: str - :ivar policy_assignment_id: Policy assignment ID. - :vartype policy_assignment_id: str - :ivar policy_definition_id: Policy definition ID. - :vartype policy_definition_id: str - :ivar effective_parameters: Effective parameters for the policy assignment. - :vartype effective_parameters: str - :ivar is_compliant: Flag which states whether the resource is compliant against the policy - assignment it was evaluated against. - :vartype is_compliant: bool - :ivar subscription_id: Subscription ID. - :vartype subscription_id: str - :ivar resource_type: Resource type. - :vartype resource_type: str - :ivar resource_location: Resource location. - :vartype resource_location: str - :ivar resource_group: Resource group name. - :vartype resource_group: str - :ivar resource_tags: List of resource tags. - :vartype resource_tags: str - :ivar policy_assignment_name: Policy assignment name. - :vartype policy_assignment_name: str - :ivar policy_assignment_owner: Policy assignment owner. - :vartype policy_assignment_owner: str - :ivar policy_assignment_parameters: Policy assignment parameters. - :vartype policy_assignment_parameters: str - :ivar policy_assignment_scope: Policy assignment scope. - :vartype policy_assignment_scope: str - :ivar policy_definition_name: Policy definition name. - :vartype policy_definition_name: str - :ivar policy_definition_action: Policy definition action, i.e. effect. - :vartype policy_definition_action: str - :ivar policy_definition_category: Policy definition category. - :vartype policy_definition_category: str - :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a - policy set. - :vartype policy_set_definition_id: str - :ivar policy_set_definition_name: Policy set definition name, if the policy assignment is for a - policy set. - :vartype policy_set_definition_name: str - :ivar policy_set_definition_owner: Policy set definition owner, if the policy assignment is for - a policy set. - :vartype policy_set_definition_owner: str - :ivar policy_set_definition_category: Policy set definition category, if the policy assignment - is for a policy set. - :vartype policy_set_definition_category: str - :ivar policy_set_definition_parameters: Policy set definition parameters, if the policy - assignment is for a policy set. - :vartype policy_set_definition_parameters: str - :ivar management_group_ids: Comma separated list of management group IDs, which represent the - hierarchy of the management groups the resource is under. - :vartype management_group_ids: str - :ivar policy_definition_reference_id: Reference ID for the policy definition inside the policy - set, if the policy assignment is for a policy set. - :vartype policy_definition_reference_id: str - :ivar compliance_state: Compliance state of the resource. - :vartype compliance_state: str - :ivar tenant_id: Tenant ID for the policy event record. - :vartype tenant_id: str - :ivar principal_oid: Principal object ID for the user who initiated the resource operation that - triggered the policy event. - :vartype principal_oid: str - :ivar components: Components events records populated only when URL contains $expand=components - clause. - :vartype components: list[~azure.mgmt.policyinsights.models.ComponentEventDetails] - """ - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "odata_id": {"key": "@odata\\.id", "type": "str"}, - "odata_context": {"key": "@odata\\.context", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "effective_parameters": {"key": "effectiveParameters", "type": "str"}, - "is_compliant": {"key": "isCompliant", "type": "bool"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_type": {"key": "resourceType", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - "resource_tags": {"key": "resourceTags", "type": "str"}, - "policy_assignment_name": {"key": "policyAssignmentName", "type": "str"}, - "policy_assignment_owner": {"key": "policyAssignmentOwner", "type": "str"}, - "policy_assignment_parameters": {"key": "policyAssignmentParameters", "type": "str"}, - "policy_assignment_scope": {"key": "policyAssignmentScope", "type": "str"}, - "policy_definition_name": {"key": "policyDefinitionName", "type": "str"}, - "policy_definition_action": {"key": "policyDefinitionAction", "type": "str"}, - "policy_definition_category": {"key": "policyDefinitionCategory", "type": "str"}, - "policy_set_definition_id": {"key": "policySetDefinitionId", "type": "str"}, - "policy_set_definition_name": {"key": "policySetDefinitionName", "type": "str"}, - "policy_set_definition_owner": {"key": "policySetDefinitionOwner", "type": "str"}, - "policy_set_definition_category": {"key": "policySetDefinitionCategory", "type": "str"}, - "policy_set_definition_parameters": {"key": "policySetDefinitionParameters", "type": "str"}, - "management_group_ids": {"key": "managementGroupIds", "type": "str"}, - "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, - "compliance_state": {"key": "complianceState", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, - "principal_oid": {"key": "principalOid", "type": "str"}, - "components": {"key": "components", "type": "[ComponentEventDetails]"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - additional_properties: Optional[dict[str, Any]] = None, - odata_id: Optional[str] = None, - odata_context: Optional[str] = None, - timestamp: Optional[datetime.datetime] = None, - resource_id: Optional[str] = None, - policy_assignment_id: Optional[str] = None, - policy_definition_id: Optional[str] = None, - effective_parameters: Optional[str] = None, - is_compliant: Optional[bool] = None, - subscription_id: Optional[str] = None, - resource_type: Optional[str] = None, - resource_location: Optional[str] = None, - resource_group: Optional[str] = None, - resource_tags: Optional[str] = None, - policy_assignment_name: Optional[str] = None, - policy_assignment_owner: Optional[str] = None, - policy_assignment_parameters: Optional[str] = None, - policy_assignment_scope: Optional[str] = None, - policy_definition_name: Optional[str] = None, - policy_definition_action: Optional[str] = None, - policy_definition_category: Optional[str] = None, - policy_set_definition_id: Optional[str] = None, - policy_set_definition_name: Optional[str] = None, - policy_set_definition_owner: Optional[str] = None, - policy_set_definition_category: Optional[str] = None, - policy_set_definition_parameters: Optional[str] = None, - management_group_ids: Optional[str] = None, - policy_definition_reference_id: Optional[str] = None, - compliance_state: Optional[str] = None, - tenant_id: Optional[str] = None, - principal_oid: Optional[str] = None, - components: Optional[list["_models.ComponentEventDetails"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword odata_id: OData entity ID; always set to null since policy event records do not have - an entity ID. - :paramtype odata_id: str - :keyword odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :paramtype odata_context: str - :keyword timestamp: Timestamp for the policy event record. - :paramtype timestamp: ~datetime.datetime - :keyword resource_id: Resource ID. - :paramtype resource_id: str - :keyword policy_assignment_id: Policy assignment ID. - :paramtype policy_assignment_id: str - :keyword policy_definition_id: Policy definition ID. - :paramtype policy_definition_id: str - :keyword effective_parameters: Effective parameters for the policy assignment. - :paramtype effective_parameters: str - :keyword is_compliant: Flag which states whether the resource is compliant against the policy - assignment it was evaluated against. - :paramtype is_compliant: bool - :keyword subscription_id: Subscription ID. - :paramtype subscription_id: str - :keyword resource_type: Resource type. - :paramtype resource_type: str - :keyword resource_location: Resource location. - :paramtype resource_location: str - :keyword resource_group: Resource group name. - :paramtype resource_group: str - :keyword resource_tags: List of resource tags. - :paramtype resource_tags: str - :keyword policy_assignment_name: Policy assignment name. - :paramtype policy_assignment_name: str - :keyword policy_assignment_owner: Policy assignment owner. - :paramtype policy_assignment_owner: str - :keyword policy_assignment_parameters: Policy assignment parameters. - :paramtype policy_assignment_parameters: str - :keyword policy_assignment_scope: Policy assignment scope. - :paramtype policy_assignment_scope: str - :keyword policy_definition_name: Policy definition name. - :paramtype policy_definition_name: str - :keyword policy_definition_action: Policy definition action, i.e. effect. - :paramtype policy_definition_action: str - :keyword policy_definition_category: Policy definition category. - :paramtype policy_definition_category: str - :keyword policy_set_definition_id: Policy set definition ID, if the policy assignment is for a - policy set. - :paramtype policy_set_definition_id: str - :keyword policy_set_definition_name: Policy set definition name, if the policy assignment is - for a policy set. - :paramtype policy_set_definition_name: str - :keyword policy_set_definition_owner: Policy set definition owner, if the policy assignment is - for a policy set. - :paramtype policy_set_definition_owner: str - :keyword policy_set_definition_category: Policy set definition category, if the policy - assignment is for a policy set. - :paramtype policy_set_definition_category: str - :keyword policy_set_definition_parameters: Policy set definition parameters, if the policy - assignment is for a policy set. - :paramtype policy_set_definition_parameters: str - :keyword management_group_ids: Comma separated list of management group IDs, which represent - the hierarchy of the management groups the resource is under. - :paramtype management_group_ids: str - :keyword policy_definition_reference_id: Reference ID for the policy definition inside the - policy set, if the policy assignment is for a policy set. - :paramtype policy_definition_reference_id: str - :keyword compliance_state: Compliance state of the resource. - :paramtype compliance_state: str - :keyword tenant_id: Tenant ID for the policy event record. - :paramtype tenant_id: str - :keyword principal_oid: Principal object ID for the user who initiated the resource operation - that triggered the policy event. - :paramtype principal_oid: str - :keyword components: Components events records populated only when URL contains - $expand=components clause. - :paramtype components: list[~azure.mgmt.policyinsights.models.ComponentEventDetails] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.odata_id = odata_id - self.odata_context = odata_context - self.timestamp = timestamp - self.resource_id = resource_id - self.policy_assignment_id = policy_assignment_id - self.policy_definition_id = policy_definition_id - self.effective_parameters = effective_parameters - self.is_compliant = is_compliant - self.subscription_id = subscription_id - self.resource_type = resource_type - self.resource_location = resource_location - self.resource_group = resource_group - self.resource_tags = resource_tags - self.policy_assignment_name = policy_assignment_name - self.policy_assignment_owner = policy_assignment_owner - self.policy_assignment_parameters = policy_assignment_parameters - self.policy_assignment_scope = policy_assignment_scope - self.policy_definition_name = policy_definition_name - self.policy_definition_action = policy_definition_action - self.policy_definition_category = policy_definition_category - self.policy_set_definition_id = policy_set_definition_id - self.policy_set_definition_name = policy_set_definition_name - self.policy_set_definition_owner = policy_set_definition_owner - self.policy_set_definition_category = policy_set_definition_category - self.policy_set_definition_parameters = policy_set_definition_parameters - self.management_group_ids = management_group_ids - self.policy_definition_reference_id = policy_definition_reference_id - self.compliance_state = compliance_state - self.tenant_id = tenant_id - self.principal_oid = principal_oid - self.components = components - - -class PolicyEventsQueryResults(_serialization.Model): - """Query results. - - :ivar odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :vartype odata_context: str - :ivar odata_count: OData entity count; represents the number of policy event records returned. - :vartype odata_count: int - :ivar odata_next_link: Odata next link; URL to get the next set of results. - :vartype odata_next_link: str - :ivar value: Query results. - :vartype value: list[~azure.mgmt.policyinsights.models.PolicyEvent] - """ - - _validation = { - "odata_count": {"minimum": 0}, - } - - _attribute_map = { - "odata_context": {"key": "@odata\\.context", "type": "str"}, - "odata_count": {"key": "@odata\\.count", "type": "int"}, - "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, - "value": {"key": "value", "type": "[PolicyEvent]"}, - } - - def __init__( - self, - *, - odata_context: Optional[str] = None, - odata_count: Optional[int] = None, - odata_next_link: Optional[str] = None, - value: Optional[list["_models.PolicyEvent"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :paramtype odata_context: str - :keyword odata_count: OData entity count; represents the number of policy event records - returned. - :paramtype odata_count: int - :keyword odata_next_link: Odata next link; URL to get the next set of results. - :paramtype odata_next_link: str - :keyword value: Query results. - :paramtype value: list[~azure.mgmt.policyinsights.models.PolicyEvent] - """ - super().__init__(**kwargs) - self.odata_context = odata_context - self.odata_count = odata_count - self.odata_next_link = odata_next_link - self.value = value - - -class PolicyGroupSummary(_serialization.Model): - """Policy definition group summary. - - :ivar policy_group_name: Policy group name. - :vartype policy_group_name: str - :ivar results: Compliance summary for the policy definition group. - :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults - """ - - _attribute_map = { - "policy_group_name": {"key": "policyGroupName", "type": "str"}, - "results": {"key": "results", "type": "SummaryResults"}, - } - - def __init__( - self, - *, - policy_group_name: Optional[str] = None, - results: Optional["_models.SummaryResults"] = None, - **kwargs: Any - ) -> None: - """ - :keyword policy_group_name: Policy group name. - :paramtype policy_group_name: str - :keyword results: Compliance summary for the policy definition group. - :paramtype results: ~azure.mgmt.policyinsights.models.SummaryResults - """ - super().__init__(**kwargs) - self.policy_group_name = policy_group_name - self.results = results - - -class PolicyMetadata(_serialization.Model): - """Policy metadata resource definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ID of the policy metadata. - :vartype id: str - :ivar type: The type of the policy metadata. - :vartype type: str - :ivar name: The name of the policy metadata. - :vartype name: str - :ivar metadata_id: The policy metadata identifier. - :vartype metadata_id: str - :ivar category: The category of the policy metadata. - :vartype category: str - :ivar title: The title of the policy metadata. - :vartype title: str - :ivar owner: The owner of the policy metadata. - :vartype owner: str - :ivar additional_content_url: Url for getting additional content about the resource metadata. - :vartype additional_content_url: str - :ivar metadata: Additional metadata. - :vartype metadata: JSON - :ivar description: The description of the policy metadata. - :vartype description: str - :ivar requirements: The requirements of the policy metadata. - :vartype requirements: str - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "name": {"readonly": True}, - "metadata_id": {"readonly": True}, - "category": {"readonly": True}, - "title": {"readonly": True}, - "owner": {"readonly": True}, - "additional_content_url": {"readonly": True}, - "metadata": {"readonly": True}, - "description": {"readonly": True}, - "requirements": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "metadata_id": {"key": "properties.metadataId", "type": "str"}, - "category": {"key": "properties.category", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "owner": {"key": "properties.owner", "type": "str"}, - "additional_content_url": {"key": "properties.additionalContentUrl", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "object"}, - "description": {"key": "properties.description", "type": "str"}, - "requirements": {"key": "properties.requirements", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.type: Optional[str] = None - self.name: Optional[str] = None - self.metadata_id: Optional[str] = None - self.category: Optional[str] = None - self.title: Optional[str] = None - self.owner: Optional[str] = None - self.additional_content_url: Optional[str] = None - self.metadata: Optional[JSON] = None - self.description: Optional[str] = None - self.requirements: Optional[str] = None - - -class PolicyMetadataCollection(_serialization.Model): - """Collection of policy metadata resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of policy metadata definitions. - :vartype value: list[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[SlimPolicyMetadata]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.SlimPolicyMetadata"]] = None - self.next_link: Optional[str] = None - - -class PolicyMetadataSlimProperties(_serialization.Model): - """The properties of the policy metadata, excluding properties containing large strings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar metadata_id: The policy metadata identifier. - :vartype metadata_id: str - :ivar category: The category of the policy metadata. - :vartype category: str - :ivar title: The title of the policy metadata. - :vartype title: str - :ivar owner: The owner of the policy metadata. - :vartype owner: str - :ivar additional_content_url: Url for getting additional content about the resource metadata. - :vartype additional_content_url: str - :ivar metadata: Additional metadata. - :vartype metadata: JSON - """ - - _validation = { - "metadata_id": {"readonly": True}, - "category": {"readonly": True}, - "title": {"readonly": True}, - "owner": {"readonly": True}, - "additional_content_url": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "metadata_id": {"key": "metadataId", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "owner": {"key": "owner", "type": "str"}, - "additional_content_url": {"key": "additionalContentUrl", "type": "str"}, - "metadata": {"key": "metadata", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.metadata_id: Optional[str] = None - self.category: Optional[str] = None - self.title: Optional[str] = None - self.owner: Optional[str] = None - self.additional_content_url: Optional[str] = None - self.metadata: Optional[JSON] = None - - -class PolicyMetadataProperties(PolicyMetadataSlimProperties): - """The properties of the policy metadata. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar metadata_id: The policy metadata identifier. - :vartype metadata_id: str - :ivar category: The category of the policy metadata. - :vartype category: str - :ivar title: The title of the policy metadata. - :vartype title: str - :ivar owner: The owner of the policy metadata. - :vartype owner: str - :ivar additional_content_url: Url for getting additional content about the resource metadata. - :vartype additional_content_url: str - :ivar metadata: Additional metadata. - :vartype metadata: JSON - :ivar description: The description of the policy metadata. - :vartype description: str - :ivar requirements: The requirements of the policy metadata. - :vartype requirements: str - """ - - _validation = { - "metadata_id": {"readonly": True}, - "category": {"readonly": True}, - "title": {"readonly": True}, - "owner": {"readonly": True}, - "additional_content_url": {"readonly": True}, - "metadata": {"readonly": True}, - "description": {"readonly": True}, - "requirements": {"readonly": True}, - } - - _attribute_map = { - "metadata_id": {"key": "metadataId", "type": "str"}, - "category": {"key": "category", "type": "str"}, - "title": {"key": "title", "type": "str"}, - "owner": {"key": "owner", "type": "str"}, - "additional_content_url": {"key": "additionalContentUrl", "type": "str"}, - "metadata": {"key": "metadata", "type": "object"}, - "description": {"key": "description", "type": "str"}, - "requirements": {"key": "requirements", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.description: Optional[str] = None - self.requirements: Optional[str] = None - - -class PolicyReference(_serialization.Model): - """Resource identifiers for a policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar policy_definition_id: The resource identifier of the policy definition. - :vartype policy_definition_id: str - :ivar policy_set_definition_id: The resource identifier of the policy set definition. - :vartype policy_set_definition_id: str - :ivar policy_definition_reference_id: The reference identifier of a specific policy definition - within a policy set definition. - :vartype policy_definition_reference_id: str - :ivar policy_assignment_id: The resource identifier of the policy assignment. - :vartype policy_assignment_id: str - """ - - _validation = { - "policy_definition_id": {"readonly": True}, - "policy_set_definition_id": {"readonly": True}, - "policy_definition_reference_id": {"readonly": True}, - "policy_assignment_id": {"readonly": True}, - } - - _attribute_map = { - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "policy_set_definition_id": {"key": "policySetDefinitionId", "type": "str"}, - "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, - "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.policy_definition_id: Optional[str] = None - self.policy_set_definition_id: Optional[str] = None - self.policy_definition_reference_id: Optional[str] = None - self.policy_assignment_id: Optional[str] = None - - -class PolicyState(_serialization.Model): - """Policy state record. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar additional_properties: Unmatched properties from the message are deserialized to this - collection. - :vartype additional_properties: dict[str, any] - :ivar odata_id: OData entity ID; always set to null since policy state records do not have an - entity ID. - :vartype odata_id: str - :ivar odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :vartype odata_context: str - :ivar timestamp: Timestamp for the policy state record. - :vartype timestamp: ~datetime.datetime - :ivar resource_id: Resource ID. - :vartype resource_id: str - :ivar policy_assignment_id: Policy assignment ID. - :vartype policy_assignment_id: str - :ivar policy_definition_id: Policy definition ID. - :vartype policy_definition_id: str - :ivar effective_parameters: Effective parameters for the policy assignment. - :vartype effective_parameters: str - :ivar is_compliant: Flag which states whether the resource is compliant against the policy - assignment it was evaluated against. This property is deprecated; please use ComplianceState - instead. - :vartype is_compliant: bool - :ivar subscription_id: Subscription ID. - :vartype subscription_id: str - :ivar resource_type: Resource type. - :vartype resource_type: str - :ivar resource_location: Resource location. - :vartype resource_location: str - :ivar resource_group: Resource group name. - :vartype resource_group: str - :ivar resource_tags: List of resource tags. - :vartype resource_tags: str - :ivar policy_assignment_name: Policy assignment name. - :vartype policy_assignment_name: str - :ivar policy_assignment_owner: Policy assignment owner. - :vartype policy_assignment_owner: str - :ivar policy_assignment_parameters: Policy assignment parameters. - :vartype policy_assignment_parameters: str - :ivar policy_assignment_scope: Policy assignment scope. - :vartype policy_assignment_scope: str - :ivar policy_definition_name: Policy definition name. - :vartype policy_definition_name: str - :ivar policy_definition_action: Policy definition action, i.e. effect. - :vartype policy_definition_action: str - :ivar policy_definition_category: Policy definition category. - :vartype policy_definition_category: str - :ivar policy_set_definition_id: Policy set definition ID, if the policy assignment is for a - policy set. - :vartype policy_set_definition_id: str - :ivar policy_set_definition_name: Policy set definition name, if the policy assignment is for a - policy set. - :vartype policy_set_definition_name: str - :ivar policy_set_definition_owner: Policy set definition owner, if the policy assignment is for - a policy set. - :vartype policy_set_definition_owner: str - :ivar policy_set_definition_category: Policy set definition category, if the policy assignment - is for a policy set. - :vartype policy_set_definition_category: str - :ivar policy_set_definition_parameters: Policy set definition parameters, if the policy - assignment is for a policy set. - :vartype policy_set_definition_parameters: str - :ivar management_group_ids: Comma separated list of management group IDs, which represent the - hierarchy of the management groups the resource is under. - :vartype management_group_ids: str - :ivar policy_definition_reference_id: Reference ID for the policy definition inside the policy - set, if the policy assignment is for a policy set. - :vartype policy_definition_reference_id: str - :ivar compliance_state: Compliance state of the resource. - :vartype compliance_state: str - :ivar policy_evaluation_details: Policy evaluation details. - :vartype policy_evaluation_details: ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails - :ivar policy_definition_group_names: Policy definition group names. - :vartype policy_definition_group_names: list[str] - :ivar components: Components state compliance records populated only when URL contains - $expand=components clause. - :vartype components: list[~azure.mgmt.policyinsights.models.ComponentStateDetails] - :ivar policy_definition_version: Evaluated policy definition version. - :vartype policy_definition_version: str - :ivar policy_set_definition_version: Evaluated policy set definition version. - :vartype policy_set_definition_version: str - :ivar policy_assignment_version: Evaluated policy assignment version. - :vartype policy_assignment_version: str - """ - - _validation = { - "policy_definition_version": {"readonly": True}, - "policy_set_definition_version": {"readonly": True}, - "policy_assignment_version": {"readonly": True}, - } - - _attribute_map = { - "additional_properties": {"key": "", "type": "{object}"}, - "odata_id": {"key": "@odata\\.id", "type": "str"}, - "odata_context": {"key": "@odata\\.context", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "resource_id": {"key": "resourceId", "type": "str"}, - "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, - "policy_definition_id": {"key": "policyDefinitionId", "type": "str"}, - "effective_parameters": {"key": "effectiveParameters", "type": "str"}, - "is_compliant": {"key": "isCompliant", "type": "bool"}, - "subscription_id": {"key": "subscriptionId", "type": "str"}, - "resource_type": {"key": "resourceType", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "resource_group": {"key": "resourceGroup", "type": "str"}, - "resource_tags": {"key": "resourceTags", "type": "str"}, - "policy_assignment_name": {"key": "policyAssignmentName", "type": "str"}, - "policy_assignment_owner": {"key": "policyAssignmentOwner", "type": "str"}, - "policy_assignment_parameters": {"key": "policyAssignmentParameters", "type": "str"}, - "policy_assignment_scope": {"key": "policyAssignmentScope", "type": "str"}, - "policy_definition_name": {"key": "policyDefinitionName", "type": "str"}, - "policy_definition_action": {"key": "policyDefinitionAction", "type": "str"}, - "policy_definition_category": {"key": "policyDefinitionCategory", "type": "str"}, - "policy_set_definition_id": {"key": "policySetDefinitionId", "type": "str"}, - "policy_set_definition_name": {"key": "policySetDefinitionName", "type": "str"}, - "policy_set_definition_owner": {"key": "policySetDefinitionOwner", "type": "str"}, - "policy_set_definition_category": {"key": "policySetDefinitionCategory", "type": "str"}, - "policy_set_definition_parameters": {"key": "policySetDefinitionParameters", "type": "str"}, - "management_group_ids": {"key": "managementGroupIds", "type": "str"}, - "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, - "compliance_state": {"key": "complianceState", "type": "str"}, - "policy_evaluation_details": {"key": "policyEvaluationDetails", "type": "PolicyEvaluationDetails"}, - "policy_definition_group_names": {"key": "policyDefinitionGroupNames", "type": "[str]"}, - "components": {"key": "components", "type": "[ComponentStateDetails]"}, - "policy_definition_version": {"key": "policyDefinitionVersion", "type": "str"}, - "policy_set_definition_version": {"key": "policySetDefinitionVersion", "type": "str"}, - "policy_assignment_version": {"key": "policyAssignmentVersion", "type": "str"}, - } - - def __init__( # pylint: disable=too-many-locals - self, - *, - additional_properties: Optional[dict[str, Any]] = None, - odata_id: Optional[str] = None, - odata_context: Optional[str] = None, - timestamp: Optional[datetime.datetime] = None, - resource_id: Optional[str] = None, - policy_assignment_id: Optional[str] = None, - policy_definition_id: Optional[str] = None, - effective_parameters: Optional[str] = None, - is_compliant: Optional[bool] = None, - subscription_id: Optional[str] = None, - resource_type: Optional[str] = None, - resource_location: Optional[str] = None, - resource_group: Optional[str] = None, - resource_tags: Optional[str] = None, - policy_assignment_name: Optional[str] = None, - policy_assignment_owner: Optional[str] = None, - policy_assignment_parameters: Optional[str] = None, - policy_assignment_scope: Optional[str] = None, - policy_definition_name: Optional[str] = None, - policy_definition_action: Optional[str] = None, - policy_definition_category: Optional[str] = None, - policy_set_definition_id: Optional[str] = None, - policy_set_definition_name: Optional[str] = None, - policy_set_definition_owner: Optional[str] = None, - policy_set_definition_category: Optional[str] = None, - policy_set_definition_parameters: Optional[str] = None, - management_group_ids: Optional[str] = None, - policy_definition_reference_id: Optional[str] = None, - compliance_state: Optional[str] = None, - policy_evaluation_details: Optional["_models.PolicyEvaluationDetails"] = None, - policy_definition_group_names: Optional[list[str]] = None, - components: Optional[list["_models.ComponentStateDetails"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword additional_properties: Unmatched properties from the message are deserialized to this - collection. - :paramtype additional_properties: dict[str, any] - :keyword odata_id: OData entity ID; always set to null since policy state records do not have - an entity ID. - :paramtype odata_id: str - :keyword odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :paramtype odata_context: str - :keyword timestamp: Timestamp for the policy state record. - :paramtype timestamp: ~datetime.datetime - :keyword resource_id: Resource ID. - :paramtype resource_id: str - :keyword policy_assignment_id: Policy assignment ID. - :paramtype policy_assignment_id: str - :keyword policy_definition_id: Policy definition ID. - :paramtype policy_definition_id: str - :keyword effective_parameters: Effective parameters for the policy assignment. - :paramtype effective_parameters: str - :keyword is_compliant: Flag which states whether the resource is compliant against the policy - assignment it was evaluated against. This property is deprecated; please use ComplianceState - instead. - :paramtype is_compliant: bool - :keyword subscription_id: Subscription ID. - :paramtype subscription_id: str - :keyword resource_type: Resource type. - :paramtype resource_type: str - :keyword resource_location: Resource location. - :paramtype resource_location: str - :keyword resource_group: Resource group name. - :paramtype resource_group: str - :keyword resource_tags: List of resource tags. - :paramtype resource_tags: str - :keyword policy_assignment_name: Policy assignment name. - :paramtype policy_assignment_name: str - :keyword policy_assignment_owner: Policy assignment owner. - :paramtype policy_assignment_owner: str - :keyword policy_assignment_parameters: Policy assignment parameters. - :paramtype policy_assignment_parameters: str - :keyword policy_assignment_scope: Policy assignment scope. - :paramtype policy_assignment_scope: str - :keyword policy_definition_name: Policy definition name. - :paramtype policy_definition_name: str - :keyword policy_definition_action: Policy definition action, i.e. effect. - :paramtype policy_definition_action: str - :keyword policy_definition_category: Policy definition category. - :paramtype policy_definition_category: str - :keyword policy_set_definition_id: Policy set definition ID, if the policy assignment is for a - policy set. - :paramtype policy_set_definition_id: str - :keyword policy_set_definition_name: Policy set definition name, if the policy assignment is - for a policy set. - :paramtype policy_set_definition_name: str - :keyword policy_set_definition_owner: Policy set definition owner, if the policy assignment is - for a policy set. - :paramtype policy_set_definition_owner: str - :keyword policy_set_definition_category: Policy set definition category, if the policy - assignment is for a policy set. - :paramtype policy_set_definition_category: str - :keyword policy_set_definition_parameters: Policy set definition parameters, if the policy - assignment is for a policy set. - :paramtype policy_set_definition_parameters: str - :keyword management_group_ids: Comma separated list of management group IDs, which represent - the hierarchy of the management groups the resource is under. - :paramtype management_group_ids: str - :keyword policy_definition_reference_id: Reference ID for the policy definition inside the - policy set, if the policy assignment is for a policy set. - :paramtype policy_definition_reference_id: str - :keyword compliance_state: Compliance state of the resource. - :paramtype compliance_state: str - :keyword policy_evaluation_details: Policy evaluation details. - :paramtype policy_evaluation_details: ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails - :keyword policy_definition_group_names: Policy definition group names. - :paramtype policy_definition_group_names: list[str] - :keyword components: Components state compliance records populated only when URL contains - $expand=components clause. - :paramtype components: list[~azure.mgmt.policyinsights.models.ComponentStateDetails] - """ - super().__init__(**kwargs) - self.additional_properties = additional_properties - self.odata_id = odata_id - self.odata_context = odata_context - self.timestamp = timestamp - self.resource_id = resource_id - self.policy_assignment_id = policy_assignment_id - self.policy_definition_id = policy_definition_id - self.effective_parameters = effective_parameters - self.is_compliant = is_compliant - self.subscription_id = subscription_id - self.resource_type = resource_type - self.resource_location = resource_location - self.resource_group = resource_group - self.resource_tags = resource_tags - self.policy_assignment_name = policy_assignment_name - self.policy_assignment_owner = policy_assignment_owner - self.policy_assignment_parameters = policy_assignment_parameters - self.policy_assignment_scope = policy_assignment_scope - self.policy_definition_name = policy_definition_name - self.policy_definition_action = policy_definition_action - self.policy_definition_category = policy_definition_category - self.policy_set_definition_id = policy_set_definition_id - self.policy_set_definition_name = policy_set_definition_name - self.policy_set_definition_owner = policy_set_definition_owner - self.policy_set_definition_category = policy_set_definition_category - self.policy_set_definition_parameters = policy_set_definition_parameters - self.management_group_ids = management_group_ids - self.policy_definition_reference_id = policy_definition_reference_id - self.compliance_state = compliance_state - self.policy_evaluation_details = policy_evaluation_details - self.policy_definition_group_names = policy_definition_group_names - self.components = components - self.policy_definition_version: Optional[str] = None - self.policy_set_definition_version: Optional[str] = None - self.policy_assignment_version: Optional[str] = None - - -class PolicyStatesQueryResults(_serialization.Model): - """Query results. - - :ivar odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :vartype odata_context: str - :ivar odata_count: OData entity count; represents the number of policy state records returned. - :vartype odata_count: int - :ivar odata_next_link: Odata next link; URL to get the next set of results. - :vartype odata_next_link: str - :ivar value: Query results. - :vartype value: list[~azure.mgmt.policyinsights.models.PolicyState] - """ - - _validation = { - "odata_count": {"minimum": 0}, - } - - _attribute_map = { - "odata_context": {"key": "@odata\\.context", "type": "str"}, - "odata_count": {"key": "@odata\\.count", "type": "int"}, - "odata_next_link": {"key": "@odata\\.nextLink", "type": "str"}, - "value": {"key": "value", "type": "[PolicyState]"}, - } - - def __init__( - self, - *, - odata_context: Optional[str] = None, - odata_count: Optional[int] = None, - odata_next_link: Optional[str] = None, - value: Optional[list["_models.PolicyState"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :paramtype odata_context: str - :keyword odata_count: OData entity count; represents the number of policy state records - returned. - :paramtype odata_count: int - :keyword odata_next_link: Odata next link; URL to get the next set of results. - :paramtype odata_next_link: str - :keyword value: Query results. - :paramtype value: list[~azure.mgmt.policyinsights.models.PolicyState] - """ - super().__init__(**kwargs) - self.odata_context = odata_context - self.odata_count = odata_count - self.odata_next_link = odata_next_link - self.value = value - - -class PolicyTrackedResource(_serialization.Model): - """Policy tracked resource record. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar tracked_resource_id: The ID of the policy tracked resource. - :vartype tracked_resource_id: str - :ivar policy_details: The details of the policy that require the tracked resource. - :vartype policy_details: ~azure.mgmt.policyinsights.models.PolicyDetails - :ivar created_by: The details of the policy triggered deployment that created the tracked - resource. - :vartype created_by: ~azure.mgmt.policyinsights.models.TrackedResourceModificationDetails - :ivar last_modified_by: The details of the policy triggered deployment that modified the - tracked resource. - :vartype last_modified_by: ~azure.mgmt.policyinsights.models.TrackedResourceModificationDetails - :ivar last_update_utc: Timestamp of the last update to the tracked resource. - :vartype last_update_utc: ~datetime.datetime - """ - - _validation = { - "tracked_resource_id": {"readonly": True}, - "policy_details": {"readonly": True}, - "created_by": {"readonly": True}, - "last_modified_by": {"readonly": True}, - "last_update_utc": {"readonly": True}, - } - - _attribute_map = { - "tracked_resource_id": {"key": "trackedResourceId", "type": "str"}, - "policy_details": {"key": "policyDetails", "type": "PolicyDetails"}, - "created_by": {"key": "createdBy", "type": "TrackedResourceModificationDetails"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "TrackedResourceModificationDetails"}, - "last_update_utc": {"key": "lastUpdateUtc", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.tracked_resource_id: Optional[str] = None - self.policy_details: Optional["_models.PolicyDetails"] = None - self.created_by: Optional["_models.TrackedResourceModificationDetails"] = None - self.last_modified_by: Optional["_models.TrackedResourceModificationDetails"] = None - self.last_update_utc: Optional[datetime.datetime] = None - - -class PolicyTrackedResourcesQueryResults(_serialization.Model): - """Query results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Query results. - :vartype value: list[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[PolicyTrackedResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.PolicyTrackedResource"]] = None - self.next_link: Optional[str] = None - - -class QueryFailure(_serialization.Model): - """Error response. - - :ivar error: Error definition. - :vartype error: ~azure.mgmt.policyinsights.models.QueryFailureError - """ - - _attribute_map = { - "error": {"key": "error", "type": "QueryFailureError"}, - } - - def __init__(self, *, error: Optional["_models.QueryFailureError"] = None, **kwargs: Any) -> None: - """ - :keyword error: Error definition. - :paramtype error: ~azure.mgmt.policyinsights.models.QueryFailureError - """ - super().__init__(**kwargs) - self.error = error - - -class QueryFailureError(_serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code: Optional[str] = None - self.message: Optional[str] = None - - -class QueryOptions(_serialization.Model): - """Parameter group. - - :ivar top: Maximum number of records to return. - :vartype top: int - :ivar filter: OData filter expression. - :vartype filter: str - :ivar order_by: Ordering expression using OData notation. One or more comma-separated column - names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, - ResourceId asc". - :vartype order_by: str - :ivar select: Select expression using OData notation. Limits the columns on each record to just - those requested, e.g. "$select=PolicyAssignmentId, ResourceId". - :vartype select: str - :ivar from_property: ISO 8601 formatted timestamp specifying the start time of the interval to - query. When not specified, the service uses ($to - 1-day). - :vartype from_property: ~datetime.datetime - :ivar to: ISO 8601 formatted timestamp specifying the end time of the interval to query. When - not specified, the service uses request time. - :vartype to: ~datetime.datetime - :ivar apply: OData apply expression for aggregations. - :vartype apply: str - :ivar skip_token: Skiptoken is only provided if a previous response returned a partial result - as a part of nextLink element. - :vartype skip_token: str - :ivar expand: The $expand query parameter. For example, to expand components use - $expand=components. - :vartype expand: str - """ - - _validation = { - "top": {"minimum": 0}, - } - - _attribute_map = { - "top": {"key": "Top", "type": "int"}, - "filter": {"key": "Filter", "type": "str"}, - "order_by": {"key": "OrderBy", "type": "str"}, - "select": {"key": "Select", "type": "str"}, - "from_property": {"key": "FromProperty", "type": "iso-8601"}, - "to": {"key": "To", "type": "iso-8601"}, - "apply": {"key": "Apply", "type": "str"}, - "skip_token": {"key": "SkipToken", "type": "str"}, - "expand": {"key": "Expand", "type": "str"}, - } - - def __init__( - self, - *, - top: Optional[int] = None, - filter: Optional[str] = None, # pylint: disable=redefined-builtin - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - expand: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword top: Maximum number of records to return. - :paramtype top: int - :keyword filter: OData filter expression. - :paramtype filter: str - :keyword order_by: Ordering expression using OData notation. One or more comma-separated column - names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, - ResourceId asc". - :paramtype order_by: str - :keyword select: Select expression using OData notation. Limits the columns on each record to - just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". - :paramtype select: str - :keyword from_property: ISO 8601 formatted timestamp specifying the start time of the interval - to query. When not specified, the service uses ($to - 1-day). - :paramtype from_property: ~datetime.datetime - :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. - When not specified, the service uses request time. - :paramtype to: ~datetime.datetime - :keyword apply: OData apply expression for aggregations. - :paramtype apply: str - :keyword skip_token: Skiptoken is only provided if a previous response returned a partial - result as a part of nextLink element. - :paramtype skip_token: str - :keyword expand: The $expand query parameter. For example, to expand components use - $expand=components. - :paramtype expand: str - """ - super().__init__(**kwargs) - self.top = top - self.filter = filter - self.order_by = order_by - self.select = select - self.from_property = from_property - self.to = to - self.apply = apply - self.skip_token = skip_token - self.expand = expand - - -class Remediation(_serialization.Model): - """The remediation definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ID of the remediation. - :vartype id: str - :ivar type: The type of the remediation. - :vartype type: str - :ivar name: The name of the remediation. - :vartype name: str - :ivar policy_assignment_id: The resource ID of the policy assignment that should be remediated. - :vartype policy_assignment_id: str - :ivar policy_definition_reference_id: The policy definition reference ID of the individual - definition that should be remediated. Required when the policy assignment being remediated - assigns a policy set definition. - :vartype policy_definition_reference_id: str - :ivar resource_discovery_mode: The way resources to remediate are discovered. Defaults to - ExistingNonCompliant if not specified. Known values are: "ExistingNonCompliant" and - "ReEvaluateCompliance". - :vartype resource_discovery_mode: str or - ~azure.mgmt.policyinsights.models.ResourceDiscoveryMode - :ivar provisioning_state: The status of the remediation. - :vartype provisioning_state: str - :ivar created_on: The time at which the remediation was created. - :vartype created_on: ~datetime.datetime - :ivar last_updated_on: The time at which the remediation was last updated. - :vartype last_updated_on: ~datetime.datetime - :ivar filters: The filters that will be applied to determine which resources to remediate. - :vartype filters: ~azure.mgmt.policyinsights.models.RemediationFilters - :ivar deployment_status: The deployment status summary for all deployments created by the - remediation. - :vartype deployment_status: ~azure.mgmt.policyinsights.models.RemediationDeploymentSummary - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "name": {"readonly": True}, - "provisioning_state": {"readonly": True}, - "created_on": {"readonly": True}, - "last_updated_on": {"readonly": True}, - "deployment_status": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "policy_assignment_id": {"key": "properties.policyAssignmentId", "type": "str"}, - "policy_definition_reference_id": {"key": "properties.policyDefinitionReferenceId", "type": "str"}, - "resource_discovery_mode": {"key": "properties.resourceDiscoveryMode", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "created_on": {"key": "properties.createdOn", "type": "iso-8601"}, - "last_updated_on": {"key": "properties.lastUpdatedOn", "type": "iso-8601"}, - "filters": {"key": "properties.filters", "type": "RemediationFilters"}, - "deployment_status": {"key": "properties.deploymentStatus", "type": "RemediationDeploymentSummary"}, - } - - def __init__( - self, - *, - policy_assignment_id: Optional[str] = None, - policy_definition_reference_id: Optional[str] = None, - resource_discovery_mode: Optional[Union[str, "_models.ResourceDiscoveryMode"]] = None, - filters: Optional["_models.RemediationFilters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword policy_assignment_id: The resource ID of the policy assignment that should be - remediated. - :paramtype policy_assignment_id: str - :keyword policy_definition_reference_id: The policy definition reference ID of the individual - definition that should be remediated. Required when the policy assignment being remediated - assigns a policy set definition. - :paramtype policy_definition_reference_id: str - :keyword resource_discovery_mode: The way resources to remediate are discovered. Defaults to - ExistingNonCompliant if not specified. Known values are: "ExistingNonCompliant" and - "ReEvaluateCompliance". - :paramtype resource_discovery_mode: str or - ~azure.mgmt.policyinsights.models.ResourceDiscoveryMode - :keyword filters: The filters that will be applied to determine which resources to remediate. - :paramtype filters: ~azure.mgmt.policyinsights.models.RemediationFilters - """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.type: Optional[str] = None - self.name: Optional[str] = None - self.policy_assignment_id = policy_assignment_id - self.policy_definition_reference_id = policy_definition_reference_id - self.resource_discovery_mode = resource_discovery_mode - self.provisioning_state: Optional[str] = None - self.created_on: Optional[datetime.datetime] = None - self.last_updated_on: Optional[datetime.datetime] = None - self.filters = filters - self.deployment_status: Optional["_models.RemediationDeploymentSummary"] = None - - -class RemediationDeployment(_serialization.Model): - """Details of a single deployment created by the remediation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar remediated_resource_id: Resource ID of the resource that is being remediated by the - deployment. - :vartype remediated_resource_id: str - :ivar deployment_id: Resource ID of the template deployment that will remediate the resource. - :vartype deployment_id: str - :ivar status: Status of the remediation deployment. - :vartype status: str - :ivar resource_location: Location of the resource that is being remediated. - :vartype resource_location: str - :ivar error: Error encountered while remediated the resource. - :vartype error: ~azure.mgmt.policyinsights.models.ErrorDefinition - :ivar created_on: The time at which the remediation was created. - :vartype created_on: ~datetime.datetime - :ivar last_updated_on: The time at which the remediation deployment was last updated. - :vartype last_updated_on: ~datetime.datetime - """ - - _validation = { - "remediated_resource_id": {"readonly": True}, - "deployment_id": {"readonly": True}, - "status": {"readonly": True}, - "resource_location": {"readonly": True}, - "error": {"readonly": True}, - "created_on": {"readonly": True}, - "last_updated_on": {"readonly": True}, - } - - _attribute_map = { - "remediated_resource_id": {"key": "remediatedResourceId", "type": "str"}, - "deployment_id": {"key": "deploymentId", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "resource_location": {"key": "resourceLocation", "type": "str"}, - "error": {"key": "error", "type": "ErrorDefinition"}, - "created_on": {"key": "createdOn", "type": "iso-8601"}, - "last_updated_on": {"key": "lastUpdatedOn", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.remediated_resource_id: Optional[str] = None - self.deployment_id: Optional[str] = None - self.status: Optional[str] = None - self.resource_location: Optional[str] = None - self.error: Optional["_models.ErrorDefinition"] = None - self.created_on: Optional[datetime.datetime] = None - self.last_updated_on: Optional[datetime.datetime] = None - - -class RemediationDeploymentsListResult(_serialization.Model): - """List of deployments for a remediation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of deployments for the remediation. - :vartype value: list[~azure.mgmt.policyinsights.models.RemediationDeployment] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[RemediationDeployment]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.RemediationDeployment"]] = None - self.next_link: Optional[str] = None - - -class RemediationDeploymentSummary(_serialization.Model): - """The deployment status summary for all deployments created by the remediation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar total_deployments: The number of deployments required by the remediation. - :vartype total_deployments: int - :ivar successful_deployments: The number of deployments required by the remediation that have - succeeded. - :vartype successful_deployments: int - :ivar failed_deployments: The number of deployments required by the remediation that have - failed. - :vartype failed_deployments: int - """ - - _validation = { - "total_deployments": {"readonly": True}, - "successful_deployments": {"readonly": True}, - "failed_deployments": {"readonly": True}, - } - - _attribute_map = { - "total_deployments": {"key": "totalDeployments", "type": "int"}, - "successful_deployments": {"key": "successfulDeployments", "type": "int"}, - "failed_deployments": {"key": "failedDeployments", "type": "int"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.total_deployments: Optional[int] = None - self.successful_deployments: Optional[int] = None - self.failed_deployments: Optional[int] = None - - -class RemediationFilters(_serialization.Model): - """The filters that will be applied to determine which resources to remediate. - - :ivar locations: The resource locations that will be remediated. - :vartype locations: list[str] - """ - - _attribute_map = { - "locations": {"key": "locations", "type": "[str]"}, - } - - def __init__(self, *, locations: Optional[list[str]] = None, **kwargs: Any) -> None: - """ - :keyword locations: The resource locations that will be remediated. - :paramtype locations: list[str] - """ - super().__init__(**kwargs) - self.locations = locations - - -class RemediationListResult(_serialization.Model): - """List of remediations. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: Array of remediation definitions. - :vartype value: list[~azure.mgmt.policyinsights.models.Remediation] - :ivar next_link: The URL to get the next set of results. - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Remediation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.value: Optional[list["_models.Remediation"]] = None - self.next_link: Optional[str] = None - - -class SlimPolicyMetadata(_serialization.Model): - """Slim version of policy metadata resource definition, excluding properties with large strings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ID of the policy metadata. - :vartype id: str - :ivar type: The type of the policy metadata. - :vartype type: str - :ivar name: The name of the policy metadata. - :vartype name: str - :ivar metadata_id: The policy metadata identifier. - :vartype metadata_id: str - :ivar category: The category of the policy metadata. - :vartype category: str - :ivar title: The title of the policy metadata. - :vartype title: str - :ivar owner: The owner of the policy metadata. - :vartype owner: str - :ivar additional_content_url: Url for getting additional content about the resource metadata. - :vartype additional_content_url: str - :ivar metadata: Additional metadata. - :vartype metadata: JSON - """ - - _validation = { - "id": {"readonly": True}, - "type": {"readonly": True}, - "name": {"readonly": True}, - "metadata_id": {"readonly": True}, - "category": {"readonly": True}, - "title": {"readonly": True}, - "owner": {"readonly": True}, - "additional_content_url": {"readonly": True}, - "metadata": {"readonly": True}, - } - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "metadata_id": {"key": "properties.metadataId", "type": "str"}, - "category": {"key": "properties.category", "type": "str"}, - "title": {"key": "properties.title", "type": "str"}, - "owner": {"key": "properties.owner", "type": "str"}, - "additional_content_url": {"key": "properties.additionalContentUrl", "type": "str"}, - "metadata": {"key": "properties.metadata", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id: Optional[str] = None - self.type: Optional[str] = None - self.name: Optional[str] = None - self.metadata_id: Optional[str] = None - self.category: Optional[str] = None - self.title: Optional[str] = None - self.owner: Optional[str] = None - self.additional_content_url: Optional[str] = None - self.metadata: Optional[JSON] = None - - -class SummarizeResults(_serialization.Model): - """Summarize action results. - - :ivar odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :vartype odata_context: str - :ivar odata_count: OData entity count; represents the number of summaries returned; always set - to 1. - :vartype odata_count: int - :ivar value: Summarize action results. - :vartype value: list[~azure.mgmt.policyinsights.models.Summary] - """ - - _validation = { - "odata_count": {"maximum": 1, "minimum": 1}, - } - - _attribute_map = { - "odata_context": {"key": "@odata\\.context", "type": "str"}, - "odata_count": {"key": "@odata\\.count", "type": "int"}, - "value": {"key": "value", "type": "[Summary]"}, - } - - def __init__( - self, - *, - odata_context: Optional[str] = None, - odata_count: Optional[int] = None, - value: Optional[list["_models.Summary"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :paramtype odata_context: str - :keyword odata_count: OData entity count; represents the number of summaries returned; always - set to 1. - :paramtype odata_count: int - :keyword value: Summarize action results. - :paramtype value: list[~azure.mgmt.policyinsights.models.Summary] - """ - super().__init__(**kwargs) - self.odata_context = odata_context - self.odata_count = odata_count - self.value = value - - -class Summary(_serialization.Model): - """Summary results. - - :ivar odata_id: OData entity ID; always set to null since summaries do not have an entity ID. - :vartype odata_id: str - :ivar odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :vartype odata_context: str - :ivar results: Compliance summary for all policy assignments. - :vartype results: ~azure.mgmt.policyinsights.models.SummaryResults - :ivar policy_assignments: Policy assignments summary. - :vartype policy_assignments: list[~azure.mgmt.policyinsights.models.PolicyAssignmentSummary] - """ - - _attribute_map = { - "odata_id": {"key": "@odata\\.id", "type": "str"}, - "odata_context": {"key": "@odata\\.context", "type": "str"}, - "results": {"key": "results", "type": "SummaryResults"}, - "policy_assignments": {"key": "policyAssignments", "type": "[PolicyAssignmentSummary]"}, - } - - def __init__( - self, - *, - odata_id: Optional[str] = None, - odata_context: Optional[str] = None, - results: Optional["_models.SummaryResults"] = None, - policy_assignments: Optional[list["_models.PolicyAssignmentSummary"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword odata_id: OData entity ID; always set to null since summaries do not have an entity - ID. - :paramtype odata_id: str - :keyword odata_context: OData context string; used by OData clients to resolve type information - based on metadata. - :paramtype odata_context: str - :keyword results: Compliance summary for all policy assignments. - :paramtype results: ~azure.mgmt.policyinsights.models.SummaryResults - :keyword policy_assignments: Policy assignments summary. - :paramtype policy_assignments: list[~azure.mgmt.policyinsights.models.PolicyAssignmentSummary] - """ - super().__init__(**kwargs) - self.odata_id = odata_id - self.odata_context = odata_context - self.results = results - self.policy_assignments = policy_assignments - - -class SummaryResults(_serialization.Model): - """Compliance summary on a particular summary level. - - :ivar query_results_uri: HTTP POST URI for queryResults action on Microsoft.PolicyInsights to - retrieve raw results for the compliance summary. This property will not be available by default - in future API versions, but could be queried explicitly. - :vartype query_results_uri: str - :ivar non_compliant_resources: Number of non-compliant resources. - :vartype non_compliant_resources: int - :ivar non_compliant_policies: Number of non-compliant policies. - :vartype non_compliant_policies: int - :ivar resource_details: The resources summary at this level. - :vartype resource_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] - :ivar policy_details: The policy artifact summary at this level. For query scope level, it - represents policy assignment summary. For policy assignment level, it represents policy - definitions summary. - :vartype policy_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] - :ivar policy_group_details: The policy definition group summary at this level. - :vartype policy_group_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] - """ - - _validation = { - "non_compliant_resources": {"minimum": 0}, - "non_compliant_policies": {"minimum": 0}, - } - - _attribute_map = { - "query_results_uri": {"key": "queryResultsUri", "type": "str"}, - "non_compliant_resources": {"key": "nonCompliantResources", "type": "int"}, - "non_compliant_policies": {"key": "nonCompliantPolicies", "type": "int"}, - "resource_details": {"key": "resourceDetails", "type": "[ComplianceDetail]"}, - "policy_details": {"key": "policyDetails", "type": "[ComplianceDetail]"}, - "policy_group_details": {"key": "policyGroupDetails", "type": "[ComplianceDetail]"}, - } - - def __init__( - self, - *, - query_results_uri: Optional[str] = None, - non_compliant_resources: Optional[int] = None, - non_compliant_policies: Optional[int] = None, - resource_details: Optional[list["_models.ComplianceDetail"]] = None, - policy_details: Optional[list["_models.ComplianceDetail"]] = None, - policy_group_details: Optional[list["_models.ComplianceDetail"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword query_results_uri: HTTP POST URI for queryResults action on Microsoft.PolicyInsights - to retrieve raw results for the compliance summary. This property will not be available by - default in future API versions, but could be queried explicitly. - :paramtype query_results_uri: str - :keyword non_compliant_resources: Number of non-compliant resources. - :paramtype non_compliant_resources: int - :keyword non_compliant_policies: Number of non-compliant policies. - :paramtype non_compliant_policies: int - :keyword resource_details: The resources summary at this level. - :paramtype resource_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] - :keyword policy_details: The policy artifact summary at this level. For query scope level, it - represents policy assignment summary. For policy assignment level, it represents policy - definitions summary. - :paramtype policy_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] - :keyword policy_group_details: The policy definition group summary at this level. - :paramtype policy_group_details: list[~azure.mgmt.policyinsights.models.ComplianceDetail] - """ - super().__init__(**kwargs) - self.query_results_uri = query_results_uri - self.non_compliant_resources = non_compliant_resources - self.non_compliant_policies = non_compliant_policies - self.resource_details = resource_details - self.policy_details = policy_details - self.policy_group_details = policy_group_details - - -class TrackedResourceModificationDetails(_serialization.Model): - """The details of the policy triggered deployment that created or modified the tracked resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar policy_details: The details of the policy that created or modified the tracked resource. - :vartype policy_details: ~azure.mgmt.policyinsights.models.PolicyDetails - :ivar deployment_id: The ID of the deployment that created or modified the tracked resource. - :vartype deployment_id: str - :ivar deployment_time: Timestamp of the deployment that created or modified the tracked - resource. - :vartype deployment_time: ~datetime.datetime - """ - - _validation = { - "policy_details": {"readonly": True}, - "deployment_id": {"readonly": True}, - "deployment_time": {"readonly": True}, - } - - _attribute_map = { - "policy_details": {"key": "policyDetails", "type": "PolicyDetails"}, - "deployment_id": {"key": "deploymentId", "type": "str"}, - "deployment_time": {"key": "deploymentTime", "type": "iso-8601"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.policy_details: Optional["_models.PolicyDetails"] = None - self.deployment_id: Optional[str] = None - self.deployment_time: Optional[datetime.datetime] = None - - -class TypedErrorInfo(_serialization.Model): - """Scenario specific error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The type of included error details. - :vartype type: str - :ivar info: The scenario specific error details. - :vartype info: any - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.info: Optional[Any] = None diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_patch.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_patch.py index 49900f6ab120..ea765788358a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_patch.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_patch.py @@ -1,15 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py index 767d5e51c452..0da3fdcef222 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- # pylint: disable=wrong-import-position @@ -12,26 +12,30 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import -from ._policy_tracked_resources_operations import PolicyTrackedResourcesOperations # type: ignore -from ._remediations_operations import RemediationsOperations # type: ignore -from ._policy_events_operations import PolicyEventsOperations # type: ignore -from ._policy_states_operations import PolicyStatesOperations # type: ignore from ._operations import Operations # type: ignore -from ._policy_metadata_operations import PolicyMetadataOperations # type: ignore -from ._policy_restrictions_operations import PolicyRestrictionsOperations # type: ignore +from ._operations import RemediationsOperations # type: ignore +from ._operations import AttestationsOperations # type: ignore +from ._operations import PolicyMetadataOperations # type: ignore +from ._operations import PolicyEventsOperations # type: ignore +from ._operations import PolicyStatesOperations # type: ignore +from ._operations import PolicyRestrictionsOperations # type: ignore +from ._operations import ComponentPolicyStatesOperations # type: ignore +from ._operations import PolicyTrackedResourcesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ - "PolicyTrackedResourcesOperations", + "Operations", "RemediationsOperations", + "AttestationsOperations", + "PolicyMetadataOperations", "PolicyEventsOperations", "PolicyStatesOperations", - "Operations", - "PolicyMetadataOperations", "PolicyRestrictionsOperations", + "ComponentPolicyStatesOperations", + "PolicyTrackedResourcesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py index dd791d9aff30..e6c546a67aac 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py @@ -1,12 +1,16 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar +import datetime +from io import IOBase +import json +from typing import Any, Callable, IO, Iterator, Literal, Optional, TypeVar, Union, cast, overload from azure.core import PipelineClient from azure.core.exceptions import ( @@ -15,35 +19,42 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) +from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models from .._configuration import PolicyInsightsClientConfiguration +from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] +JSON = MutableMapping[str, Any] List = list _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request(**kwargs: Any) -> HttpRequest: +def build_operations_list_request(**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", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.PolicyInsights/operations") + _url = "/providers/Microsoft.PolicyInsights/operations" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -54,31 +65,11027 @@ def build_list_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_remediations_get_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, remediation_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_create_or_update_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, remediation_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_delete_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, remediation_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_list_for_management_group_request( # pylint: disable=name-too-long + management_group_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_get_at_subscription_request( # pylint: disable=name-too-long + remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_create_or_update_at_subscription_request( # pylint: disable=name-too-long + remediation_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_delete_at_subscription_request( # pylint: disable=name-too-long + remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_list_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, *, top: Optional[int] = None, 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_list_deployments_at_subscription_request( # pylint: disable=name-too-long + remediation_name: str, subscription_id: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_cancel_at_subscription_request( # pylint: disable=name-too-long + remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_get_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_create_or_update_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, remediation_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_delete_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_list_for_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_list_deployments_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, remediation_name: str, subscription_id: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_cancel_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_get_at_resource_request( # pylint: disable=name-too-long + resource_id: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_create_or_update_at_resource_request( # pylint: disable=name-too-long + resource_id: str, remediation_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_delete_at_resource_request( # pylint: disable=name-too-long + resource_id: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "remediationName": _SERIALIZER.url("remediation_name", remediation_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_remediations_list_for_resource_request( # pylint: disable=name-too-long + resource_id: str, *, top: Optional[int] = None, 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/remediations" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_list_deployments_at_resource_request( # pylint: disable=name-too-long + resource_id: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_cancel_at_resource_request( # pylint: disable=name-too-long + resource_id: str, remediation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_list_deployments_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, remediation_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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_remediations_cancel_at_management_group_request( # pylint: disable=name-too-long + management_group_id: str, remediation_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_attestations_get_at_subscription_request( # pylint: disable=name-too-long + attestation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "attestationName": _SERIALIZER.url("attestation_name", attestation_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_attestations_create_or_update_at_subscription_request( # pylint: disable=name-too-long + attestation_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "attestationName": _SERIALIZER.url("attestation_name", attestation_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_attestations_delete_at_subscription_request( # pylint: disable=name-too-long + attestation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_attestations_list_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, *, top: Optional[int] = None, 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_attestations_get_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, attestation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "attestationName": _SERIALIZER.url("attestation_name", attestation_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_attestations_create_or_update_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, attestation_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "attestationName": _SERIALIZER.url("attestation_name", attestation_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_attestations_delete_at_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, attestation_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_attestations_list_for_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + subscription_id: str, + *, + top: Optional[int] = None, + 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_attestations_get_at_resource_request( # pylint: disable=name-too-long + resource_id: str, attestation_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "attestationName": _SERIALIZER.url("attestation_name", attestation_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_attestations_create_or_update_at_resource_request( # pylint: disable=name-too-long + resource_id: str, attestation_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "attestationName": _SERIALIZER.url("attestation_name", attestation_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_attestations_delete_at_resource_request( # pylint: disable=name-too-long + resource_id: str, attestation_name: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_attestations_list_for_resource_request( # pylint: disable=name-too-long + resource_id: str, *, top: Optional[int] = None, 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/attestations" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_metadata_get_resource_request( # pylint: disable=name-too-long + resource_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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.PolicyInsights/policyMetadata/{resourceName}" + path_format_arguments = { + "resourceName": _SERIALIZER.url("resource_name", resource_name, "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") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_metadata_list_request(*, 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/Microsoft.PolicyInsights/policyMetadata" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_management_group_request( # pylint: disable=name-too-long + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + management_group_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_resource_group_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_resource_request( # pylint: disable=name-too-long + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + resource_id: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + skip_token: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_policy_set_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_events_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_management_group_request( # pylint: disable=name-too-long + policy_states_resource: Union[str, _models.PolicyStatesResource], + management_group_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_management_group_request( # pylint: disable=name-too-long + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + management_group_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + } + + _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") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_resource_group_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_resource_group_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + } + + _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") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_resource_request( # pylint: disable=name-too-long + policy_states_resource: Union[str, _models.PolicyStatesResource], + resource_id: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + skip_token: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_resource_request( # pylint: disable=name-too-long + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + resource_id: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_trigger_subscription_evaluation_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" + 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") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_policy_states_trigger_resource_group_evaluation_request( # pylint: disable=name-too-long + subscription_id: str, resource_group_name: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_policy_states_list_query_results_for_policy_set_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_policy_set_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_policy_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_definition_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + } + + _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") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + if skip_token is not None: + _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_states_summarize_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyStatesSummaryResource": _SERIALIZER.url( + "policy_states_summary_resource", policy_states_summary_resource, "str" + ), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + } + + _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") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restrictions_check_at_subscription_scope_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restrictions_check_at_resource_group_scope_request( # pylint: disable=name-too-long + resource_group_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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_restrictions_check_at_management_group_scope_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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_component_policy_states_list_query_results_for_subscription_request( # pylint: disable=name-too-long + subscription_id: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "componentPolicyStatesResource": _SERIALIZER.url( + "component_policy_states_resource", component_policy_states_resource, "str" + ), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_component_policy_states_list_query_results_for_resource_group_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "componentPolicyStatesResource": _SERIALIZER.url( + "component_policy_states_resource", component_policy_states_resource, "str" + ), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_component_policy_states_list_query_results_for_resource_request( # pylint: disable=name-too-long + resource_id: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + 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", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "componentPolicyStatesResource": _SERIALIZER.url( + "component_policy_states_resource", component_policy_states_resource, "str" + ), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "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) + + +def build_component_policy_states_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long + subscription_id: str, + policy_definition_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), + "componentPolicyStatesResource": _SERIALIZER.url( + "component_policy_states_resource", component_policy_states_resource, "str" + ), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_component_policy_states_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + policy_assignment_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + "componentPolicyStatesResource": _SERIALIZER.url( + "component_policy_states_resource", component_policy_states_resource, "str" + ), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_component_policy_states_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long + subscription_id: str, + resource_group_name: str, + policy_assignment_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), + "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), + "componentPolicyStatesResource": _SERIALIZER.url( + "component_policy_states_resource", component_policy_states_resource, "str" + ), + } + + _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") + if order_by is not None: + _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") + if select is not None: + _params["$select"] = _SERIALIZER.query("select", select, "str") + if from_parameter is not None: + _params["$from"] = _SERIALIZER.query("from_parameter", from_parameter, "iso-8601") + if to is not None: + _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if apply is not None: + _params["$apply"] = _SERIALIZER.query("apply", apply, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_tracked_resources_list_query_results_for_management_group_request( # pylint: disable=name-too-long + management_group_name: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" + path_format_arguments = { + "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), + "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), + "policyTrackedResourcesResource": _SERIALIZER.url( + "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" + ), + } + + _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") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_tracked_resources_list_query_results_for_subscription_request( # pylint: disable=name-too-long + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + subscription_id: str, + *, + top: Optional[int] = None, + 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", "2018-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "policyTrackedResourcesResource": _SERIALIZER.url( + "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" + ), + } + + _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") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_tracked_resources_list_query_results_for_resource_group_request( # pylint: disable=name-too-long + resource_group_name: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + subscription_id: str, + *, + top: Optional[int] = None, + 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", "2018-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "policyTrackedResourcesResource": _SERIALIZER.url( + "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" + ), + } + + _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") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_policy_tracked_resources_list_query_results_for_resource_request( # pylint: disable=name-too-long + resource_id: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + 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", "2018-07-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" + path_format_arguments = { + "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), + "policyTrackedResourcesResource": _SERIALIZER.url( + "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" + ), + } + + _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") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class Operations: """ .. warning:: **DO NOT** instantiate this class directly. - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`operations` attribute. - """ + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`operations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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(self, **kwargs: Any) -> _models.OperationsListResults: + """Lists available operations. + + :return: OperationsListResults. The OperationsListResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.OperationsListResults + :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", "2024-10-01")) + cls: ClsType[_models.OperationsListResults] = kwargs.pop("cls", None) + + _request = build_operations_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.OperationsListResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class RemediationsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`remediations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_at_management_group( + self, management_group_id: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Gets an existing remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_management_group( + self, + management_group_id: str, + remediation_name: str, + parameters: Union[_models.Remediation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_at_management_group( + self, management_group_id: str, remediation_name: str, **kwargs: Any + ) -> Optional[_models.Remediation]: + """Deletes an existing remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_management_group( + self, management_group_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Remediation"]: + """Gets all remediations for the management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_management_group_request( + management_group_id=management_group_id, + top=top, + filter=filter, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Gets an existing remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update_at_subscription( + self, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_subscription( + self, remediation_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_subscription( + self, remediation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_subscription( + self, remediation_name: str, parameters: Union[_models.Remediation, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Optional[_models.Remediation]: + """Deletes an existing remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_subscription( + self, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Remediation"]: + """Gets all remediations for the subscription. + + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_deployments_at_subscription( + self, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :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", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Cancels a remediation at subscription scope. + + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_subscription_request( + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_at_resource_group( + self, resource_group_name: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Gets an existing remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_resource_group( + self, + resource_group_name: str, + remediation_name: str, + parameters: Union[_models.Remediation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_at_resource_group( + self, resource_group_name: str, remediation_name: str, **kwargs: Any + ) -> Optional[_models.Remediation]: + """Deletes an existing remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Remediation"]: + """Gets all remediations for the subscription. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_deployments_at_resource_group( + self, resource_group_name: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :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", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def cancel_at_resource_group( + self, resource_group_name: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Cancels a remediation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_resource_group_request( + resource_group_name=resource_group_name, + remediation_name=remediation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Gets an existing remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_get_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: _models.Remediation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. 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: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_at_resource( + self, + resource_id: str, + remediation_name: str, + parameters: Union[_models.Remediation, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.Remediation: + """Creates or updates a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :param parameters: The remediation parameters. Is one of the following types: Remediation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or JSON or IO[bytes] + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_remediations_create_or_update_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete_at_resource( + self, resource_id: str, remediation_name: str, **kwargs: Any + ) -> Optional[_models.Remediation]: + """Deletes an existing remediation at individual resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation or None. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2024-10-01")) + cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) + + _request = build_remediations_delete_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_for_resource( + self, resource_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Remediation"]: + """Gets all remediations for a resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Remediation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Remediation]] = 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_remediations_list_for_resource_request( + resource_id=resource_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Remediation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_deployments_at_resource( + self, resource_id: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :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", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: + """Cancel a remediation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_resource_request( + resource_id=resource_id, + remediation_name=remediation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_deployments_at_management_group( + self, management_group_id: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any + ) -> ItemPaged["_models.RemediationDeployment"]: + """Gets all deployments for a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of RemediationDeployment + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.RemediationDeployment]] = 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_remediations_list_deployments_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + top=top, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.RemediationDeployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def cancel_at_management_group( + self, management_group_id: str, remediation_name: str, **kwargs: Any + ) -> _models.Remediation: + """Cancels a remediation at management group scope. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param remediation_name: The name of the remediation. Required. + :type remediation_name: str + :return: Remediation. The Remediation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Remediation + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) + + _request = build_remediations_cancel_at_management_group_request( + management_group_id=management_group_id, + remediation_name=remediation_name, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Remediation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class AttestationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`attestations` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.Attestation: + """Gets an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: Attestation. The Attestation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :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", "2024-10-01")) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + + _request = build_attestations_get_at_subscription_request( + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Attestation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_at_subscription_initial( # pylint: disable=name-too-long + self, attestation_name: str, parameters: Union[_models.Attestation, JSON, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_attestations_create_or_update_at_subscription_request( + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update_at_subscription( + self, + attestation_name: str, + parameters: _models.Attestation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_at_subscription( + self, attestation_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_at_subscription( + self, attestation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. 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: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_subscription( + self, attestation_name: str, parameters: Union[_models.Attestation, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Is one of the following types: Attestation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or JSON or IO[bytes] + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_at_subscription_initial( + attestation_name=attestation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Attestation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Attestation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete_at_subscription( # pylint: disable=inconsistent-return-statements + self, attestation_name: str, **kwargs: Any + ) -> None: + """Deletes an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_attestations_delete_at_subscription_request( + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_for_subscription( + self, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Attestation"]: + """Gets all attestations for the subscription. + + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Attestation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Attestation]] = 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_attestations_list_for_subscription_request( + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Attestation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_at_resource_group( + self, resource_group_name: str, attestation_name: str, **kwargs: Any + ) -> _models.Attestation: + """Gets an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: Attestation. The Attestation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :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", "2024-10-01")) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + + _request = build_attestations_get_at_resource_group_request( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Attestation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_at_resource_group_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_attestations_create_or_update_at_resource_group_request( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: _models.Attestation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. 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: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Is one of the following types: Attestation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or JSON or IO[bytes] + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_at_resource_group_initial( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Attestation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Attestation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete_at_resource_group( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, attestation_name: str, **kwargs: Any + ) -> None: + """Deletes an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_attestations_delete_at_resource_group_request( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_for_resource_group( + self, resource_group_name: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Attestation"]: + """Gets all attestations for the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Attestation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Attestation]] = 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_attestations_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Attestation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any) -> _models.Attestation: + """Gets an existing attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: Attestation. The Attestation is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :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", "2024-10-01")) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + + _request = build_attestations_get_at_resource_request( + resource_id=resource_id, + attestation_name=attestation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Attestation, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_at_resource_initial( + self, + resource_id: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_attestations_create_or_update_at_resource_request( + resource_id=resource_id, + attestation_name=attestation_name, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: _models.Attestation, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. 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: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: Union[_models.Attestation, JSON, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Attestation]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :param parameters: The attestation parameters. Is one of the following types: Attestation, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or JSON or IO[bytes] + :return: An instance of LROPoller that returns Attestation. The Attestation is compatible with + MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_at_resource_initial( + resource_id=resource_id, + attestation_name=attestation_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = _deserialize(_models.Attestation, response.json()) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Attestation].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def delete_at_resource( # pylint: disable=inconsistent-return-statements + self, resource_id: str, attestation_name: str, **kwargs: Any + ) -> None: + """Deletes an existing attestation at individual resource scope. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param attestation_name: The name of the attestation. Required. + :type attestation_name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_attestations_delete_at_resource_request( + resource_id=resource_id, + attestation_name=attestation_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @distributed_trace + def list_for_resource( + self, resource_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.Attestation"]: + """Gets all attestations for a resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of Attestation + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] + :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", "2024-10-01")) + cls: ClsType[List[_models.Attestation]] = 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_attestations_list_for_resource_request( + resource_id=resource_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Attestation], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PolicyMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`policy_metadata` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetadata: + """Get policy metadata resource. + + :param resource_name: The name of the policy metadata resource. Required. + :type resource_name: str + :return: PolicyMetadata. The PolicyMetadata is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.PolicyMetadata + :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", "2024-10-01")) + cls: ClsType[_models.PolicyMetadata] = kwargs.pop("cls", None) + + _request = build_policy_metadata_get_resource_request( + resource_name=resource_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PolicyMetadata, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list(self, *, top: Optional[int] = None, **kwargs: Any) -> ItemPaged["_models.SlimPolicyMetadata"]: + """Get a list of the policy metadata resources. + + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :return: An iterator like instance of SlimPolicyMetadata + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] + :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", "2024-10-01")) + cls: ClsType[List[_models.SlimPolicyMetadata]] = 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_metadata_list_request( + top=top, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SlimPolicyMetadata], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PolicyEventsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`policy_events` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( # pylint: disable=too-many-locals + self, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + management_group_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resources under the management group. + + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param management_group_name: Management group name. Required. + :type management_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_management_group_request( + policy_events_resource=policy_events_resource, + management_group_name=management_group_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_subscription( + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_subscription_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource_group( # pylint: disable=too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_events_resource=policy_events_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource( # pylint: disable=too-many-locals + self, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + resource_id: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resource. + + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword expand: The $expand query parameter. For example, to expand components use + $expand=components. Default value is None. + :paramtype expand: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_resource_request( + policy_events_resource=policy_events_resource, + resource_id=resource_id, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + expand=expand, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the subscription level policy set definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_set_definition_name: Policy set definition name. Required. + :type policy_set_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_policy_set_definition_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + policy_set_definition_name=policy_set_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_policy_definition( # pylint: disable=too-many-locals + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_policy_definition_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + policy_definition_name=policy_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_events_resource=policy_events_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_events_resource: Union[str, _models.PolicyEventsResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyEvent"]: + """Queries policy events for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_events_resource: The name of the virtual resource under PolicyEvents resource + type; only "default" is allowed. "default" Required. + :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyEvent + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyEvent]] = 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_events_list_query_results_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_events_resource=policy_events_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyEvent], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class PolicyStatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`policy_states` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( # pylint: disable=too-many-locals + self, + policy_states_resource: Union[str, _models.PolicyStatesResource], + management_group_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the resources under the management group. + + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param management_group_name: Management group name. Required. + :type management_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_management_group_request( + policy_states_resource=policy_states_resource, + management_group_name=management_group_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_management_group( + self, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + management_group_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resources under the management group. + + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param management_group_name: Management group name. Required. + :type management_group_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_management_group_request( + policy_states_summary_resource=policy_states_summary_resource, + management_group_name=management_group_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_subscription( + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_subscription_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_subscription( + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_subscription_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource_group( # pylint: disable=too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_resource=policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_resource_group( + self, + subscription_id: str, + resource_group_name: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_summary_resource=policy_states_summary_resource, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource( # pylint: disable=too-many-locals + self, + policy_states_resource: Union[str, _models.PolicyStatesResource], + resource_id: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the resource. + + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword expand: The $expand query parameter. For example, to expand components use + $expand=components. Default value is None. + :paramtype expand: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :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", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_resource_request( + policy_states_resource=policy_states_resource, + resource_id=resource_id, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + expand=expand, + skip_token=skip_token, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_resource( + self, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + resource_id: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resource. + + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param resource_id: Resource ID. Required. + :type resource_id: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_resource_request( + policy_states_summary_resource=policy_states_summary_resource, + resource_id=resource_id, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _trigger_subscription_evaluation_initial(self, subscription_id: str, **kwargs: Any) -> Iterator[bytes]: + 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", "2024-10-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_policy_states_trigger_subscription_evaluation_request( + subscription_id=subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: Any) -> LROPoller[None]: + """Triggers a policy evaluation scan for all the resources under the subscription. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[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", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._trigger_subscription_evaluation_initial( + subscription_id=subscription_id, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _trigger_resource_group_evaluation_initial( # pylint: disable=name-too-long + self, subscription_id: str, resource_group_name: str, **kwargs: Any + ) -> Iterator[bytes]: + 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", "2024-10-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_policy_states_trigger_resource_group_evaluation_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + 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, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_trigger_resource_group_evaluation( + self, subscription_id: str, resource_group_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Triggers a policy evaluation scan for all the resources under the resource group. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :return: An instance of LROPoller that returns None + :rtype: ~azure.core.polling.LROPoller[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", "2024-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._trigger_resource_group_evaluation_initial( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the subscription level policy set definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_set_definition_name: Policy set definition name. Required. + :type policy_set_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_policy_set_definition_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + policy_set_definition_name=policy_set_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_policy_set_definition( + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_set_definition_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the subscription level policy set definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_set_definition_name: Policy set definition name. Required. + :type policy_set_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_policy_set_definition_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + policy_set_definition_name=policy_set_definition_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_policy_definition( # pylint: disable=too-many-locals + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_definition_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_policy_definition_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + policy_definition_name=policy_definition_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_policy_definition( + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_definition_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the subscription level policy definition. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_policy_definition_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + policy_definition_name=policy_definition_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_states_resource=policy_states_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_subscription_level_policy_assignment( # pylint: disable=name-too-long + self, + subscription_id: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_states_summary_resource=policy_states_summary_resource, + policy_assignment_name=policy_assignment_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_states_resource: Union[str, _models.PolicyStatesResource], + policy_assignment_name: str, + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyState"]: + """Queries policy states for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_states_resource: The virtual resource under PolicyStates resource type. In a + given time range, 'latest' represents the latest policy state(s), whereas 'default' represents + all policy state(s). Known values are: "default" and "latest". Required. + :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword skip_token: Skiptoken is only provided if a previous response returned a partial + result as a part of nextLink element. Default value is None. + :paramtype skip_token: str + :return: An iterator like instance of PolicyState + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[List[_models.PolicyState]] = 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_states_list_query_results_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_resource=policy_states_resource, + policy_assignment_name=policy_assignment_name, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + skip_token=skip_token, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyState], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("@odata.nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def summarize_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long + self, + subscription_id: str, + resource_group_name: str, + policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], + policy_assignment_name: str, + *, + top: Optional[int] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> _models.SummarizeResults: + """Summarizes policy states for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_states_summary_resource: The virtual resource under PolicyStates resource type + for summarize action. In a given time range, 'latest' represents the latest policy state(s) and + is the only allowed value. "latest" Required. + :type policy_states_summary_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: SummarizeResults. The SummarizeResults is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) + + _request = build_policy_states_summarize_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_states_summary_resource=policy_states_summary_resource, + policy_assignment_name=policy_assignment_name, + top=top, + from_parameter=from_parameter, + to=to, + filter=filter, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.SummarizeResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class PolicyRestrictionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`policy_restrictions` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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 check_at_subscription_scope( + self, parameters: _models.CheckRestrictionsRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_at_subscription_scope( + self, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_at_subscription_scope( + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :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: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_at_subscription_scope( + self, parameters: Union[_models.CheckRestrictionsRequest, JSON, IO[bytes]], **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a subscription. + + :param parameters: The request body. Is one of the following types: CheckRestrictionsRequest, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or JSON or + IO[bytes] + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restrictions_check_at_subscription_scope_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckRestrictionsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_at_resource_group_scope( + self, + resource_group_name: str, + parameters: _models.CheckRestrictionsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The request body. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_at_resource_group_scope( + self, resource_group_name: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The request body. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_at_resource_group_scope( + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :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: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_at_resource_group_scope( + self, + resource_group_name: str, + parameters: Union[_models.CheckRestrictionsRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on a resource within a resource group. Use + this when the resource group the resource will be created in is already known. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param parameters: The request body. Is one of the following types: CheckRestrictionsRequest, + JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or JSON or + IO[bytes] + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :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", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restrictions_check_at_resource_group_scope_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckRestrictionsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def check_at_management_group_scope( + self, + management_group_id: str, + parameters: _models.CheckManagementGroupRestrictionsRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_at_management_group_scope( + self, management_group_id: str, parameters: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. Required. + :type parameters: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_at_management_group_scope( + self, management_group_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. 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: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_at_management_group_scope( + self, + management_group_id: str, + parameters: Union[_models.CheckManagementGroupRestrictionsRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.CheckRestrictionsResult: + """Checks what restrictions Azure Policy will place on resources within a management group. + + :param management_group_id: Management group ID. Required. + :type management_group_id: str + :param parameters: The check policy restrictions parameters. Is one of the following types: + CheckManagementGroupRestrictionsRequest, JSON, IO[bytes] Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest or + JSON or IO[bytes] + :return: CheckRestrictionsResult. The CheckRestrictionsResult is compatible with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult + :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 {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _content = json.dumps(parameters, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_policy_restrictions_check_at_management_group_scope_request( + management_group_id=management_group_id, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + content_type=content_type, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.CheckRestrictionsResult, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ComponentPolicyStatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`component_policy_states` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_subscription( + self, + subscription_id: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states under subscription scope. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_subscription_request( + subscription_id=subscription_id, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource_group( + self, + subscription_id: str, + resource_group_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states under resource group scope. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_resource_group_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource( + self, + resource_id: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :keyword expand: The $expand query parameter. Default value is None. + :paramtype expand: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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 {}) - models = _models + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", 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: PolicyInsightsClientConfiguration = 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") + _request = build_component_policy_states_list_query_results_for_resource_request( + resource_id=resource_id, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list(self, **kwargs: Any) -> _models.OperationsListResults: - """Lists available operations. + def list_query_results_for_policy_definition( # pylint: disable=too-many-locals + self, + subscription_id: str, + policy_definition_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the subscription level policy definition. - :return: OperationsListResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.OperationsListResults + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_definition_name: Policy definition name. Required. + :type policy_definition_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -92,17 +11099,35 @@ def list(self, **kwargs: Any) -> _models.OperationsListResults: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.OperationsListResults] = kwargs.pop("cls", None) + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - _request = build_list_request( + _request = build_component_policy_states_list_query_results_for_policy_definition_request( + subscription_id=subscription_id, + policy_definition_name=policy_definition_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + authorization_namespace=authorization_namespace, api_version=api_version, headers=_headers, params=_params, ) - _request.url = self._client.format_url(_request.url) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -110,16 +11135,693 @@ def list(self, **kwargs: Any) -> _models.OperationsListResults: response = pipeline_response.http_response if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.QueryFailure, - pipeline_response, + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + policy_assignment_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the subscription level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_subscription_level_policy_assignment_request( + subscription_id=subscription_id, + policy_assignment_name=policy_assignment_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long,too-many-locals + self, + subscription_id: str, + resource_group_name: str, + policy_assignment_name: str, + component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], + *, + top: Optional[int] = None, + order_by: Optional[str] = None, + select: Optional[str] = None, + from_parameter: Optional[datetime.datetime] = None, + to: Optional[datetime.datetime] = None, + filter: Optional[str] = None, + apply: Optional[str] = None, + **kwargs: Any + ) -> _models.ComponentPolicyStatesQueryResults: + """Queries component policy states for the resource group level policy assignment. + + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. + :type subscription_id: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param policy_assignment_name: Policy assignment name. Required. + :type policy_assignment_name: str + :param component_policy_states_resource: The virtual resource under ComponentPolicyStates + resource type. In a given time range, 'latest' represents the latest component policy state(s). + "latest" Required. + :type component_policy_states_resource: str or + ~azure.mgmt.policyinsights.models.ComponentPolicyStatesResource + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword order_by: Ordering expression using OData notation. One or more comma-separated column + names with an optional "desc" (the default) or "asc", e.g. "$orderby=PolicyAssignmentId, + ResourceId asc". Default value is None. + :paramtype order_by: str + :keyword select: Select expression using OData notation. Limits the columns on each record to + just those requested, e.g. "$select=PolicyAssignmentId, ResourceId". Default value is None. + :paramtype select: str + :keyword from_parameter: ISO 8601 formatted timestamp specifying the start time of the interval + to query. When not specified, the service uses ($to - 1-day). Default value is None. + :paramtype from_parameter: ~datetime.datetime + :keyword to: ISO 8601 formatted timestamp specifying the end time of the interval to query. + When not specified, the service uses request time. Default value is None. + :paramtype to: ~datetime.datetime + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :keyword apply: OData apply expression for aggregations. Default value is None. + :paramtype apply: str + :return: ComponentPolicyStatesQueryResults. The ComponentPolicyStatesQueryResults is compatible + with MutableMapping + :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults + :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 {}) + + authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( + "authorization_namespace", "Microsoft.Authorization" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) + + _request = build_component_policy_states_list_query_results_for_resource_group_level_policy_assignment_request( + subscription_id=subscription_id, + resource_group_name=resource_group_name, + policy_assignment_name=policy_assignment_name, + component_policy_states_resource=component_policy_states_resource, + top=top, + order_by=order_by, + select=select, + from_parameter=from_parameter, + to=to, + filter=filter, + apply=apply, + authorization_namespace=authorization_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ErrorResponse, + response, ) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationsListResults", pipeline_response.http_response) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ComponentPolicyStatesQueryResults, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + + +class PolicyTrackedResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s + :attr:`policy_tracked_resources` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( + self, + management_group_name: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the management group. + + :param management_group_name: Management group name. Required. + :type management_group_name: str + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( + "management_groups_namespace", "Microsoft.Management" + ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_management_group_request( + management_group_name=management_group_name, + policy_tracked_resources_resource=policy_tracked_resources_resource, + top=top, + filter=filter, + management_groups_namespace=management_groups_namespace, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_subscription( + self, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the subscription. + + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :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", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_subscription_request( + policy_tracked_resources_resource=policy_tracked_resources_resource, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource_group( + self, + resource_group_name: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :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", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_resource_group_request( + resource_group_name=resource_group_name, + policy_tracked_resources_resource=policy_tracked_resources_resource, + subscription_id=self._config.subscription_id, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_query_results_for_resource( + self, + resource_id: str, + policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], + *, + top: Optional[int] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.PolicyTrackedResource"]: + """Queries policy tracked resources under the resource. + + :param resource_id: Resource ID. Required. + :type resource_id: str + :param policy_tracked_resources_resource: The name of the virtual resource under + PolicyTrackedResources resource type; only "default" is allowed. "default" Required. + :type policy_tracked_resources_resource: str or + ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType + :keyword top: Maximum number of records to return. Default value is None. + :paramtype top: int + :keyword filter: OData filter expression. Default value is None. + :paramtype filter: str + :return: An iterator like instance of PolicyTrackedResource + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] + :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", "2018-07-01-preview")) + cls: ClsType[List[_models.PolicyTrackedResource]] = 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_tracked_resources_list_query_results_for_resource_request( + resource_id=resource_id, + policy_tracked_resources_resource=policy_tracked_resources_resource, + top=top, + filter=filter, + api_version=api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link, headers=_headers) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.base_url", self._config.base_url, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.PolicyTrackedResource], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.QueryFailure, + response, + ) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_patch.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_patch.py index 49900f6ab120..ea765788358a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_patch.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_patch.py @@ -1,15 +1,14 @@ -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - +# 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. +# -------------------------------------------------------------------------- """Customize generated code here. Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import List -__all__: List[str] = [] # Add all objects you want publicly available to users at this package level +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level def patch_sdk(): diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py deleted file mode 100644 index de28232c81c0..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py +++ /dev/null @@ -1,1846 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PolicyInsightsClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_query_results_for_management_group_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - management_group_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_subscription_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "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 top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_resource_group_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - resource_group_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_resource_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - resource_id: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - expand: Optional[str] = None, - skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_policy_set_definition_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_set_definition_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_definition_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_assignment_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), - } - - _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", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) - path_format_arguments = { - "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), - } - - _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", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class PolicyEventsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`policy_events` 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: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - management_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resources under the management group. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_management_group_request( - policy_events_resource=policy_events_resource, - management_group_name=management_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - management_groups_namespace=management_groups_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_subscription( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resources under the subscription. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource_group( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - resource_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resources under the resource group. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - resource_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resource. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_request( - policy_events_resource=policy_events_resource, - resource_id=resource_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - expand=_expand, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_set_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the subscription level policy set definition. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_set_definition_name: Policy set definition name. Required. - :type policy_set_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_set_definition_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - policy_set_definition_name=policy_set_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_policy_definition( - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the subscription level policy definition. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_definition_name: Policy definition name. Required. - :type policy_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_definition_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - policy_definition_name=policy_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the subscription level policy assignment. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_level_policy_assignment_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_events_resource: Union[str, _models.PolicyEventsResourceType], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyEvent"]: - """Queries policy events for the resource group level policy assignment. - - :param policy_events_resource: The name of the virtual resource under PolicyEvents resource - type; only "default" is allowed. "default" Required. - :type policy_events_resource: str or ~azure.mgmt.policyinsights.models.PolicyEventsResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyEvent or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyEventsQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_level_policy_assignment_request( - policy_events_resource=policy_events_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py deleted file mode 100644 index bd84fc256580..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py +++ /dev/null @@ -1,229 +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. -# -------------------------------------------------------------------------- -from collections.abc import MutableMapping -from typing import Any, Callable, Optional, TypeVar - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PolicyInsightsClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_get_resource_request(resource_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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.PolicyInsights/policyMetadata/{resourceName}") - path_format_arguments = { - "resourceName": _SERIALIZER.url("resource_name", resource_name, "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_request(*, 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/providers/Microsoft.PolicyInsights/policyMetadata") - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -class PolicyMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`policy_metadata` 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: PolicyInsightsClientConfiguration = 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_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetadata: - """Get policy metadata resource. - - :param resource_name: The name of the policy metadata resource. Required. - :type resource_name: str - :return: PolicyMetadata or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.PolicyMetadata - :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", "2019-10-01")) - cls: ClsType[_models.PolicyMetadata] = kwargs.pop("cls", None) - - _request = build_get_resource_request( - resource_name=resource_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("PolicyMetadata", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> ItemPaged["_models.SlimPolicyMetadata"]: - """Get a list of the policy metadata resources. - - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either SlimPolicyMetadata or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyMetadataCollection] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_request( - 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("PolicyMetadataCollection", 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.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py deleted file mode 100644 index a93a10071731..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py +++ /dev/null @@ -1,343 +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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PolicyInsightsClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_check_at_subscription_scope_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", "2020-07-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.PolicyInsights/checkPolicyRestrictions" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_check_at_resource_group_scope_request( # pylint: disable=name-too-long - resource_group_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", "2020-07-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions", - ) - 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 - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class PolicyRestrictionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`policy_restrictions` 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: PolicyInsightsClientConfiguration = 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 check_at_subscription_scope( - self, parameters: _models.CheckRestrictionsRequest, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a subscription. - - :param parameters: The check policy restrictions parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_at_subscription_scope( - self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a subscription. - - :param parameters: The check policy restrictions parameters. 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: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_at_subscription_scope( - self, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a subscription. - - :param parameters: The check policy restrictions parameters. Is either a - CheckRestrictionsRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :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", "2020-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckRestrictionsResult] = 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, "CheckRestrictionsRequest") - - _request = build_check_at_subscription_scope_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.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def check_at_resource_group_scope( - self, - resource_group_name: str, - parameters: _models.CheckRestrictionsRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a resource group. Use - this when the resource group the resource will be created in is already known. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: The check policy restrictions parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_at_resource_group_scope( - self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a resource group. Use - this when the resource group the resource will be created in is already known. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: The check policy restrictions parameters. 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: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_at_resource_group_scope( - self, resource_group_name: str, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **kwargs: Any - ) -> _models.CheckRestrictionsResult: - """Checks what restrictions Azure Policy will place on a resource within a resource group. Use - this when the resource group the resource will be created in is already known. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param parameters: The check policy restrictions parameters. Is either a - CheckRestrictionsRequest type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] - :return: CheckRestrictionsResult or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult - :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", "2020-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.CheckRestrictionsResult] = 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, "CheckRestrictionsRequest") - - _request = build_check_at_resource_group_scope_request( - resource_group_name=resource_group_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 [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponseAutoGenerated, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py deleted file mode 100644 index 25e8ae9d17b3..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py +++ /dev/null @@ -1,3235 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# 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 collections.abc import MutableMapping -import datetime -from typing import Any, Callable, Iterator, Literal, Optional, TypeVar, Union, cast - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling - -from .. import models as _models -from .._configuration import PolicyInsightsClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_query_results_for_management_group_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - management_group_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_management_group_request( # pylint: disable=name-too-long - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - management_group_name: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_subscription_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "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 top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_subscription_request( - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "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 top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_resource_group_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - resource_group_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_resource_group_request( # pylint: disable=name-too-long - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - resource_group_name: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_resource_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - resource_id: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - expand: Optional[str] = None, - skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if expand is not None: - _params["$expand"] = _SERIALIZER.query("expand", expand, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_resource_request( - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - resource_id: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "resourceId": _SERIALIZER.url("resource_id", resource_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 top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_trigger_subscription_evaluation_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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation", - ) - 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_trigger_resource_group_evaluation_request( # pylint: disable=name-too-long - subscription_id: str, resource_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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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_list_query_results_for_policy_set_definition_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_set_definition_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_policy_set_definition_request( # pylint: disable=name-too-long - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_set_definition_name: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_definition_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_policy_definition_request( # pylint: disable=name-too-long - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_definition_name: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_assignment_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), - } - - _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", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_assignment_name: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), - } - - _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", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - *, - top: Optional[int] = None, - order_by: Optional[str] = None, - select: Optional[str] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - apply: Optional[str] = None, - skip_token: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) - path_format_arguments = { - "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), - } - - _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", minimum=0) - if order_by is not None: - _params["$orderby"] = _SERIALIZER.query("order_by", order_by, "str") - if select is not None: - _params["$select"] = _SERIALIZER.query("select", select, "str") - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - if apply is not None: - _params["$apply"] = _SERIALIZER.query("apply", apply, "str") - if skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_next_link_request(next_link: str, *, skip_token: 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", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "{nextLink}") - path_format_arguments = { - "nextLink": _SERIALIZER.url("next_link", next_link, "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 skip_token is not None: - _params["$skiptoken"] = _SERIALIZER.query("skip_token", skip_token, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_summarize_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - *, - top: Optional[int] = None, - from_property: Optional[datetime.datetime] = None, - to: Optional[datetime.datetime] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) - path_format_arguments = { - "policyStatesSummaryResource": _SERIALIZER.url( - "policy_states_summary_resource", policy_states_summary_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), - "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), - } - - _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", minimum=0) - if from_property is not None: - _params["$from"] = _SERIALIZER.query("from_property", from_property, "iso-8601") - if to is not None: - _params["$to"] = _SERIALIZER.query("to", to, "iso-8601") - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -class PolicyStatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`policy_states` 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: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - management_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the resources under the management group. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_management_group_request( - policy_states_resource=policy_states_resource, - management_group_name=management_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - management_groups_namespace=management_groups_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_management_group( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - management_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resources under the management group. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_management_group_request( - policy_states_summary_resource=policy_states_summary_resource, - management_group_name=management_group_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - management_groups_namespace=management_groups_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_subscription( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the resources under the subscription. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_subscription( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resources under the subscription. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_subscription_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_resource_group( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - resource_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the resources under the resource group. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_resource_group( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - resource_group_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resources under the resource group. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_resource_group_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_resource( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - resource_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the resource. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :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", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_request( - policy_states_resource=policy_states_resource, - resource_id=resource_id, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - expand=_expand, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _expand = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _expand = query_options.expand - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_resource( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - resource_id: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resource. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_resource_request( - policy_states_summary_resource=policy_states_summary_resource, - resource_id=resource_id, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _trigger_subscription_evaluation_initial(self, subscription_id: str, **kwargs: Any) -> Iterator[bytes]: - 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", "2019-10-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_trigger_subscription_evaluation_request( - subscription_id=subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: Any) -> LROPoller[None]: - """Triggers a policy evaluation scan for all the resources under the subscription. - - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[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", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._trigger_subscription_evaluation_initial( - subscription_id=subscription_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _trigger_resource_group_evaluation_initial( # pylint: disable=name-too-long - self, subscription_id: str, resource_group_name: str, **kwargs: Any - ) -> Iterator[bytes]: - 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", "2019-10-01")) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_trigger_resource_group_evaluation_request( - subscription_id=subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - 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, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize( - _models.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_trigger_resource_group_evaluation( - self, subscription_id: str, resource_group_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Triggers a policy evaluation scan for all the resources under the resource group. - - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[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", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._trigger_resource_group_evaluation_initial( - subscription_id=subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_set_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the subscription level policy set definition. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_set_definition_name: Policy set definition name. Required. - :type policy_set_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_set_definition_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - policy_set_definition_name=policy_set_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_policy_set_definition( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_set_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the subscription level policy set definition. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_set_definition_name: Policy set definition name. Required. - :type policy_set_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_policy_set_definition_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - policy_set_definition_name=policy_set_definition_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_policy_definition( - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the subscription level policy definition. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_definition_name: Policy definition name. Required. - :type policy_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_policy_definition_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - policy_definition_name=policy_definition_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_policy_definition( - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_definition_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the subscription level policy definition. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_definition_name: Policy definition name. Required. - :type policy_definition_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_policy_definition_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - policy_definition_name=policy_definition_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the subscription level policy assignment. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_subscription_level_policy_assignment_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_subscription_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the subscription level policy assignment. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_subscription_level_policy_assignment_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - policy_assignment_name=policy_assignment_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_resource: Union[str, _models.PolicyStatesResource], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyState"]: - """Queries policy states for the resource group level policy assignment. - - :param policy_states_resource: The virtual resource under PolicyStates resource type. In a - given time range, 'latest' represents the latest policy state(s), whereas 'default' represents - all policy state(s). Known values are: "default" and "latest". Required. - :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyState or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.PolicyStatesQueryResults] = 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: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_list_query_results_for_resource_group_level_policy_assignment_request( - policy_states_resource=policy_states_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - policy_assignment_name=policy_assignment_name, - top=_top, - order_by=_order_by, - select=_select, - from_property=_from_property, - to=_to, - filter=_filter, - apply=_apply, - skip_token=_skip_token, - authorization_namespace=authorization_namespace, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - else: - _top = None - _order_by = None - _select = None - _from_property = None - _to = None - _filter = None - _apply = None - _skip_token = None - if query_options is not None: - _apply = query_options.apply - _filter = query_options.filter - _from_property = query_options.from_property - _order_by = query_options.order_by - _select = query_options.select - _skip_token = query_options.skip_token - _to = query_options.to - _top = query_options.top - - _request = build_next_link_request( - next_link=next_link, - skip_token=_skip_token, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.odata_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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def summarize_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long - self, - policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], - subscription_id: str, - resource_group_name: str, - policy_assignment_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> _models.SummarizeResults: - """Summarizes policy states for the resource group level policy assignment. - - :param policy_states_summary_resource: The virtual resource under PolicyStates resource type - for summarize action. In a given time range, 'latest' represents the latest policy state(s) and - is the only allowed value. "latest" Required. - :type policy_states_summary_resource: str or - ~azure.mgmt.policyinsights.models.PolicyStatesSummaryResourceType - :param subscription_id: Microsoft Azure subscription ID. Required. - :type subscription_id: str - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_assignment_name: Policy assignment name. Required. - :type policy_assignment_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: SummarizeResults or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults - :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 {}) - - authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( - "authorization_namespace", "Microsoft.Authorization" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) - - _top = None - _from_property = None - _to = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _from_property = query_options.from_property - _to = query_options.to - _top = query_options.top - - _request = build_summarize_for_resource_group_level_policy_assignment_request( - policy_states_summary_resource=policy_states_summary_resource, - subscription_id=subscription_id, - resource_group_name=resource_group_name, - policy_assignment_name=policy_assignment_name, - top=_top, - from_property=_from_property, - to=_to, - filter=_filter, - authorization_namespace=authorization_namespace, - 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py deleted file mode 100644 index 10fb2887ae4b..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py +++ /dev/null @@ -1,589 +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 collections.abc import MutableMapping -from typing import Any, Callable, Literal, Optional, TypeVar, Union - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PolicyInsightsClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_query_results_for_management_group_request( # pylint: disable=name-too-long - management_group_name: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - *, - top: Optional[int] = None, - filter: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), - "policyTrackedResourcesResource": _SERIALIZER.url( - "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _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_list_query_results_for_subscription_request( # pylint: disable=name-too-long - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - subscription_id: str, - *, - top: Optional[int] = None, - 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", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) - path_format_arguments = { - "policyTrackedResourcesResource": _SERIALIZER.url( - "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _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_list_query_results_for_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - subscription_id: str, - *, - top: Optional[int] = None, - 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", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) - path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "policyTrackedResourcesResource": _SERIALIZER.url( - "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" - ), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _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_list_query_results_for_resource_request( # pylint: disable=name-too-long - resource_id: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - *, - top: Optional[int] = None, - 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", "2018-07-01-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "policyTrackedResourcesResource": _SERIALIZER.url( - "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" - ), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "str") - _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) - - -class PolicyTrackedResourcesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`policy_tracked_resources` 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: PolicyInsightsClientConfiguration = 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_query_results_for_management_group( - self, - management_group_name: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the management group. - - :param management_group_name: Management group name. Required. - :type management_group_name: str - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_management_group_request( - management_group_name=management_group_name, - policy_tracked_resources_resource=policy_tracked_resources_resource, - top=_top, - filter=_filter, - management_groups_namespace=management_groups_namespace, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_subscription( - self, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the subscription. - - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :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", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_subscription_request( - policy_tracked_resources_resource=policy_tracked_resources_resource, - subscription_id=self._config.subscription_id, - top=_top, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource_group( - self, - resource_group_name: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the resource group. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :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", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_resource_group_request( - resource_group_name=resource_group_name, - policy_tracked_resources_resource=policy_tracked_resources_resource, - subscription_id=self._config.subscription_id, - top=_top, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_query_results_for_resource( - self, - resource_id: str, - policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.PolicyTrackedResource"]: - """Queries policy tracked resources under the resource. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param policy_tracked_resources_resource: The name of the virtual resource under - PolicyTrackedResources resource type; only "default" is allowed. "default" Required. - :type policy_tracked_resources_resource: str or - ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either PolicyTrackedResource or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] - :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", "2018-07-01-preview")) - cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_query_results_for_resource_request( - resource_id=resource_id, - policy_tracked_resources_resource=policy_tracked_resources_resource, - top=_top, - 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("PolicyTrackedResourcesQueryResults", 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.QueryFailure, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py deleted file mode 100644 index 18c7a52e1860..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py +++ /dev/null @@ -1,2698 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines -# 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 collections.abc import MutableMapping -from io import IOBase -from typing import Any, Callable, IO, Literal, Optional, TypeVar, Union, overload - -from azure.core import PipelineClient -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.rest import HttpRequest, HttpResponse -from azure.core.tracing.decorator import distributed_trace -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models -from .._configuration import PolicyInsightsClientConfiguration -from .._utils.serialization import Deserializer, Serializer - -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] -List = list - -_SERIALIZER = Serializer() -_SERIALIZER.client_side_validation = False - - -def build_list_deployments_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, remediation_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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - _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_cancel_at_management_group_request( - management_group_id: str, remediation_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_management_group_request( - management_group_id: str, *, top: Optional[int] = None, filter: Optional[str] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "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) - - -def build_create_or_update_at_management_group_request( # pylint: disable=name-too-long - management_group_id: str, remediation_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-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/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_get_at_management_group_request( - management_group_id: str, remediation_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_delete_at_management_group_request( - management_group_id: str, remediation_name: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), - "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_list_deployments_at_subscription_request( # pylint: disable=name-too-long - remediation_name: str, subscription_id: 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - _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_cancel_at_subscription_request(remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_subscription_request( - subscription_id: str, *, top: Optional[int] = None, 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations") - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "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) - - -def build_create_or_update_at_subscription_request( # pylint: disable=name-too-long - remediation_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", "2019-07-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.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_get_at_subscription_request(remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_delete_at_subscription_request(remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_list_deployments_at_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, remediation_name: str, subscription_id: 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - _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_cancel_at_resource_group_request( - resource_group_name: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_group_request( - resource_group_name: str, - subscription_id: str, - *, - top: Optional[int] = None, - 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "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) - - -def build_create_or_update_at_resource_group_request( # pylint: disable=name-too-long - resource_group_name: str, remediation_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", "2019-07-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_get_at_resource_group_request( - resource_group_name: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_delete_at_resource_group_request( - resource_group_name: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_list_deployments_at_resource_request( # pylint: disable=name-too-long - resource_id: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", - "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - _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_cancel_at_resource_request(resource_id: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop( - "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - ) - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_list_for_resource_request( - resource_id: str, *, top: Optional[int] = None, 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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int", minimum=0) - if filter is not None: - _params["$filter"] = _SERIALIZER.query("filter", filter, "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) - - -def build_create_or_update_at_resource_request( # pylint: disable=name-too-long - resource_id: str, remediation_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", "2019-07-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", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_get_at_resource_request(resource_id: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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_delete_at_resource_request(resource_id: str, remediation_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", "2019-07-01")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = kwargs.pop("template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}") - path_format_arguments = { - "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), - "remediationName": _SERIALIZER.url("remediation_name", remediation_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) - - -class RemediationsOperations: # pylint: disable=too-many-public-methods - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.policyinsights.PolicyInsightsClient`'s - :attr:`remediations` 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: PolicyInsightsClientConfiguration = 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_deployments_at_management_group( - self, - management_group_id: str, - remediation_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - top=_top, - management_groups_namespace=management_groups_namespace, - 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("RemediationDeploymentsListResult", 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 cancel_at_management_group( - self, management_group_id: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Cancels a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_management_group( - self, management_group_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> ItemPaged["_models.Remediation"]: - """Gets all remediations for the management group. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_management_group_request( - management_group_id=management_group_id, - top=_top, - filter=_filter, - management_groups_namespace=management_groups_namespace, - 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("RemediationListResult", 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) - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_management_group( - self, - management_group_id: str, - remediation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_at_management_group( - self, - management_group_id: str, - remediation_name: str, - parameters: Union[_models.Remediation, IO[bytes]], - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_at_management_group( - self, management_group_id: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Gets an existing remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_at_management_group( - self, management_group_id: str, remediation_name: str, **kwargs: Any - ) -> Optional[_models.Remediation]: - """Deletes an existing remediation at management group scope. - - :param management_group_id: Management group ID. Required. - :type management_group_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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 {}) - - management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( - "management_groups_namespace", "Microsoft.Management" - ) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_management_group_request( - management_group_id=management_group_id, - remediation_name=remediation_name, - management_groups_namespace=management_groups_namespace, - 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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_deployments_at_subscription( - self, remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> ItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_subscription_request( - remediation_name=remediation_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("RemediationDeploymentsListResult", 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 cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Cancels a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_subscription_request( - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_subscription( - self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> ItemPaged["_models.Remediation"]: - """Gets all remediations for the subscription. - - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_subscription_request( - subscription_id=self._config.subscription_id, - top=_top, - 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("RemediationListResult", 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) - - @overload - def create_or_update_at_subscription( - self, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_subscription( - self, remediation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_at_subscription( - self, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_subscription_request( - remediation_name=remediation_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 [200, 201]: - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Gets an existing remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_subscription_request( - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Optional[_models.Remediation]: - """Deletes an existing remediation at subscription scope. - - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_subscription_request( - remediation_name=remediation_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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_deployments_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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("RemediationDeploymentsListResult", 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 cancel_at_resource_group( - self, resource_group_name: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Cancels a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", 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, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> ItemPaged["_models.Remediation"]: - """Gets all remediations for the subscription. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_resource_group_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - top=_top, - 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("RemediationListResult", 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) - - @overload - def create_or_update_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_at_resource_group( - self, - resource_group_name: str, - remediation_name: str, - parameters: Union[_models.Remediation, IO[bytes]], - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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 [200, 201]: - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_at_resource_group( - self, resource_group_name: str, remediation_name: str, **kwargs: Any - ) -> _models.Remediation: - """Gets an existing remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_at_resource_group( - self, resource_group_name: str, remediation_name: str, **kwargs: Any - ) -> Optional[_models.Remediation]: - """Deletes an existing remediation at resource group scope. - - :param resource_group_name: Resource group name. Required. - :type resource_group_name: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_resource_group_request( - resource_group_name=resource_group_name, - remediation_name=remediation_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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_deployments_at_resource( - self, - resource_id: str, - remediation_name: str, - query_options: Optional[_models.QueryOptions] = None, - **kwargs: Any - ) -> ItemPaged["_models.RemediationDeployment"]: - """Gets all deployments for a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either RemediationDeployment or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationDeploymentsListResult] = 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: - _top = None - if query_options is not None: - _top = query_options.top - - _request = build_list_deployments_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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("RemediationDeploymentsListResult", 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 cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Cancel a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_cancel_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_for_resource( - self, resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> ItemPaged["_models.Remediation"]: - """Gets all remediations for a resource. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param query_options: Parameter group. Default value is None. - :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :return: An iterator like instance of either Remediation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] - :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", "2019-07-01")) - cls: ClsType[_models.RemediationListResult] = 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: - _top = None - _filter = None - if query_options is not None: - _filter = query_options.filter - _top = query_options.top - - _request = build_list_for_resource_request( - resource_id=resource_id, - top=_top, - 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("RemediationListResult", 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) - - @overload - def create_or_update_at_resource( - self, - resource_id: str, - remediation_name: str, - parameters: _models.Remediation, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update_at_resource( - self, - resource_id: str, - remediation_name: str, - parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. 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: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update_at_resource( - self, resource_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any - ) -> _models.Remediation: - """Creates or updates a remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Remediation] = 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, "Remediation") - - _request = build_create_or_update_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: - """Gets an existing remediation at resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation - :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", "2019-07-01")) - cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - - _request = build_get_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - error = self._deserialize.failsafe_deserialize( - _models.ErrorResponse, - pipeline_response, - ) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def delete_at_resource( - self, resource_id: str, remediation_name: str, **kwargs: Any - ) -> Optional[_models.Remediation]: - """Deletes an existing remediation at individual resource scope. - - :param resource_id: Resource ID. Required. - :type resource_id: str - :param remediation_name: The name of the remediation. Required. - :type remediation_name: str - :return: Remediation or None or the result of cls(response) - :rtype: ~azure.mgmt.policyinsights.models.Remediation 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", "2019-07-01")) - cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - - _request = build_delete_at_resource_request( - resource_id=resource_id, - remediation_name=remediation_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) - 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("Remediation", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py new file mode 100644 index 000000000000..c90832275a2d --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py @@ -0,0 +1,61 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_create_resource_group_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.begin_create_or_update_at_resource_group( + resource_group_name="myRg", + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + parameters={ + "properties": { + "assessmentDate": "2021-06-10T00:00:00Z", + "comments": "This subscription has passed a security audit.", + "complianceState": "Compliant", + "evidence": [ + { + "description": "The results of the security audit.", + "sourceUri": "https://gist.github.com/contoso/9573e238762c60166c090ae16b814011", + } + ], + "expiresOn": "2021-06-15T00:00:00Z", + "metadata": {"departmentId": "NYC-MARKETING-1"}, + "owner": "55a32e28-3aa5-4eea-9b5a-4cd85153b966", + "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", + "policyDefinitionReferenceId": "0b158b46-ff42-4799-8e39-08a5c23b4551", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_CreateResourceGroupScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py new file mode 100644 index 000000000000..c0f0697dbd71 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py @@ -0,0 +1,61 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_create_resource_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.begin_create_or_update_at_resource( + resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + parameters={ + "properties": { + "assessmentDate": "2021-06-10T00:00:00Z", + "comments": "This subscription has passed a security audit.", + "complianceState": "Compliant", + "evidence": [ + { + "description": "The results of the security audit.", + "sourceUri": "https://gist.github.com/contoso/9573e238762c60166c090ae16b814011", + } + ], + "expiresOn": "2021-06-15T00:00:00Z", + "metadata": {"departmentId": "NYC-MARKETING-1"}, + "owner": "55a32e28-3aa5-4eea-9b5a-4cd85153b966", + "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", + "policyDefinitionReferenceId": "0b158b46-ff42-4799-8e39-08a5c23b4551", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_CreateResourceScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py new file mode 100644 index 000000000000..04f4a264db44 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py @@ -0,0 +1,48 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_create_subscription_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.begin_create_or_update_at_subscription( + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + parameters={ + "properties": { + "complianceState": "Compliant", + "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_CreateSubscriptionScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py new file mode 100644 index 000000000000..ad0b9bc77df4 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py @@ -0,0 +1,60 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_create_subscription_scope_all_properties.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.begin_create_or_update_at_subscription( + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + parameters={ + "properties": { + "assessmentDate": "2021-06-10T00:00:00Z", + "comments": "This subscription has passed a security audit.", + "complianceState": "Compliant", + "evidence": [ + { + "description": "The results of the security audit.", + "sourceUri": "https://gist.github.com/contoso/9573e238762c60166c090ae16b814011", + } + ], + "expiresOn": "2021-06-15T00:00:00Z", + "metadata": {"departmentId": "NYC-MARKETING-1"}, + "owner": "55a32e28-3aa5-4eea-9b5a-4cd85153b966", + "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", + "policyDefinitionReferenceId": "0b158b46-ff42-4799-8e39-08a5c23b4551", + } + }, + ).result() + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_CreateSubscriptionScope_AllProperties.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py new file mode 100644 index 000000000000..664653d1c977 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_delete_resource_group_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.attestations.delete_at_resource_group( + resource_group_name="myRg", + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + ) + + +# x-ms-original-file: 2024-10-01/Attestations_DeleteResourceGroupScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py new file mode 100644 index 000000000000..59605546b560 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py @@ -0,0 +1,42 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_delete_resource_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.attestations.delete_at_resource( + resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + ) + + +# x-ms-original-file: 2024-10-01/Attestations_DeleteResourceScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py new file mode 100644 index 000000000000..b823e0fb9278 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_delete_subscription_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.attestations.delete_at_subscription( + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + ) + + +# x-ms-original-file: 2024-10-01/Attestations_DeleteSubscriptionScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py new file mode 100644 index 000000000000..7b9c709252ef --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_get_resource_group_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.get_at_resource_group( + resource_group_name="myRg", + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_GetResourceGroupScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py new file mode 100644 index 000000000000..ce568baaaf86 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_get_resource_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.get_at_resource( + resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_GetResourceScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py new file mode 100644 index 000000000000..4726e4c13abd --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_get_subscription_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.get_at_subscription( + attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/Attestations_GetSubscriptionScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py new file mode 100644 index 000000000000..f276c082ae4f --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_list_resource_group_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.list_for_resource_group( + resource_group_name="myRg", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-10-01/Attestations_ListResourceGroupScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py new file mode 100644 index 000000000000..2d87d574f39c --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_list_resource_group_scope_with_query.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.list_for_resource_group( + resource_group_name="myRg", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-10-01/Attestations_ListResourceGroupScope_WithQuery.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py new file mode 100644 index 000000000000..18d371ae3722 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_list_resource_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.list_for_resource( + resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-10-01/Attestations_ListResourceScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py new file mode 100644 index 000000000000..33d04e39ac36 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_list_resource_scope_with_query.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.list_for_resource( + resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", + ) + for item in response: + print(item) + + +# x-ms-original-file: 2024-10-01/Attestations_ListResourceScope_WithQuery.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py new file mode 100644 index 000000000000..4c7405ea6b2b --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_list_subscription_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.list_for_subscription() + for item in response: + print(item) + + +# x-ms-original-file: 2024-10-01/Attestations_ListSubscriptionScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py new file mode 100644 index 000000000000..418759b94fa4 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python attestations_list_subscription_scope_with_query.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.attestations.list_for_subscription() + for item in response: + print(item) + + +# x-ms-original-file: 2024-10-01/Attestations_ListSubscriptionScope_WithQuery.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py new file mode 100644 index 000000000000..212d8071ff1e --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_nested_resource_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource( + resource_id="subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVault", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryNestedResourceScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py new file mode 100644 index 000000000000..69e675f79ca7 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_group_level_policy_assignment_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource_group_level_policy_assignment( + subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + resource_group_name="myResourceGroup", + policy_assignment_name="myPolicyAssignment", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py new file mode 100644 index 000000000000..640dc1954d1b --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_group_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource_group( + subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + resource_group_name="myResourceGroup", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceGroupScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py new file mode 100644 index 000000000000..1d5135748be5 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource_group( + subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + resource_group_name="myResourceGroup", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceGroupScopeGroupByComponentTypeWithAggregate.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py new file mode 100644 index 000000000000..bcfa4e727ef6 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource( + resource_id="subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py new file mode 100644 index 000000000000..9846fc61793d --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_scope_expand_policy_evaluation_details.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource( + resource_id="subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myCluster", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py new file mode 100644 index 000000000000..c9f4536200eb --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_scope_filter_by_component_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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource( + resource_id="subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceScopeFilterByComponentId.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py new file mode 100644 index 000000000000..825062516a0c --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py @@ -0,0 +1,43 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_resource( + resource_id="subscriptions/e78961ba-36fe-4739-9212-e3031b4c8db7/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/Vaults/myKVName", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QueryResourceScopeGroupByComponentTypeWithAggregate.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py new file mode 100644 index 000000000000..b9fe2e653eb9 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_subscription_level_policy_assignment_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_subscription_level_policy_assignment( + subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_assignment_name="ec8f9645-8ecb-4abb-9c0b-5292f19d4003", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py new file mode 100644 index 000000000000..e40a9fc6e4df --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_subscription_level_policy_definition_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_policy_definition( + subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_definition_name="24813039-7534-408a-9842-eb99f45721b1", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py new file mode 100644 index 000000000000..13a00c1e227f --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_subscription_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_subscription( + subscription_id="fff10b27-fff3-fff5-fff8-fffbe01e86a5", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QuerySubscriptionScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py new file mode 100644 index 000000000000..62b163c4db45 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.component_policy_states.list_query_results_for_subscription( + subscription_id="e78961ba-36fe-4739-9212-e3031b4c8db7", + component_policy_states_resource="latest", + ) + print(response) + + +# x-ms-original-file: 2024-10-01/ComponentPolicyStates_QuerySubscriptionScopeGroupByComponentTypeWithAggregate.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py index dc2dee01404c..d0e84cdc4882 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -35,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/Operations_ListOperations.json +# x-ms-original-file: 2024-10-01/Operations_ListOperations.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py index 9c1591c3ed44..64dfe2b65598 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndAggregateOnly.json +# x-ms-original-file: 2024-10-01/PolicyEvents_FilterAndAggregateOnly.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py index 97e5b03f82d4..9c25363ae04a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndGroupByWithAggregate.json +# x-ms-original-file: 2024-10-01/PolicyEvents_FilterAndGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py index 5e29c19154f3..07f6e7576d53 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndGroupByWithoutAggregate.json +# x-ms-original-file: 2024-10-01/PolicyEvents_FilterAndGroupByWithoutAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py index 7766d5efdf5c..4c60232eac04 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndMultipleGroups.json +# x-ms-original-file: 2024-10-01/PolicyEvents_FilterAndMultipleGroups.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py index 32c2a5615db3..255523482264 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py index 5d802e7c9a17..82bce218cbd5 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryManagementGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py index 9ce7a36dfe0b..f5b35ec13805 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryNestedResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py index b76691942103..48c792c99034 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,19 +27,19 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_resource_group_level_policy_assignment( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_events_resource="default", policy_assignment_name="myPolicyAssignment", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py index a9af22346bd9..9b852ce34849 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,19 +27,19 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_resource_group_level_policy_assignment( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_events_resource="default", policy_assignment_name="myPolicyAssignment", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py index 651c6d3d3623..f93c117169e1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_resource_group( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py index 41c118f0b950..676d77cd717c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_resource_group( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py index 4ad334c28922..e5bddf3144e0 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py index 4f0de15d6fa3..507acae996e3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponents.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceScopeExpandComponents.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py index d02f2863a5a7..c654e91561fc 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponentsGroupByWithAggregate.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceScopeExpandComponentsGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py index 834ed438a41f..d64b573424d5 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QueryResourceScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py index a44be6bcc05a..0b5b9e525665 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelNestedResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py index 5f0a886846da..f301e8bff330 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription_level_policy_assignment( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", policy_assignment_name="ec8f9645-8ecb-4abb-9c0b-5292f19d4003", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py index f18d95674357..a26c99855724 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription_level_policy_assignment( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", policy_assignment_name="ec8f9645-8ecb-4abb-9c0b-5292f19d4003", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py index 625e2e5f0ea2..3d7227c7b132 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_policy_definition( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", policy_definition_name="24813039-7534-408a-9842-eb99f45721b1", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py index c6d0b0804330..6caf7c02e338 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_policy_definition( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", policy_definition_name="24813039-7534-408a-9842-eb99f45721b1", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py index e9466df4760f..7027bceefd9b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_policy_set_definition( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", policy_set_definition_name="3e3807c1-65c9-49e0-a406-82d8ae3e338c", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py index ec6cc9812fb6..edd4b3b5237d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_policy_set_definition( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", policy_set_definition_name="3e3807c1-65c9-49e0-a406-82d8ae3e338c", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py index 7fa32b77bf61..1a7c96f55152 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionLevelResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py index 1a6b3eefc647..f930f38901b9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionScope.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py index 39f7d2af46f9..e5afeb69bf40 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyEvents_QuerySubscriptionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py index fa3c017e212d..ea4e06d5e024 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_events.list_query_results_for_subscription( - policy_events_resource="default", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_events_resource="default", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_TimeRangeSortSelectTop.json +# x-ms-original-file: 2024-10-01/PolicyEvents_TimeRangeSortSelectTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py index f295a54d746c..c3383c934a51 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json +# x-ms-original-file: 2024-10-01/PolicyMetadata_GetResource.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py index 902cebb1baee..2be6fd4669ab 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json +# x-ms-original-file: 2024-10-01/PolicyMetadata_List.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py index 9773abb32729..66d7832189e4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json +# x-ms-original-file: 2024-10-01/PolicyMetadata_List_WithTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py new file mode 100644 index 000000000000..4c20b62323aa --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python policy_restrictions_check_at_management_group_scope.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.policy_restrictions.check_at_management_group_scope( + management_group_id="financeMg", + parameters={"pendingFields": [{"field": "type"}]}, + ) + print(response) + + +# x-ms-original-file: 2024-10-01/PolicyRestrictions_CheckAtManagementGroupScope.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py index 45f3614958ea..7758cb171777 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restrictions.check_at_resource_group_scope( @@ -48,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2020-07-01/examples/PolicyRestrictions_CheckAtResourceGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyRestrictions_CheckAtResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py new file mode 100644 index 000000000000..191659b9571d --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py @@ -0,0 +1,53 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python policy_restrictions_check_at_resource_group_scope_include_audit_effect.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.policy_restrictions.check_at_resource_group_scope( + resource_group_name="vmRg", + parameters={ + "includeAuditEffect": True, + "pendingFields": [ + {"field": "name", "values": ["myVMName"]}, + {"field": "location", "values": ["eastus", "westus", "westus2", "westeurope"]}, + {"field": "tags"}, + ], + "resourceDetails": { + "apiVersion": "2019-12-01", + "resourceContent": {"properties": {"priority": "Spot"}, "type": "Microsoft.Compute/virtualMachines"}, + }, + }, + ) + print(response) + + +# x-ms-original-file: 2024-10-01/PolicyRestrictions_CheckAtResourceGroupScopeIncludeAuditEffect.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py index 7c6d5c5cfc4a..05b31d9f4024 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_restrictions.check_at_subscription_scope( @@ -47,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2020-07-01/examples/PolicyRestrictions_CheckAtSubscriptionScope.json +# x-ms-original-file: 2024-10-01/PolicyRestrictions_CheckAtSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py new file mode 100644 index 000000000000..a8b8cfa55579 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python policy_restrictions_check_at_subscription_scope_include_audit_effect.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.policy_restrictions.check_at_subscription_scope( + parameters={ + "includeAuditEffect": True, + "pendingFields": [ + {"field": "name", "values": ["myVMName"]}, + {"field": "location", "values": ["eastus", "westus", "westus2", "westeurope"]}, + {"field": "tags"}, + ], + "resourceDetails": { + "apiVersion": "2019-12-01", + "resourceContent": {"properties": {"priority": "Spot"}, "type": "Microsoft.Compute/virtualMachines"}, + }, + }, + ) + print(response) + + +# x-ms-original-file: 2024-10-01/PolicyRestrictions_CheckAtSubscriptionScopeIncludeAuditEffect.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py index 697752b96a5d..1134e9c1f351 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndAggregateOnly.json +# x-ms-original-file: 2024-10-01/PolicyStates_FilterAndAggregateOnly.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py index 8c517f40969b..326c7797affa 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndGroupByWithAggregate.json +# x-ms-original-file: 2024-10-01/PolicyStates_FilterAndGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py index 9d9567cc0089..28c238b6c07f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndGroupByWithoutAggregate.json +# x-ms-original-file: 2024-10-01/PolicyStates_FilterAndGroupByWithoutAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py index 0bee82d0fc9f..d52ee06c49f9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndMultipleGroups.json +# x-ms-original-file: 2024-10-01/PolicyStates_FilterAndMultipleGroups.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py index be0b05cfd23e..a819ca0b4d68 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py index d5cfacf69f9e..32c69cb470e3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryManagementGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py index 48308aafc772..cfa528076b4e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryNestedResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py index a13b43037b84..2b13bde2ce1c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,19 +27,19 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_resource_group_level_policy_assignment( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_states_resource="latest", policy_assignment_name="myPolicyAssignment", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py index 7a5c6c34f0be..88ef2e4f7c5b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,19 +27,19 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_resource_group_level_policy_assignment( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_states_resource="latest", policy_assignment_name="myPolicyAssignment", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py index 2db7aa8ee71c..65bfda2b594a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_resource_group( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py index 9ee31b0f271f..ed6fcacbedc8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_resource_group( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py index d7b6a2a645ca..35e5a33d04c9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py index 2cbc8bee78f9..7166d451f71c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandComponents.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceScopeExpandComponents.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py index 3134a617adf3..1e3fb3cd54e7 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandComponentsGroupByWithAggregate.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceScopeExpandComponentsGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py index 9060af373907..5df564c5870b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py index d89d997977ae..c8e7bfe2f307 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QueryResourceScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py index 58ff7ea47494..0e836c1ac0fd 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelNestedResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py index 69fb95a719fd..abb8ae7671f1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription_level_policy_assignment( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", policy_assignment_name="ec8f9645-8ecb-4abb-9c0b-5292f19d4003", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py index 330601862249..d6a849afc026 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription_level_policy_assignment( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", policy_assignment_name="ec8f9645-8ecb-4abb-9c0b-5292f19d4003", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py index 3735011d6153..e6dd19ad7f03 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_policy_definition( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", policy_definition_name="24813039-7534-408a-9842-eb99f45721b1", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py index 9bff4f773b50..d34db5df63f3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_policy_definition( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", policy_definition_name="24813039-7534-408a-9842-eb99f45721b1", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py index 3812055b9e06..b9e7b3e0a513 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_policy_set_definition( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", policy_set_definition_name="3e3807c1-65c9-49e0-a406-82d8ae3e338c", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py index 2a4a356023ff..662f6d8f3f27 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_policy_set_definition( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", policy_set_definition_name="3e3807c1-65c9-49e0-a406-82d8ae3e338c", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py index 7fcfd3097044..95ec86d3cc6a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionLevelResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py index 3d5dcabf1da0..f7cee6e3919f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py index d1e544847929..99faf9015188 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionScopeNextLink.json +# x-ms-original-file: 2024-10-01/PolicyStates_QuerySubscriptionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py index 4f21a3943a1a..a1ee7bb974d0 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeManagementGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py index efdba58f5d10..1acbfd029305 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,18 +27,18 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_resource_group_level_policy_assignment( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_states_summary_resource="latest", policy_assignment_name="b7a1ca2596524e3ab19597f2", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py index 01225736db59..3ddb252e4cec 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_resource_group( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", + policy_states_summary_resource="latest", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py index f25861af552d..5c4edf9a6e5f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py index 21b9b96ec5b3..79ad23959e57 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_subscription_level_policy_assignment( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_summary_resource="latest", policy_assignment_name="ec8f9645-8ecb-4abb-9c0b-5292f19d4003", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeSubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py index 315eec6a0842..1503e062e3d4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_policy_definition( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_summary_resource="latest", policy_definition_name="24813039-7534-408a-9842-eb99f45721b1", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeSubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py index 8d70b227d23a..0660842c5678 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_policy_set_definition( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_summary_resource="latest", policy_set_definition_name="3e3807c1-65c9-49e0-a406-82d8ae3e338c", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicySetDefinitionScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeSubscriptionLevelPolicySetDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py index bc4343940b53..980d6e31409d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,16 +27,16 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_subscription( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_summary_resource="latest", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScope.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py index 122671144afb..22bb88efccc7 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,16 +27,16 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.summarize_for_subscription( - policy_states_summary_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_summary_resource="latest", ) print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScopeForPolicyGroup.json +# x-ms-original-file: 2024-10-01/PolicyStates_SummarizeSubscriptionScopeForPolicyGroup.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py index 35bfea25c0b6..a4e99f2a82d2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,17 +27,17 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_states.list_query_results_for_subscription( - policy_states_resource="latest", subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + policy_states_resource="latest", ) for item in response: print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TimeRangeSortSelectTop.json +# x-ms-original-file: 2024-10-01/PolicyStates_TimeRangeSortSelectTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py index 81388dad0ace..ac954421625d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) client.policy_states.begin_trigger_resource_group_evaluation( @@ -37,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerResourceGroupEvaluation.json +# x-ms-original-file: 2024-10-01/PolicyStates_TriggerResourceGroupEvaluation.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py index c9233c618448..fa5067bc91e9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) client.policy_states.begin_trigger_subscription_evaluation( @@ -36,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerSubscriptionEvaluation.json +# x-ms-original-file: 2024-10-01/PolicyStates_TriggerSubscriptionEvaluation.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py index 9dc6330d8ef4..4f1c96795cac 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryManagementGroupScope.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QueryManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py index 600cccd6acb6..cb0840788125 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryManagementGroupScopeWithFilterAndTop.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QueryManagementGroupScopeWithFilterAndTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py index c578a7eb341e..d227097f8fbe 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_tracked_resources.list_query_results_for_resource_group( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceGroupScope.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QueryResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py index c06724b01c1f..d405e49cc236 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_tracked_resources.list_query_results_for_resource_group( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceGroupScopeWithFilterAndTop.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QueryResourceGroupScopeWithFilterAndTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py index a41244ae495e..6d56c1391e63 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceScope.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QueryResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py index db665ca1f4b6..8ea059f23961 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QueryResourceScopeWithFilterAndTop.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QueryResourceScopeWithFilterAndTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py index e2072ff368b3..b30843445724 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_tracked_resources.list_query_results_for_subscription( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QuerySubscriptionScope.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QuerySubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py index 5d5e039f6df1..3859c715ed31 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", + subscription_id="SUBSCRIPTION_ID", ) response = client.policy_tracked_resources.list_query_results_for_subscription( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/preview/2018-07-01-preview/examples/PolicyTrackedResources_QuerySubscriptionScopeWithFilterAndTop.json +# x-ms-original-file: 2018-07-01-preview/PolicyTrackedResources_QuerySubscriptionScopeWithFilterAndTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py index d51027c0fe9c..cfaeed3e5c6b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CancelManagementGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_CancelManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py index 2e8f8f48b5b5..f600bf827e4b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.cancel_at_resource_group( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CancelResourceGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_CancelResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py index ae57fe08a547..5f96d4be4369 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CancelResourceScope.json +# x-ms-original-file: 2024-10-01/Remediations_CancelResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py index 16bc384b1e14..8de7717877e7 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.cancel_at_subscription( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CancelSubscriptionScope.json +# x-ms-original-file: 2024-10-01/Remediations_CancelSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py index cc95c6788577..02a3aeada06f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CreateManagementGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_CreateManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py index 00134f1138c0..6d4ec56b489d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.create_or_update_at_resource_group( @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CreateResourceGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_CreateResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py index 2c74a799f13b..4bd1fd8a1fb1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -43,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CreateResourceScope.json +# x-ms-original-file: 2024-10-01/Remediations_CreateResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py index a993ab30b3d7..edd4bf250ac3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +28,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.create_or_update_at_subscription( @@ -42,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CreateSubscriptionScope.json +# x-ms-original-file: 2024-10-01/Remediations_CreateSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py index c3a670996ff9..6a37417c272d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,16 +28,19 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.create_or_update_at_subscription( remediation_name="storageRemediation", parameters={ "properties": { + "failureThreshold": {"percentage": 0.1}, "filters": {"locations": ["eastus", "westus"]}, + "parallelDeployments": 6, "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", "policyDefinitionReferenceId": "8c8fa9e4", + "resourceCount": 42, "resourceDiscoveryMode": "ReEvaluateCompliance", } }, @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_CreateSubscriptionScope_AllProperties.json +# x-ms-original-file: 2024-10-01/Remediations_CreateSubscriptionScope_AllProperties.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py new file mode 100644 index 000000000000..ce32046dc3fd --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py @@ -0,0 +1,63 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python remediations_create_subscription_scope_resource_ids_filter.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 = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.remediations.create_or_update_at_subscription( + remediation_name="storageRemediation", + parameters={ + "properties": { + "failureThreshold": {"percentage": 0.1}, + "filters": { + "locations": ["eastus", "westus"], + "resourceIds": [ + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/res2627/providers/Microsoft.Storage/storageAccounts/sto1125", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/testcmk3/providers/Microsoft.Storage/storageAccounts/sto3699", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/res9407/providers/Microsoft.Storage/storageAccounts/sto8596", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/testcmk3/providers/Microsoft.Storage/storageAccounts/sto6637", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/res8186/providers/Microsoft.Storage/storageAccounts/sto834", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/testcmk3/providers/Microsoft.Storage/storageAccounts/sto9174", + ], + }, + "parallelDeployments": 6, + "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", + "policyDefinitionReferenceId": "8c8fa9e4", + "resourceCount": 42, + "resourceDiscoveryMode": "ExistingNonCompliant", + } + }, + ) + print(response) + + +# x-ms-original-file: 2024-10-01/Remediations_CreateSubscriptionScope_ResourceIdsFilter.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py index 6b1b8cfc48a2..cde46c229bd8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_DeleteManagementGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_DeleteManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py index b24264bbb7b6..dffa821ca885 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.delete_at_resource_group( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_DeleteResourceGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_DeleteResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py index 62b082e7aca3..9bb6733fd190 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_DeleteResourceScope.json +# x-ms-original-file: 2024-10-01/Remediations_DeleteResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py index f1bb41f1fc9d..d88a02231015 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.delete_at_subscription( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_DeleteSubscriptionScope.json +# x-ms-original-file: 2024-10-01/Remediations_DeleteSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py index 97644d42cb7e..aae17a602ee8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_GetManagementGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_GetManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py index 5a97e996a053..339c09159cf3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.get_at_resource_group( @@ -38,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_GetResourceGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_GetResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py index 16c1e1dec651..314c54c29e3a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_GetResourceScope.json +# x-ms-original-file: 2024-10-01/Remediations_GetResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py index b4aecb52bc19..74bb79be921e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.get_at_subscription( @@ -37,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_GetSubscriptionScope.json +# x-ms-original-file: 2024-10-01/Remediations_GetSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py index 3b51c7ef4094..fa63d81fa222 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListDeploymentsManagementGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListDeploymentsManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py index 106cff5c5203..346bbb1298f1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.list_deployments_at_resource_group( @@ -39,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListDeploymentsResourceGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListDeploymentsResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py index b4d137f7b023..8f900a6d279b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -39,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListDeploymentsResourceScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListDeploymentsResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py index 430cef5678e5..2b76c2274002 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.list_deployments_at_subscription( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListDeploymentsSubscriptionScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListDeploymentsSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py index 25525af6f5a3..bb17aa456823 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListManagementGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py index 29db3ca87f8e..b0d3b990bd05 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListManagementGroupScope_WithQuery.json +# x-ms-original-file: 2024-10-01/Remediations_ListManagementGroupScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py index 93b9c3b29186..a31e83d72449 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.list_for_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListResourceGroupScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py index e6361b68f413..7ed464904e1f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.list_for_resource_group( @@ -38,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListResourceGroupScope_WithQuery.json +# x-ms-original-file: 2024-10-01/Remediations_ListResourceGroupScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py index 10bf5951c146..d122ea9bf85a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListResourceScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py index e083cd60aedc..6c98c6b33e71 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py @@ -3,7 +3,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListResourceScope_WithQuery.json +# x-ms-original-file: 2024-10-01/Remediations_ListResourceScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py index cc8d2f7b7f3f..1870e38ebe26 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.list_for_subscription() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListSubscriptionScope.json +# x-ms-original-file: 2024-10-01/Remediations_ListSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py index 0f80744863b9..9c2bceba422b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py @@ -1,9 +1,8 @@ -# 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -28,7 +27,7 @@ def main(): client = PolicyInsightsClient( credential=DefaultAzureCredential(), - subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + subscription_id="SUBSCRIPTION_ID", ) response = client.remediations.list_for_subscription() @@ -36,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-07-01/examples/Remediations_ListSubscriptionScope_WithQuery.json +# x-ms-original-file: 2024-10-01/Remediations_ListSubscriptionScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py index 3ca9a4ea2524..bbe3fee1c9b1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import os diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py index 3d28281e9d55..cd9ba7180826 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,11 +20,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_list_for_subscription(self, resource_group): - response = self.client.attestations.list_for_subscription( + def test_attestations_get_at_subscription(self, resource_group): + response = self.client.attestations.get_at_subscription( + attestation_name="str", api_version="2024-10-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -34,19 +35,21 @@ def test_attestations_begin_create_or_update_at_subscription(self, resource_grou response = self.client.attestations.begin_create_or_update_at_subscription( attestation_name="str", parameters={ - "policyAssignmentId": "str", - "assessmentDate": "2020-02-20 00:00:00", - "comments": "str", - "complianceState": "str", - "evidence": [{"description": "str", "sourceUri": "str"}], - "expiresOn": "2020-02-20 00:00:00", + "properties": { + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + }, "id": "str", - "lastComplianceStateChangeAt": "2020-02-20 00:00:00", - "metadata": {}, "name": "str", - "owner": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -65,8 +68,8 @@ def test_attestations_begin_create_or_update_at_subscription(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_get_at_subscription(self, resource_group): - response = self.client.attestations.get_at_subscription( + def test_attestations_delete_at_subscription(self, resource_group): + response = self.client.attestations.delete_at_subscription( attestation_name="str", api_version="2024-10-01", ) @@ -76,23 +79,23 @@ def test_attestations_get_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_delete_at_subscription(self, resource_group): - response = self.client.attestations.delete_at_subscription( - attestation_name="str", + def test_attestations_list_for_subscription(self, resource_group): + response = self.client.attestations.list_for_subscription( api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_list_for_resource_group(self, resource_group): - response = self.client.attestations.list_for_resource_group( + def test_attestations_get_at_resource_group(self, resource_group): + response = self.client.attestations.get_at_resource_group( resource_group_name=resource_group.name, + attestation_name="str", api_version="2024-10-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -103,19 +106,21 @@ def test_attestations_begin_create_or_update_at_resource_group(self, resource_gr resource_group_name=resource_group.name, attestation_name="str", parameters={ - "policyAssignmentId": "str", - "assessmentDate": "2020-02-20 00:00:00", - "comments": "str", - "complianceState": "str", - "evidence": [{"description": "str", "sourceUri": "str"}], - "expiresOn": "2020-02-20 00:00:00", + "properties": { + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + }, "id": "str", - "lastComplianceStateChangeAt": "2020-02-20 00:00:00", - "metadata": {}, "name": "str", - "owner": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -134,8 +139,8 @@ def test_attestations_begin_create_or_update_at_resource_group(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_get_at_resource_group(self, resource_group): - response = self.client.attestations.get_at_resource_group( + def test_attestations_delete_at_resource_group(self, resource_group): + response = self.client.attestations.delete_at_resource_group( resource_group_name=resource_group.name, attestation_name="str", api_version="2024-10-01", @@ -146,24 +151,24 @@ def test_attestations_get_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_delete_at_resource_group(self, resource_group): - response = self.client.attestations.delete_at_resource_group( + def test_attestations_list_for_resource_group(self, resource_group): + response = self.client.attestations.list_for_resource_group( resource_group_name=resource_group.name, - attestation_name="str", api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_list_for_resource(self, resource_group): - response = self.client.attestations.list_for_resource( + def test_attestations_get_at_resource(self, resource_group): + response = self.client.attestations.get_at_resource( resource_id="str", + attestation_name="str", api_version="2024-10-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @@ -174,19 +179,21 @@ def test_attestations_begin_create_or_update_at_resource(self, resource_group): resource_id="str", attestation_name="str", parameters={ - "policyAssignmentId": "str", - "assessmentDate": "2020-02-20 00:00:00", - "comments": "str", - "complianceState": "str", - "evidence": [{"description": "str", "sourceUri": "str"}], - "expiresOn": "2020-02-20 00:00:00", + "properties": { + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + }, "id": "str", - "lastComplianceStateChangeAt": "2020-02-20 00:00:00", - "metadata": {}, "name": "str", - "owner": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -205,8 +212,8 @@ def test_attestations_begin_create_or_update_at_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_get_at_resource(self, resource_group): - response = self.client.attestations.get_at_resource( + def test_attestations_delete_at_resource(self, resource_group): + response = self.client.attestations.delete_at_resource( resource_id="str", attestation_name="str", api_version="2024-10-01", @@ -217,12 +224,11 @@ def test_attestations_get_at_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_attestations_delete_at_resource(self, resource_group): - response = self.client.attestations.delete_at_resource( + def test_attestations_list_for_resource(self, resource_group): + response = self.client.attestations.list_for_resource( resource_id="str", - attestation_name="str", api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py index 2e6579bd0d3c..92dc528f9b99 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,11 +21,12 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_list_for_subscription(self, resource_group): - response = self.client.attestations.list_for_subscription( + async def test_attestations_get_at_subscription(self, resource_group): + response = await self.client.attestations.get_at_subscription( + attestation_name="str", api_version="2024-10-01", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -36,19 +37,21 @@ async def test_attestations_begin_create_or_update_at_subscription(self, resourc await self.client.attestations.begin_create_or_update_at_subscription( attestation_name="str", parameters={ - "policyAssignmentId": "str", - "assessmentDate": "2020-02-20 00:00:00", - "comments": "str", - "complianceState": "str", - "evidence": [{"description": "str", "sourceUri": "str"}], - "expiresOn": "2020-02-20 00:00:00", + "properties": { + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + }, "id": "str", - "lastComplianceStateChangeAt": "2020-02-20 00:00:00", - "metadata": {}, "name": "str", - "owner": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -68,8 +71,8 @@ async def test_attestations_begin_create_or_update_at_subscription(self, resourc @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_get_at_subscription(self, resource_group): - response = await self.client.attestations.get_at_subscription( + async def test_attestations_delete_at_subscription(self, resource_group): + response = await self.client.attestations.delete_at_subscription( attestation_name="str", api_version="2024-10-01", ) @@ -79,23 +82,23 @@ async def test_attestations_get_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_delete_at_subscription(self, resource_group): - response = await self.client.attestations.delete_at_subscription( - attestation_name="str", + async def test_attestations_list_for_subscription(self, resource_group): + response = self.client.attestations.list_for_subscription( api_version="2024-10-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_attestations_list_for_resource_group(self, resource_group): - response = self.client.attestations.list_for_resource_group( + async def test_attestations_get_at_resource_group(self, resource_group): + response = await self.client.attestations.get_at_resource_group( resource_group_name=resource_group.name, + attestation_name="str", api_version="2024-10-01", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -107,19 +110,21 @@ async def test_attestations_begin_create_or_update_at_resource_group(self, resou resource_group_name=resource_group.name, attestation_name="str", parameters={ - "policyAssignmentId": "str", - "assessmentDate": "2020-02-20 00:00:00", - "comments": "str", - "complianceState": "str", - "evidence": [{"description": "str", "sourceUri": "str"}], - "expiresOn": "2020-02-20 00:00:00", + "properties": { + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + }, "id": "str", - "lastComplianceStateChangeAt": "2020-02-20 00:00:00", - "metadata": {}, "name": "str", - "owner": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -139,8 +144,8 @@ async def test_attestations_begin_create_or_update_at_resource_group(self, resou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_get_at_resource_group(self, resource_group): - response = await self.client.attestations.get_at_resource_group( + async def test_attestations_delete_at_resource_group(self, resource_group): + response = await self.client.attestations.delete_at_resource_group( resource_group_name=resource_group.name, attestation_name="str", api_version="2024-10-01", @@ -151,24 +156,24 @@ async def test_attestations_get_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_delete_at_resource_group(self, resource_group): - response = await self.client.attestations.delete_at_resource_group( + async def test_attestations_list_for_resource_group(self, resource_group): + response = self.client.attestations.list_for_resource_group( resource_group_name=resource_group.name, - attestation_name="str", api_version="2024-10-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_attestations_list_for_resource(self, resource_group): - response = self.client.attestations.list_for_resource( + async def test_attestations_get_at_resource(self, resource_group): + response = await self.client.attestations.get_at_resource( resource_id="str", + attestation_name="str", api_version="2024-10-01", ) - result = [r async for r in response] + # please add some check logic here by yourself # ... @@ -180,19 +185,21 @@ async def test_attestations_begin_create_or_update_at_resource(self, resource_gr resource_id="str", attestation_name="str", parameters={ - "policyAssignmentId": "str", - "assessmentDate": "2020-02-20 00:00:00", - "comments": "str", - "complianceState": "str", - "evidence": [{"description": "str", "sourceUri": "str"}], - "expiresOn": "2020-02-20 00:00:00", + "properties": { + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + }, "id": "str", - "lastComplianceStateChangeAt": "2020-02-20 00:00:00", - "metadata": {}, "name": "str", - "owner": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", "systemData": { "createdAt": "2020-02-20 00:00:00", "createdBy": "str", @@ -212,8 +219,8 @@ async def test_attestations_begin_create_or_update_at_resource(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_get_at_resource(self, resource_group): - response = await self.client.attestations.get_at_resource( + async def test_attestations_delete_at_resource(self, resource_group): + response = await self.client.attestations.delete_at_resource( resource_id="str", attestation_name="str", api_version="2024-10-01", @@ -224,12 +231,11 @@ async def test_attestations_get_at_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_attestations_delete_at_resource(self, resource_group): - response = await self.client.attestations.delete_at_resource( + async def test_attestations_list_for_resource(self, resource_group): + response = self.client.attestations.list_for_resource( resource_id="str", - attestation_name="str", api_version="2024-10-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py index 7a4ef0dfb8bd..b38ea066cd78 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py index b6365488243f..63889a50cecf 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py index f528dd09ef5c..53166e3b0f43 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -22,7 +22,7 @@ def setup_method(self, method): @recorded_by_proxy def test_operations_list(self, resource_group): response = self.client.operations.list( - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py index 44be0610f4f4..e23b2721723d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -23,7 +23,7 @@ def setup_method(self, method): @recorded_by_proxy_async async def test_operations_list(self, resource_group): response = await self.client.operations.list( - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py index 63039e2ca753..fb75d77146ae 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,7 @@ def test_policy_events_list_query_results_for_management_group(self, resource_gr policy_events_resource="str", management_group_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -35,9 +35,9 @@ def test_policy_events_list_query_results_for_management_group(self, resource_gr @recorded_by_proxy def test_policy_events_list_query_results_for_subscription(self, resource_group): response = self.client.policy_events.list_query_results_for_subscription( - policy_events_resource="str", subscription_id="str", - api_version="2019-10-01", + policy_events_resource="str", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -47,10 +47,10 @@ def test_policy_events_list_query_results_for_subscription(self, resource_group) @recorded_by_proxy def test_policy_events_list_query_results_for_resource_group(self, resource_group): response = self.client.policy_events.list_query_results_for_resource_group( - policy_events_resource="str", subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + policy_events_resource="str", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -62,7 +62,7 @@ def test_policy_events_list_query_results_for_resource(self, resource_group): response = self.client.policy_events.list_query_results_for_resource( policy_events_resource="str", resource_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -72,11 +72,11 @@ def test_policy_events_list_query_results_for_resource(self, resource_group): @recorded_by_proxy def test_policy_events_list_query_results_for_policy_set_definition(self, resource_group): response = self.client.policy_events.list_query_results_for_policy_set_definition( - policy_events_resource="str", subscription_id="str", + policy_events_resource="str", policy_set_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -86,11 +86,11 @@ def test_policy_events_list_query_results_for_policy_set_definition(self, resour @recorded_by_proxy def test_policy_events_list_query_results_for_policy_definition(self, resource_group): response = self.client.policy_events.list_query_results_for_policy_definition( - policy_events_resource="str", subscription_id="str", + policy_events_resource="str", policy_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -100,11 +100,11 @@ def test_policy_events_list_query_results_for_policy_definition(self, resource_g @recorded_by_proxy def test_policy_events_list_query_results_for_subscription_level_policy_assignment(self, resource_group): response = self.client.policy_events.list_query_results_for_subscription_level_policy_assignment( - policy_events_resource="str", subscription_id="str", + policy_events_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -114,12 +114,12 @@ def test_policy_events_list_query_results_for_subscription_level_policy_assignme @recorded_by_proxy def test_policy_events_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): response = self.client.policy_events.list_query_results_for_resource_group_level_policy_assignment( - policy_events_resource="str", subscription_id="str", resource_group_name=resource_group.name, + policy_events_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py index 31ef6e7ddc77..cce08db66f03 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,7 @@ async def test_policy_events_list_query_results_for_management_group(self, resou policy_events_resource="str", management_group_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -36,9 +36,9 @@ async def test_policy_events_list_query_results_for_management_group(self, resou @recorded_by_proxy_async async def test_policy_events_list_query_results_for_subscription(self, resource_group): response = self.client.policy_events.list_query_results_for_subscription( - policy_events_resource="str", subscription_id="str", - api_version="2019-10-01", + policy_events_resource="str", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -48,10 +48,10 @@ async def test_policy_events_list_query_results_for_subscription(self, resource_ @recorded_by_proxy_async async def test_policy_events_list_query_results_for_resource_group(self, resource_group): response = self.client.policy_events.list_query_results_for_resource_group( - policy_events_resource="str", subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + policy_events_resource="str", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -63,7 +63,7 @@ async def test_policy_events_list_query_results_for_resource(self, resource_grou response = self.client.policy_events.list_query_results_for_resource( policy_events_resource="str", resource_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -73,11 +73,11 @@ async def test_policy_events_list_query_results_for_resource(self, resource_grou @recorded_by_proxy_async async def test_policy_events_list_query_results_for_policy_set_definition(self, resource_group): response = self.client.policy_events.list_query_results_for_policy_set_definition( - policy_events_resource="str", subscription_id="str", + policy_events_resource="str", policy_set_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -87,11 +87,11 @@ async def test_policy_events_list_query_results_for_policy_set_definition(self, @recorded_by_proxy_async async def test_policy_events_list_query_results_for_policy_definition(self, resource_group): response = self.client.policy_events.list_query_results_for_policy_definition( - policy_events_resource="str", subscription_id="str", + policy_events_resource="str", policy_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -101,11 +101,11 @@ async def test_policy_events_list_query_results_for_policy_definition(self, reso @recorded_by_proxy_async async def test_policy_events_list_query_results_for_subscription_level_policy_assignment(self, resource_group): response = self.client.policy_events.list_query_results_for_subscription_level_policy_assignment( - policy_events_resource="str", subscription_id="str", + policy_events_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -115,12 +115,12 @@ async def test_policy_events_list_query_results_for_subscription_level_policy_as @recorded_by_proxy_async async def test_policy_events_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): response = self.client.policy_events.list_query_results_for_resource_group_level_policy_assignment( - policy_events_resource="str", subscription_id="str", resource_group_name=resource_group.name, + policy_events_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py index 007822a7a07a..ca301a182338 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -23,7 +23,7 @@ def setup_method(self, method): def test_policy_metadata_get_resource(self, resource_group): response = self.client.policy_metadata.get_resource( resource_name="str", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -33,7 +33,7 @@ def test_policy_metadata_get_resource(self, resource_group): @recorded_by_proxy def test_policy_metadata_list(self, resource_group): response = self.client.policy_metadata.list( - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py index f80d1b2d5cee..35a56d5e8112 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,7 +24,7 @@ def setup_method(self, method): async def test_policy_metadata_get_resource(self, resource_group): response = await self.client.policy_metadata.get_resource( resource_name="str", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -34,7 +34,7 @@ async def test_policy_metadata_get_resource(self, resource_group): @recorded_by_proxy_async async def test_policy_metadata_list(self, resource_group): response = self.client.policy_metadata.list( - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py index e611c85f7173..4356bde06225 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -24,9 +24,10 @@ def test_policy_restrictions_check_at_subscription_scope(self, resource_group): response = self.client.policy_restrictions.check_at_subscription_scope( parameters={ "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": bool, "pendingFields": [{"field": "str", "values": ["str"]}], }, - api_version="2020-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -39,9 +40,26 @@ def test_policy_restrictions_check_at_resource_group_scope(self, resource_group) resource_group_name=resource_group.name, parameters={ "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": bool, "pendingFields": [{"field": "str", "values": ["str"]}], }, - api_version="2020-07-01", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_restrictions_check_at_management_group_scope(self, resource_group): + response = self.client.policy_restrictions.check_at_management_group_scope( + management_group_id="str", + parameters={ + "pendingFields": [{"field": "str", "values": ["str"]}], + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + }, + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py index 2c2ff9d64352..c0aa30b0bb7f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,9 +25,10 @@ async def test_policy_restrictions_check_at_subscription_scope(self, resource_gr response = await self.client.policy_restrictions.check_at_subscription_scope( parameters={ "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": bool, "pendingFields": [{"field": "str", "values": ["str"]}], }, - api_version="2020-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -40,9 +41,26 @@ async def test_policy_restrictions_check_at_resource_group_scope(self, resource_ resource_group_name=resource_group.name, parameters={ "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": bool, "pendingFields": [{"field": "str", "values": ["str"]}], }, - api_version="2020-07-01", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_restrictions_check_at_management_group_scope(self, resource_group): + response = await self.client.policy_restrictions.check_at_management_group_scope( + management_group_id="str", + parameters={ + "pendingFields": [{"field": "str", "values": ["str"]}], + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + }, + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py index 74ad2f3b6987..3a0af450d043 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -25,7 +25,7 @@ def test_policy_states_list_query_results_for_management_group(self, resource_gr policy_states_resource="str", management_group_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -38,7 +38,7 @@ def test_policy_states_summarize_for_management_group(self, resource_group): policy_states_summary_resource="str", management_group_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -48,9 +48,9 @@ def test_policy_states_summarize_for_management_group(self, resource_group): @recorded_by_proxy def test_policy_states_list_query_results_for_subscription(self, resource_group): response = self.client.policy_states.list_query_results_for_subscription( - policy_states_resource="str", subscription_id="str", - api_version="2019-10-01", + policy_states_resource="str", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -60,9 +60,9 @@ def test_policy_states_list_query_results_for_subscription(self, resource_group) @recorded_by_proxy def test_policy_states_summarize_for_subscription(self, resource_group): response = self.client.policy_states.summarize_for_subscription( - policy_states_summary_resource="str", subscription_id="str", - api_version="2019-10-01", + policy_states_summary_resource="str", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -72,10 +72,10 @@ def test_policy_states_summarize_for_subscription(self, resource_group): @recorded_by_proxy def test_policy_states_list_query_results_for_resource_group(self, resource_group): response = self.client.policy_states.list_query_results_for_resource_group( - policy_states_resource="str", subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + policy_states_resource="str", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -85,10 +85,10 @@ def test_policy_states_list_query_results_for_resource_group(self, resource_grou @recorded_by_proxy def test_policy_states_summarize_for_resource_group(self, resource_group): response = self.client.policy_states.summarize_for_resource_group( - policy_states_summary_resource="str", subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + policy_states_summary_resource="str", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -100,7 +100,7 @@ def test_policy_states_list_query_results_for_resource(self, resource_group): response = self.client.policy_states.list_query_results_for_resource( policy_states_resource="str", resource_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -112,7 +112,7 @@ def test_policy_states_summarize_for_resource(self, resource_group): response = self.client.policy_states.summarize_for_resource( policy_states_summary_resource="str", resource_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -123,7 +123,7 @@ def test_policy_states_summarize_for_resource(self, resource_group): def test_policy_states_begin_trigger_subscription_evaluation(self, resource_group): response = self.client.policy_states.begin_trigger_subscription_evaluation( subscription_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -135,7 +135,7 @@ def test_policy_states_begin_trigger_resource_group_evaluation(self, resource_gr response = self.client.policy_states.begin_trigger_resource_group_evaluation( subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + api_version="2024-10-01", ).result() # call '.result()' to poll until service return final result # please add some check logic here by yourself @@ -145,11 +145,11 @@ def test_policy_states_begin_trigger_resource_group_evaluation(self, resource_gr @recorded_by_proxy def test_policy_states_list_query_results_for_policy_set_definition(self, resource_group): response = self.client.policy_states.list_query_results_for_policy_set_definition( - policy_states_resource="str", subscription_id="str", + policy_states_resource="str", policy_set_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -159,11 +159,11 @@ def test_policy_states_list_query_results_for_policy_set_definition(self, resour @recorded_by_proxy def test_policy_states_summarize_for_policy_set_definition(self, resource_group): response = self.client.policy_states.summarize_for_policy_set_definition( - policy_states_summary_resource="str", subscription_id="str", + policy_states_summary_resource="str", policy_set_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -173,11 +173,11 @@ def test_policy_states_summarize_for_policy_set_definition(self, resource_group) @recorded_by_proxy def test_policy_states_list_query_results_for_policy_definition(self, resource_group): response = self.client.policy_states.list_query_results_for_policy_definition( - policy_states_resource="str", subscription_id="str", + policy_states_resource="str", policy_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -187,11 +187,11 @@ def test_policy_states_list_query_results_for_policy_definition(self, resource_g @recorded_by_proxy def test_policy_states_summarize_for_policy_definition(self, resource_group): response = self.client.policy_states.summarize_for_policy_definition( - policy_states_summary_resource="str", subscription_id="str", + policy_states_summary_resource="str", policy_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -201,11 +201,11 @@ def test_policy_states_summarize_for_policy_definition(self, resource_group): @recorded_by_proxy def test_policy_states_list_query_results_for_subscription_level_policy_assignment(self, resource_group): response = self.client.policy_states.list_query_results_for_subscription_level_policy_assignment( - policy_states_resource="str", subscription_id="str", + policy_states_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -215,11 +215,11 @@ def test_policy_states_list_query_results_for_subscription_level_policy_assignme @recorded_by_proxy def test_policy_states_summarize_for_subscription_level_policy_assignment(self, resource_group): response = self.client.policy_states.summarize_for_subscription_level_policy_assignment( - policy_states_summary_resource="str", subscription_id="str", + policy_states_summary_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -229,12 +229,12 @@ def test_policy_states_summarize_for_subscription_level_policy_assignment(self, @recorded_by_proxy def test_policy_states_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): response = self.client.policy_states.list_query_results_for_resource_group_level_policy_assignment( - policy_states_resource="str", subscription_id="str", resource_group_name=resource_group.name, + policy_states_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -244,12 +244,12 @@ def test_policy_states_list_query_results_for_resource_group_level_policy_assign @recorded_by_proxy def test_policy_states_summarize_for_resource_group_level_policy_assignment(self, resource_group): response = self.client.policy_states.summarize_for_resource_group_level_policy_assignment( - policy_states_summary_resource="str", subscription_id="str", resource_group_name=resource_group.name, + policy_states_summary_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py index 314a14c696e0..98f35947b1f5 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -26,7 +26,7 @@ async def test_policy_states_list_query_results_for_management_group(self, resou policy_states_resource="str", management_group_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -39,7 +39,7 @@ async def test_policy_states_summarize_for_management_group(self, resource_group policy_states_summary_resource="str", management_group_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -49,9 +49,9 @@ async def test_policy_states_summarize_for_management_group(self, resource_group @recorded_by_proxy_async async def test_policy_states_list_query_results_for_subscription(self, resource_group): response = self.client.policy_states.list_query_results_for_subscription( - policy_states_resource="str", subscription_id="str", - api_version="2019-10-01", + policy_states_resource="str", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -61,9 +61,9 @@ async def test_policy_states_list_query_results_for_subscription(self, resource_ @recorded_by_proxy_async async def test_policy_states_summarize_for_subscription(self, resource_group): response = await self.client.policy_states.summarize_for_subscription( - policy_states_summary_resource="str", subscription_id="str", - api_version="2019-10-01", + policy_states_summary_resource="str", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -73,10 +73,10 @@ async def test_policy_states_summarize_for_subscription(self, resource_group): @recorded_by_proxy_async async def test_policy_states_list_query_results_for_resource_group(self, resource_group): response = self.client.policy_states.list_query_results_for_resource_group( - policy_states_resource="str", subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + policy_states_resource="str", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -86,10 +86,10 @@ async def test_policy_states_list_query_results_for_resource_group(self, resourc @recorded_by_proxy_async async def test_policy_states_summarize_for_resource_group(self, resource_group): response = await self.client.policy_states.summarize_for_resource_group( - policy_states_summary_resource="str", subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + policy_states_summary_resource="str", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -101,7 +101,7 @@ async def test_policy_states_list_query_results_for_resource(self, resource_grou response = self.client.policy_states.list_query_results_for_resource( policy_states_resource="str", resource_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -113,7 +113,7 @@ async def test_policy_states_summarize_for_resource(self, resource_group): response = await self.client.policy_states.summarize_for_resource( policy_states_summary_resource="str", resource_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -125,7 +125,7 @@ async def test_policy_states_begin_trigger_subscription_evaluation(self, resourc response = await ( await self.client.policy_states.begin_trigger_subscription_evaluation( subscription_id="str", - api_version="2019-10-01", + api_version="2024-10-01", ) ).result() # call '.result()' to poll until service return final result @@ -139,7 +139,7 @@ async def test_policy_states_begin_trigger_resource_group_evaluation(self, resou await self.client.policy_states.begin_trigger_resource_group_evaluation( subscription_id="str", resource_group_name=resource_group.name, - api_version="2019-10-01", + api_version="2024-10-01", ) ).result() # call '.result()' to poll until service return final result @@ -150,11 +150,11 @@ async def test_policy_states_begin_trigger_resource_group_evaluation(self, resou @recorded_by_proxy_async async def test_policy_states_list_query_results_for_policy_set_definition(self, resource_group): response = self.client.policy_states.list_query_results_for_policy_set_definition( - policy_states_resource="str", subscription_id="str", + policy_states_resource="str", policy_set_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -164,11 +164,11 @@ async def test_policy_states_list_query_results_for_policy_set_definition(self, @recorded_by_proxy_async async def test_policy_states_summarize_for_policy_set_definition(self, resource_group): response = await self.client.policy_states.summarize_for_policy_set_definition( - policy_states_summary_resource="str", subscription_id="str", + policy_states_summary_resource="str", policy_set_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -178,11 +178,11 @@ async def test_policy_states_summarize_for_policy_set_definition(self, resource_ @recorded_by_proxy_async async def test_policy_states_list_query_results_for_policy_definition(self, resource_group): response = self.client.policy_states.list_query_results_for_policy_definition( - policy_states_resource="str", subscription_id="str", + policy_states_resource="str", policy_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -192,11 +192,11 @@ async def test_policy_states_list_query_results_for_policy_definition(self, reso @recorded_by_proxy_async async def test_policy_states_summarize_for_policy_definition(self, resource_group): response = await self.client.policy_states.summarize_for_policy_definition( - policy_states_summary_resource="str", subscription_id="str", + policy_states_summary_resource="str", policy_definition_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -206,11 +206,11 @@ async def test_policy_states_summarize_for_policy_definition(self, resource_grou @recorded_by_proxy_async async def test_policy_states_list_query_results_for_subscription_level_policy_assignment(self, resource_group): response = self.client.policy_states.list_query_results_for_subscription_level_policy_assignment( - policy_states_resource="str", subscription_id="str", + policy_states_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -220,11 +220,11 @@ async def test_policy_states_list_query_results_for_subscription_level_policy_as @recorded_by_proxy_async async def test_policy_states_summarize_for_subscription_level_policy_assignment(self, resource_group): response = await self.client.policy_states.summarize_for_subscription_level_policy_assignment( - policy_states_summary_resource="str", subscription_id="str", + policy_states_summary_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -234,12 +234,12 @@ async def test_policy_states_summarize_for_subscription_level_policy_assignment( @recorded_by_proxy_async async def test_policy_states_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): response = self.client.policy_states.list_query_results_for_resource_group_level_policy_assignment( - policy_states_resource="str", subscription_id="str", resource_group_name=resource_group.name, + policy_states_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -249,12 +249,12 @@ async def test_policy_states_list_query_results_for_resource_group_level_policy_ @recorded_by_proxy_async async def test_policy_states_summarize_for_resource_group_level_policy_assignment(self, resource_group): response = await self.client.policy_states.summarize_for_resource_group_level_policy_assignment( - policy_states_summary_resource="str", subscription_id="str", resource_group_name=resource_group.name, + policy_states_summary_resource="str", policy_assignment_name="str", authorization_namespace="Microsoft.Authorization", - api_version="2019-10-01", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py index 28323a580dea..53d71a375b5f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py index 4a1da9718fb4..742fd3fba115 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py index 8a106a4f6e2e..04b637a6fbea 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -20,25 +20,66 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_list_deployments_at_management_group(self, resource_group): - response = self.client.remediations.list_deployments_at_management_group( + def test_remediations_get_at_management_group(self, resource_group): + response = self.client.remediations.get_at_management_group( management_group_id="str", remediation_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_cancel_at_management_group(self, resource_group): - response = self.client.remediations.cancel_at_management_group( + def test_remediations_create_or_update_at_management_group(self, resource_group): + response = self.client.remediations.create_or_update_at_management_group( management_group_id="str", remediation_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_delete_at_management_group(self, resource_group): + response = self.client.remediations.delete_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -50,7 +91,7 @@ def test_remediations_list_for_management_group(self, resource_group): response = self.client.remediations.list_for_management_group( management_group_id="str", management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -58,25 +99,49 @@ def test_remediations_list_for_management_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_create_or_update_at_management_group(self, resource_group): - response = self.client.remediations.create_or_update_at_management_group( - management_group_id="str", + def test_remediations_get_at_subscription(self, resource_group): + response = self.client.remediations.get_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_create_or_update_at_subscription(self, resource_group): + response = self.client.remediations.create_or_update_at_subscription( remediation_name="str", parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -84,12 +149,10 @@ def test_remediations_create_or_update_at_management_group(self, resource_group) @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_get_at_management_group(self, resource_group): - response = self.client.remediations.get_at_management_group( - management_group_id="str", + def test_remediations_delete_at_subscription(self, resource_group): + response = self.client.remediations.delete_at_subscription( remediation_name="str", - management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -97,14 +160,11 @@ def test_remediations_get_at_management_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_delete_at_management_group(self, resource_group): - response = self.client.remediations.delete_at_management_group( - management_group_id="str", - remediation_name="str", - management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + def test_remediations_list_for_subscription(self, resource_group): + response = self.client.remediations.list_for_subscription( + api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -113,7 +173,7 @@ def test_remediations_delete_at_management_group(self, resource_group): def test_remediations_list_deployments_at_subscription(self, resource_group): response = self.client.remediations.list_deployments_at_subscription( remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -124,7 +184,7 @@ def test_remediations_list_deployments_at_subscription(self, resource_group): def test_remediations_cancel_at_subscription(self, resource_group): response = self.client.remediations.cancel_at_subscription( remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -132,33 +192,51 @@ def test_remediations_cancel_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_list_for_subscription(self, resource_group): - response = self.client.remediations.list_for_subscription( - api_version="2019-07-01", + def test_remediations_get_at_resource_group(self, resource_group): + response = self.client.remediations.get_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_create_or_update_at_subscription(self, resource_group): - response = self.client.remediations.create_or_update_at_subscription( + def test_remediations_create_or_update_at_resource_group(self, resource_group): + response = self.client.remediations.create_or_update_at_resource_group( + resource_group_name=resource_group.name, remediation_name="str", parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -166,10 +244,11 @@ def test_remediations_create_or_update_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_get_at_subscription(self, resource_group): - response = self.client.remediations.get_at_subscription( + def test_remediations_delete_at_resource_group(self, resource_group): + response = self.client.remediations.delete_at_resource_group( + resource_group_name=resource_group.name, remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -177,12 +256,12 @@ def test_remediations_get_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_delete_at_subscription(self, resource_group): - response = self.client.remediations.delete_at_subscription( - remediation_name="str", - api_version="2019-07-01", + def test_remediations_list_for_resource_group(self, resource_group): + response = self.client.remediations.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -192,7 +271,7 @@ def test_remediations_list_deployments_at_resource_group(self, resource_group): response = self.client.remediations.list_deployments_at_resource_group( resource_group_name=resource_group.name, remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -204,7 +283,7 @@ def test_remediations_cancel_at_resource_group(self, resource_group): response = self.client.remediations.cancel_at_resource_group( resource_group_name=resource_group.name, remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -212,35 +291,51 @@ def test_remediations_cancel_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_list_for_resource_group(self, resource_group): - response = self.client.remediations.list_for_resource_group( - resource_group_name=resource_group.name, - api_version="2019-07-01", + def test_remediations_get_at_resource(self, resource_group): + response = self.client.remediations.get_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", ) - result = [r for r in response] + # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_create_or_update_at_resource_group(self, resource_group): - response = self.client.remediations.create_or_update_at_resource_group( - resource_group_name=resource_group.name, + def test_remediations_create_or_update_at_resource(self, resource_group): + response = self.client.remediations.create_or_update_at_resource( + resource_id="str", remediation_name="str", parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -248,11 +343,11 @@ def test_remediations_create_or_update_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_get_at_resource_group(self, resource_group): - response = self.client.remediations.get_at_resource_group( - resource_group_name=resource_group.name, + def test_remediations_delete_at_resource(self, resource_group): + response = self.client.remediations.delete_at_resource( + resource_id="str", remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -260,13 +355,12 @@ def test_remediations_get_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_delete_at_resource_group(self, resource_group): - response = self.client.remediations.delete_at_resource_group( - resource_group_name=resource_group.name, - remediation_name="str", - api_version="2019-07-01", + def test_remediations_list_for_resource(self, resource_group): + response = self.client.remediations.list_for_resource( + resource_id="str", + api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @@ -276,7 +370,7 @@ def test_remediations_list_deployments_at_resource(self, resource_group): response = self.client.remediations.list_deployments_at_resource( resource_id="str", remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r for r in response] # please add some check logic here by yourself @@ -288,43 +382,7 @@ def test_remediations_cancel_at_resource(self, resource_group): response = self.client.remediations.cancel_at_resource( resource_id="str", remediation_name="str", - api_version="2019-07-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_remediations_list_for_resource(self, resource_group): - response = self.client.remediations.list_for_resource( - resource_id="str", - api_version="2019-07-01", - ) - result = [r for r in response] - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy - def test_remediations_create_or_update_at_resource(self, resource_group): - response = self.client.remediations.create_or_update_at_resource( - resource_id="str", - remediation_name="str", - parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, - "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", - "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", - "type": "str", - }, - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -332,23 +390,25 @@ def test_remediations_create_or_update_at_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_get_at_resource(self, resource_group): - response = self.client.remediations.get_at_resource( - resource_id="str", + def test_remediations_list_deployments_at_management_group(self, resource_group): + response = self.client.remediations.list_deployments_at_management_group( + management_group_id="str", remediation_name="str", - api_version="2019-07-01", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) - + result = [r for r in response] # please add some check logic here by yourself # ... @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy - def test_remediations_delete_at_resource(self, resource_group): - response = self.client.remediations.delete_at_resource( - resource_id="str", + def test_remediations_cancel_at_management_group(self, resource_group): + response = self.client.remediations.cancel_at_management_group( + management_group_id="str", remediation_name="str", - api_version="2019-07-01", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py index 7713e5b973b6..b675584841d7 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py @@ -2,7 +2,7 @@ # -------------------------------------------------------------------------- # 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. +# Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import pytest @@ -21,25 +21,66 @@ def setup_method(self, method): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_list_deployments_at_management_group(self, resource_group): - response = self.client.remediations.list_deployments_at_management_group( + async def test_remediations_get_at_management_group(self, resource_group): + response = await self.client.remediations.get_at_management_group( management_group_id="str", remediation_name="str", management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-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_remediations_cancel_at_management_group(self, resource_group): - response = await self.client.remediations.cancel_at_management_group( + async def test_remediations_create_or_update_at_management_group(self, resource_group): + response = await self.client.remediations.create_or_update_at_management_group( management_group_id="str", remediation_name="str", + parameters={ + "id": "str", + "name": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_delete_at_management_group(self, resource_group): + response = await self.client.remediations.delete_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -51,7 +92,7 @@ async def test_remediations_list_for_management_group(self, resource_group): response = self.client.remediations.list_for_management_group( management_group_id="str", management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -59,25 +100,49 @@ async def test_remediations_list_for_management_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_create_or_update_at_management_group(self, resource_group): - response = await self.client.remediations.create_or_update_at_management_group( - management_group_id="str", + async def test_remediations_get_at_subscription(self, resource_group): + response = await self.client.remediations.get_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_create_or_update_at_subscription(self, resource_group): + response = await self.client.remediations.create_or_update_at_subscription( remediation_name="str", parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -85,12 +150,10 @@ async def test_remediations_create_or_update_at_management_group(self, resource_ @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_get_at_management_group(self, resource_group): - response = await self.client.remediations.get_at_management_group( - management_group_id="str", + async def test_remediations_delete_at_subscription(self, resource_group): + response = await self.client.remediations.delete_at_subscription( remediation_name="str", - management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -98,14 +161,11 @@ async def test_remediations_get_at_management_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_delete_at_management_group(self, resource_group): - response = await self.client.remediations.delete_at_management_group( - management_group_id="str", - remediation_name="str", - management_groups_namespace="Microsoft.Management", - api_version="2019-07-01", + async def test_remediations_list_for_subscription(self, resource_group): + response = self.client.remediations.list_for_subscription( + api_version="2024-10-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -114,7 +174,7 @@ async def test_remediations_delete_at_management_group(self, resource_group): async def test_remediations_list_deployments_at_subscription(self, resource_group): response = self.client.remediations.list_deployments_at_subscription( remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -125,7 +185,7 @@ async def test_remediations_list_deployments_at_subscription(self, resource_grou async def test_remediations_cancel_at_subscription(self, resource_group): response = await self.client.remediations.cancel_at_subscription( remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -133,33 +193,51 @@ async def test_remediations_cancel_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_list_for_subscription(self, resource_group): - response = self.client.remediations.list_for_subscription( - api_version="2019-07-01", + async def test_remediations_get_at_resource_group(self, resource_group): + response = await self.client.remediations.get_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-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_remediations_create_or_update_at_subscription(self, resource_group): - response = await self.client.remediations.create_or_update_at_subscription( + async def test_remediations_create_or_update_at_resource_group(self, resource_group): + response = await self.client.remediations.create_or_update_at_resource_group( + resource_group_name=resource_group.name, remediation_name="str", parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -167,10 +245,11 @@ async def test_remediations_create_or_update_at_subscription(self, resource_grou @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_get_at_subscription(self, resource_group): - response = await self.client.remediations.get_at_subscription( + async def test_remediations_delete_at_resource_group(self, resource_group): + response = await self.client.remediations.delete_at_resource_group( + resource_group_name=resource_group.name, remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -178,12 +257,12 @@ async def test_remediations_get_at_subscription(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_delete_at_subscription(self, resource_group): - response = await self.client.remediations.delete_at_subscription( - remediation_name="str", - api_version="2019-07-01", + async def test_remediations_list_for_resource_group(self, resource_group): + response = self.client.remediations.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -193,7 +272,7 @@ async def test_remediations_list_deployments_at_resource_group(self, resource_gr response = self.client.remediations.list_deployments_at_resource_group( resource_group_name=resource_group.name, remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -205,7 +284,7 @@ async def test_remediations_cancel_at_resource_group(self, resource_group): response = await self.client.remediations.cancel_at_resource_group( resource_group_name=resource_group.name, remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -213,35 +292,51 @@ async def test_remediations_cancel_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_list_for_resource_group(self, resource_group): - response = self.client.remediations.list_for_resource_group( - resource_group_name=resource_group.name, - api_version="2019-07-01", + async def test_remediations_get_at_resource(self, resource_group): + response = await self.client.remediations.get_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-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_remediations_create_or_update_at_resource_group(self, resource_group): - response = await self.client.remediations.create_or_update_at_resource_group( - resource_group_name=resource_group.name, + async def test_remediations_create_or_update_at_resource(self, resource_group): + response = await self.client.remediations.create_or_update_at_resource( + resource_id="str", remediation_name="str", parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", + "properties": { + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "lastUpdatedOn": "2020-02-20 00:00:00", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, "type": "str", }, - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -249,11 +344,11 @@ async def test_remediations_create_or_update_at_resource_group(self, resource_gr @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_get_at_resource_group(self, resource_group): - response = await self.client.remediations.get_at_resource_group( - resource_group_name=resource_group.name, + async def test_remediations_delete_at_resource(self, resource_group): + response = await self.client.remediations.delete_at_resource( + resource_id="str", remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -261,13 +356,12 @@ async def test_remediations_get_at_resource_group(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_delete_at_resource_group(self, resource_group): - response = await self.client.remediations.delete_at_resource_group( - resource_group_name=resource_group.name, - remediation_name="str", - api_version="2019-07-01", + async def test_remediations_list_for_resource(self, resource_group): + response = self.client.remediations.list_for_resource( + resource_id="str", + api_version="2024-10-01", ) - + result = [r async for r in response] # please add some check logic here by yourself # ... @@ -277,7 +371,7 @@ async def test_remediations_list_deployments_at_resource(self, resource_group): response = self.client.remediations.list_deployments_at_resource( resource_id="str", remediation_name="str", - api_version="2019-07-01", + api_version="2024-10-01", ) result = [r async for r in response] # please add some check logic here by yourself @@ -289,43 +383,7 @@ async def test_remediations_cancel_at_resource(self, resource_group): response = await self.client.remediations.cancel_at_resource( resource_id="str", remediation_name="str", - api_version="2019-07-01", - ) - - # please add some check logic here by yourself - # ... - - @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) - @recorded_by_proxy_async - async def test_remediations_list_for_resource(self, resource_group): - response = self.client.remediations.list_for_resource( - resource_id="str", - api_version="2019-07-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_remediations_create_or_update_at_resource(self, resource_group): - response = await self.client.remediations.create_or_update_at_resource( - resource_id="str", - remediation_name="str", - parameters={ - "createdOn": "2020-02-20 00:00:00", - "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, - "filters": {"locations": ["str"]}, - "id": "str", - "lastUpdatedOn": "2020-02-20 00:00:00", - "name": "str", - "policyAssignmentId": "str", - "policyDefinitionReferenceId": "str", - "provisioningState": "str", - "resourceDiscoveryMode": "str", - "type": "str", - }, - api_version="2019-07-01", + api_version="2024-10-01", ) # please add some check logic here by yourself @@ -333,23 +391,25 @@ async def test_remediations_create_or_update_at_resource(self, resource_group): @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) @recorded_by_proxy_async - async def test_remediations_get_at_resource(self, resource_group): - response = await self.client.remediations.get_at_resource( - resource_id="str", + async def test_remediations_list_deployments_at_management_group(self, resource_group): + response = self.client.remediations.list_deployments_at_management_group( + management_group_id="str", remediation_name="str", - api_version="2019-07-01", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-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_remediations_delete_at_resource(self, resource_group): - response = await self.client.remediations.delete_at_resource( - resource_id="str", + async def test_remediations_cancel_at_management_group(self, resource_group): + response = await self.client.remediations.cancel_at_management_group( + management_group_id="str", remediation_name="str", - api_version="2019-07-01", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", ) # please add some check logic here by yourself diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/pyproject.toml b/sdk/policyinsights/azure-mgmt-policyinsights/pyproject.toml index ac9f139e7d4b..11e5aa4ec106 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/pyproject.toml +++ b/sdk/policyinsights/azure-mgmt-policyinsights/pyproject.toml @@ -13,17 +13,16 @@ authors = [ description = "Microsoft Azure Policyinsights Management Client Library for Python" license = "MIT" classifiers = [ - "Development Status :: 5 - Production/Stable", + "Development Status :: 4 - Beta", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", ] -requires-python = ">=3.9" +requires-python = ">=3.10" keywords = [ "azure", "azure sdk", @@ -79,7 +78,7 @@ package_name = "azure-mgmt-policyinsights" package_nspkg = "azure-mgmt-nspkg" package_pprint_name = "Policy Insights" package_doc_id = "" -is_stable = true +is_stable = false is_arm = true sample_link = "" title = "PolicyInsightsClient" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/tsp-location.yaml b/sdk/policyinsights/azure-mgmt-policyinsights/tsp-location.yaml new file mode 100644 index 000000000000..fa4aec466f91 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/PolicyInsights +commit: cb62053a18882dd258d9922be9770702b7ef6ac9 +repo: Azure/azure-rest-api-specs +additionalDirectories: