From 00d2bea2a63f5de9aea92f8f8409fd2ffd2ee05f Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 21 Feb 2018 20:21:51 +0000 Subject: [PATCH 1/4] Generated from 1a6e1a0fe97a248cfea4062bc096bcdadc6d23fc Swagger specs for all existing versions of Microsoft.PolicyInsights --- .../azure/mgmt/policyinsights/__init__.py | 18 + .../mgmt/policyinsights/models/__init__.py | 48 + .../mgmt/policyinsights/models/operation.py | 32 + .../models/operation_display.py | 40 + .../mgmt/policyinsights/models/operations.py | 28 + .../models/policy_assignment_summary.py | 42 + .../models/policy_definition_summary.py | 36 + .../policyinsights/models/policy_event.py | 154 ++ .../models/policy_events_query_results.py | 42 + .../models/policy_insights_client_enums.py | 18 + .../policyinsights/models/policy_state.py | 145 ++ .../models/policy_states_query_results.py | 42 + .../policyinsights/models/query_failure.py | 41 + .../models/query_failure_error.py | 33 + .../policyinsights/models/query_options.py | 49 + .../models/summarize_results.py | 42 + .../mgmt/policyinsights/models/summary.py | 43 + .../policyinsights/models/summary_results.py | 43 + .../policyinsights/operations/__init__.py | 20 + .../operations/policy_events_operations.py | 775 +++++++++ .../operations/policy_insights_operations.py | 88 ++ .../operations/policy_states_operations.py | 1390 +++++++++++++++++ .../policyinsights/policy_insights_client.py | 84 + .../azure/mgmt/policyinsights/version.py | 13 + 24 files changed, 3266 insertions(+) create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_insights_client_enums.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_insights_operations.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py create mode 100644 azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py new file mode 100644 index 000000000000..3587c19cedfc --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py @@ -0,0 +1,18 @@ +# 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 .policy_insights_client import PolicyInsightsClient +from .version import VERSION + +__all__ = ['PolicyInsightsClient'] + +__version__ = VERSION + diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py new file mode 100644 index 000000000000..169c632f046c --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py @@ -0,0 +1,48 @@ +# 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 .policy_event import PolicyEvent +from .policy_events_query_results import PolicyEventsQueryResults +from .query_failure_error import QueryFailureError +from .query_failure import QueryFailure, QueryFailureException +from .operation_display import OperationDisplay +from .operation import Operation +from .operations import Operations +from .policy_state import PolicyState +from .policy_states_query_results import PolicyStatesQueryResults +from .summary_results import SummaryResults +from .policy_definition_summary import PolicyDefinitionSummary +from .policy_assignment_summary import PolicyAssignmentSummary +from .summary import Summary +from .summarize_results import SummarizeResults +from .query_options import QueryOptions +from .policy_insights_client_enums import ( + PolicyStatesResource, +) + +__all__ = [ + 'PolicyEvent', + 'PolicyEventsQueryResults', + 'QueryFailureError', + 'QueryFailure', 'QueryFailureException', + 'OperationDisplay', + 'Operation', + 'Operations', + 'PolicyState', + 'PolicyStatesQueryResults', + 'SummaryResults', + 'PolicyDefinitionSummary', + 'PolicyAssignmentSummary', + 'Summary', + 'SummarizeResults', + 'QueryOptions', + 'PolicyStatesResource', +] diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation.py new file mode 100644 index 000000000000..fc8cb4e12bf3 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation.py @@ -0,0 +1,32 @@ +# 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 msrest.serialization import Model + + +class Operation(Model): + """Operation definition. + + :param name: Operation name. + :type name: str + :param display: Display metadata associated with the operation. + :type display: ~azure.mgmt.policyinsights.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, name=None, display=None): + super(Operation, self).__init__() + self.name = name + self.display = display diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display.py new file mode 100644 index 000000000000..6de9fa30d6a6 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class OperationDisplay(Model): + """Display metadata associated with the operation. + + :param provider: Resource provider name. + :type provider: str + :param resource: Resource name on which the operation is performed. + :type resource: str + :param operation: Operation name. + :type operation: str + :param description: Operation description. + :type 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=None, resource=None, operation=None, description=None): + super(OperationDisplay, self).__init__() + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py new file mode 100644 index 000000000000..c14b6e8cae0c --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py @@ -0,0 +1,28 @@ +# 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 msrest.serialization import Model + + +class Operations(Model): + """List of available operations. + + :param value: List of available operations. + :type value: list[~azure.mgmt.policyinsights.models.Operation] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + } + + def __init__(self, value=None): + super(Operations, self).__init__() + self.value = value diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary.py new file mode 100644 index 000000000000..34b43a35dbc6 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PolicyAssignmentSummary(Model): + """Policy assignment summary. + + :param policy_assignment_id: Policy assignment ID. + :type policy_assignment_id: str + :param policy_set_definition_id: Policy set definition ID, if the policy + assignment is for a policy set. + :type policy_set_definition_id: str + :param results: Non-compliance summary for the policy assignment. + :type results: ~azure.mgmt.policyinsights.models.SummaryResults + :param policy_definitions: Policy definitions summary. + :type policy_definitions: + list[~azure.mgmt.policyinsights.models.PolicyDefinitionSummary] + """ + + _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]'}, + } + + def __init__(self, policy_assignment_id=None, policy_set_definition_id=None, results=None, policy_definitions=None): + super(PolicyAssignmentSummary, self).__init__() + self.policy_assignment_id = policy_assignment_id + self.policy_set_definition_id = policy_set_definition_id + self.results = results + self.policy_definitions = policy_definitions diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary.py new file mode 100644 index 000000000000..7a34ceb8001a --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary.py @@ -0,0 +1,36 @@ +# 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 msrest.serialization import Model + + +class PolicyDefinitionSummary(Model): + """Policy definition summary. + + :param policy_definition_id: Policy definition ID. + :type policy_definition_id: str + :param effect: Policy effect, i.e. policy definition action. + :type effect: str + :param results: Non-compliance summary for the policy definition. + :type results: ~azure.mgmt.policyinsights.models.SummaryResults + """ + + _attribute_map = { + 'policy_definition_id': {'key': 'policyDefinitionId', 'type': 'str'}, + 'effect': {'key': 'effect', 'type': 'str'}, + 'results': {'key': 'results', 'type': 'SummaryResults'}, + } + + def __init__(self, policy_definition_id=None, effect=None, results=None): + super(PolicyDefinitionSummary, self).__init__() + self.policy_definition_id = policy_definition_id + self.effect = effect + self.results = results diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py new file mode 100644 index 000000000000..267875115603 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py @@ -0,0 +1,154 @@ +# 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 msrest.serialization import Model + + +class PolicyEvent(Model): + """Policy event record. + + :param odataid: OData entity ID; always set to null since policy event + records do not have an entity ID. + :type odataid: str + :param odatacontext: OData context string; used by OData clients to + resolve type information based on metadata. + :type odatacontext: str + :param timestamp: Timestamp for the policy event record. + :type timestamp: datetime + :param resource_id: Resource ID. + :type resource_id: str + :param policy_assignment_id: Policy assignment ID. + :type policy_assignment_id: str + :param policy_definition_id: Policy definition ID. + :type policy_definition_id: str + :param effective_parameters: Effective parameters for the policy + assignment. + :type effective_parameters: str + :param is_compliant: Flag which states whether the resource is compliant + against the policy assignment it was evaluated against. + :type is_compliant: bool + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_type: Resource type. + :type resource_type: str + :param resource_location: Resource location. + :type resource_location: str + :param resource_group: Resource group name. + :type resource_group: str + :param resource_tags: List of resource tags. + :type resource_tags: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str + :param policy_assignment_owner: Policy assignment owner. + :type policy_assignment_owner: str + :param policy_assignment_parameters: Policy assignment parameters. + :type policy_assignment_parameters: str + :param policy_assignment_scope: Policy assignment scope. + :type policy_assignment_scope: str + :param policy_definition_name: Policy definition name. + :type policy_definition_name: str + :param policy_definition_action: Policy definition action, i.e. effect. + :type policy_definition_action: str + :param policy_definition_category: Policy definition category. + :type policy_definition_category: str + :param policy_set_definition_id: Policy set definition ID, if the policy + assignment is for a policy set. + :type policy_set_definition_id: str + :param policy_set_definition_name: Policy set definition name, if the + policy assignment is for a policy set. + :type policy_set_definition_name: str + :param policy_set_definition_owner: Policy set definition owner, if the + policy assignment is for a policy set. + :type policy_set_definition_owner: str + :param policy_set_definition_category: Policy set definition category, if + the policy assignment is for a policy set. + :type policy_set_definition_category: str + :param policy_set_definition_parameters: Policy set definition parameters, + if the policy assignment is for a policy set. + :type policy_set_definition_parameters: str + :param management_group_ids: Comma seperated list of management group IDs, + which represent the hierarchy of the management groups the resource is + under. + :type management_group_ids: str + :param policy_definition_reference_id: Reference ID for the policy + definition inside the policy set, if the policy assignment is for a policy + set. + :type policy_definition_reference_id: str + :param tenant_id: Tenant ID for the policy event record. + :type tenant_id: str + :param principal_oid: Principal object ID for the user who initiated the + resource operation that triggered the policy event. + :type principal_oid: str + """ + + _attribute_map = { + 'odataid': {'key': '@odata\\.id', 'type': 'str'}, + 'odatacontext': {'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'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'principal_oid': {'key': 'principalOid', 'type': 'str'}, + } + + def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, tenant_id=None, principal_oid=None): + super(PolicyEvent, self).__init__() + self.odataid = odataid + self.odatacontext = odatacontext + 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.tenant_id = tenant_id + self.principal_oid = principal_oid diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results.py new file mode 100644 index 000000000000..35fd1968abe7 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PolicyEventsQueryResults(Model): + """Query results. + + :param odatacontext: OData context string; used by OData clients to + resolve type information based on metadata. + :type odatacontext: str + :param odatacount: OData entity count; represents the number of policy + event records returned. + :type odatacount: int + :param value: Query results. + :type value: list[~azure.mgmt.policyinsights.models.PolicyEvent] + """ + + _validation = { + 'odatacount': {'minimum': 0}, + } + + _attribute_map = { + 'odatacontext': {'key': '@odata\\.context', 'type': 'str'}, + 'odatacount': {'key': '@odata\\.count', 'type': 'int'}, + 'value': {'key': 'value', 'type': '[PolicyEvent]'}, + } + + def __init__(self, odatacontext=None, odatacount=None, value=None): + super(PolicyEventsQueryResults, self).__init__() + self.odatacontext = odatacontext + self.odatacount = odatacount + self.value = value diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_insights_client_enums.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_insights_client_enums.py new file mode 100644 index 000000000000..9c9cff3f2fff --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_insights_client_enums.py @@ -0,0 +1,18 @@ +# 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 enum import Enum + + +class PolicyStatesResource(Enum): + + default = "default" + latest = "latest" diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py new file mode 100644 index 000000000000..be7151e7d7c4 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py @@ -0,0 +1,145 @@ +# 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 msrest.serialization import Model + + +class PolicyState(Model): + """Policy state record. + + :param odataid: OData entity ID; always set to null since policy state + records do not have an entity ID. + :type odataid: str + :param odatacontext: OData context string; used by OData clients to + resolve type information based on metadata. + :type odatacontext: str + :param timestamp: Timestamp for the policy state record. + :type timestamp: datetime + :param resource_id: Resource ID. + :type resource_id: str + :param policy_assignment_id: Policy assignment ID. + :type policy_assignment_id: str + :param policy_definition_id: Policy definition ID. + :type policy_definition_id: str + :param effective_parameters: Effective parameters for the policy + assignment. + :type effective_parameters: str + :param is_compliant: Flag which states whether the resource is compliant + against the policy assignment it was evaluated against. + :type is_compliant: bool + :param subscription_id: Subscription ID. + :type subscription_id: str + :param resource_type: Resource type. + :type resource_type: str + :param resource_location: Resource location. + :type resource_location: str + :param resource_group: Resource group name. + :type resource_group: str + :param resource_tags: List of resource tags. + :type resource_tags: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str + :param policy_assignment_owner: Policy assignment owner. + :type policy_assignment_owner: str + :param policy_assignment_parameters: Policy assignment parameters. + :type policy_assignment_parameters: str + :param policy_assignment_scope: Policy assignment scope. + :type policy_assignment_scope: str + :param policy_definition_name: Policy definition name. + :type policy_definition_name: str + :param policy_definition_action: Policy definition action, i.e. effect. + :type policy_definition_action: str + :param policy_definition_category: Policy definition category. + :type policy_definition_category: str + :param policy_set_definition_id: Policy set definition ID, if the policy + assignment is for a policy set. + :type policy_set_definition_id: str + :param policy_set_definition_name: Policy set definition name, if the + policy assignment is for a policy set. + :type policy_set_definition_name: str + :param policy_set_definition_owner: Policy set definition owner, if the + policy assignment is for a policy set. + :type policy_set_definition_owner: str + :param policy_set_definition_category: Policy set definition category, if + the policy assignment is for a policy set. + :type policy_set_definition_category: str + :param policy_set_definition_parameters: Policy set definition parameters, + if the policy assignment is for a policy set. + :type policy_set_definition_parameters: str + :param management_group_ids: Comma seperated list of management group IDs, + which represent the hierarchy of the management groups the resource is + under. + :type management_group_ids: str + :param policy_definition_reference_id: Reference ID for the policy + definition inside the policy set, if the policy assignment is for a policy + set. + :type policy_definition_reference_id: str + """ + + _attribute_map = { + 'odataid': {'key': '@odata\\.id', 'type': 'str'}, + 'odatacontext': {'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'}, + } + + def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None): + super(PolicyState, self).__init__() + self.odataid = odataid + self.odatacontext = odatacontext + 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 diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results.py new file mode 100644 index 000000000000..d9ae80535a52 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PolicyStatesQueryResults(Model): + """Query results. + + :param odatacontext: OData context string; used by OData clients to + resolve type information based on metadata. + :type odatacontext: str + :param odatacount: OData entity count; represents the number of policy + state records returned. + :type odatacount: int + :param value: Query results. + :type value: list[~azure.mgmt.policyinsights.models.PolicyState] + """ + + _validation = { + 'odatacount': {'minimum': 0}, + } + + _attribute_map = { + 'odatacontext': {'key': '@odata\\.context', 'type': 'str'}, + 'odatacount': {'key': '@odata\\.count', 'type': 'int'}, + 'value': {'key': 'value', 'type': '[PolicyState]'}, + } + + def __init__(self, odatacontext=None, odatacount=None, value=None): + super(PolicyStatesQueryResults, self).__init__() + self.odatacontext = odatacontext + self.odatacount = odatacount + self.value = value diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure.py new file mode 100644 index 000000000000..0c9602e55730 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class QueryFailure(Model): + """Error response. + + :param error: Error definition. + :type error: ~azure.mgmt.policyinsights.models.QueryFailureError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'QueryFailureError'}, + } + + def __init__(self, error=None): + super(QueryFailure, self).__init__() + self.error = error + + +class QueryFailureException(HttpOperationError): + """Server responsed with exception of type: 'QueryFailure'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(QueryFailureException, self).__init__(deserialize, response, 'QueryFailure', *args) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error.py new file mode 100644 index 000000000000..9788a5bf0c37 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error.py @@ -0,0 +1,33 @@ +# 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 msrest.serialization import Model + + +class QueryFailureError(Model): + """Error definition. + + :param code: Service specific error code which serves as the substatus for + the HTTP error code. + :type code: str + :param message: Description of the error. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, code=None, message=None): + super(QueryFailureError, self).__init__() + self.code = code + self.message = message diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options.py new file mode 100644 index 000000000000..37d10da18767 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options.py @@ -0,0 +1,49 @@ +# 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 msrest.serialization import Model + + +class QueryOptions(Model): + """Additional parameters for a set of operations. + + :param top: Maximum number of records to return. + :type top: int + :param 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". + :type order_by: str + :param select: Select expression using OData notation. Limits the columns + on each record to just those requested, e.g. "$select=PolicyAssignmentId, + ResourceId". + :type select: str + :param from_property: ISO 8601 formatted timestamp specifying the start + time of the interval to query. When not specified, the service uses ($to - + 1-day). + :type from_property: datetime + :param to: ISO 8601 formatted timestamp specifying the end time of the + interval to query. When not specified, the service uses request time. + :type to: datetime + :param filter: OData filter expression. + :type filter: str + :param apply: OData apply expression for aggregations. + :type apply: str + """ + + def __init__(self, top=None, order_by=None, select=None, from_property=None, to=None, filter=None, apply=None): + super(QueryOptions, self).__init__() + self.top = top + self.order_by = order_by + self.select = select + self.from_property = from_property + self.to = to + self.filter = filter + self.apply = apply diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results.py new file mode 100644 index 000000000000..c48f02b73115 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SummarizeResults(Model): + """Summarize action results. + + :param odatacontext: OData context string; used by OData clients to + resolve type information based on metadata. + :type odatacontext: str + :param odatacount: OData entity count; represents the number of summaries + returned; always set to 1. + :type odatacount: int + :param value: Summarize action results. + :type value: list[~azure.mgmt.policyinsights.models.Summary] + """ + + _validation = { + 'odatacount': {'maximum': 1, 'minimum': 1}, + } + + _attribute_map = { + 'odatacontext': {'key': '@odata\\.context', 'type': 'str'}, + 'odatacount': {'key': '@odata\\.count', 'type': 'int'}, + 'value': {'key': 'value', 'type': '[Summary]'}, + } + + def __init__(self, odatacontext=None, odatacount=None, value=None): + super(SummarizeResults, self).__init__() + self.odatacontext = odatacontext + self.odatacount = odatacount + self.value = value diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary.py new file mode 100644 index 000000000000..c93d58f55d4b --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Summary(Model): + """Summary results. + + :param odataid: OData entity ID; always set to null since summaries do not + have an entity ID. + :type odataid: str + :param odatacontext: OData context string; used by OData clients to + resolve type information based on metadata. + :type odatacontext: str + :param results: Non-compliance summary for all policy assignments. + :type results: ~azure.mgmt.policyinsights.models.SummaryResults + :param policy_assignments: Policy assignments summary. + :type policy_assignments: + list[~azure.mgmt.policyinsights.models.PolicyAssignmentSummary] + """ + + _attribute_map = { + 'odataid': {'key': '@odata\\.id', 'type': 'str'}, + 'odatacontext': {'key': '@odata\\.context', 'type': 'str'}, + 'results': {'key': 'results', 'type': 'SummaryResults'}, + 'policy_assignments': {'key': 'policyAssignments', 'type': '[PolicyAssignmentSummary]'}, + } + + def __init__(self, odataid=None, odatacontext=None, results=None, policy_assignments=None): + super(Summary, self).__init__() + self.odataid = odataid + self.odatacontext = odatacontext + self.results = results + self.policy_assignments = policy_assignments diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results.py new file mode 100644 index 000000000000..2f97a1edf62a --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results.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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class SummaryResults(Model): + """Non-compliance summary on a particular summary level. + + :param query_results_uri: HTTP POST URI for queryResults action on + Microsoft.PolicyInsights to retrieve raw results for the non-compliance + summary. + :type query_results_uri: str + :param non_compliant_resources: Number of non-compliant resources. + :type non_compliant_resources: int + :param non_compliant_policies: Number of non-compliant policies. + :type non_compliant_policies: int + """ + + _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'}, + } + + def __init__(self, query_results_uri=None, non_compliant_resources=None, non_compliant_policies=None): + super(SummaryResults, self).__init__() + self.query_results_uri = query_results_uri + self.non_compliant_resources = non_compliant_resources + self.non_compliant_policies = non_compliant_policies diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py new file mode 100644 index 000000000000..17712904e12d --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py @@ -0,0 +1,20 @@ +# 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 .policy_events_operations import PolicyEventsOperations +from .policy_insights_operations import PolicyInsightsOperations +from .policy_states_operations import PolicyStatesOperations + +__all__ = [ + 'PolicyEventsOperations', + 'PolicyInsightsOperations', + 'PolicyStatesOperations', +] diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py new file mode 100644 index 000000000000..f9e04c568e84 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py @@ -0,0 +1,775 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class PolicyEventsOperations(object): + """PolicyEventsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar policy_events_resource: The name of the virtual resource under PolicyEvents resource type; only "default" is allowed. Constant value: "default". + :ivar api_version: API version to use with the client requests. Constant value: "2017-12-12-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.policy_events_resource = "default" + self.api_version = "2017-12-12-preview" + + self.config = config + + def list_query_results_for_management_group( + self, management_group_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the resources under the management group. + + :param management_group_id: Management group ID, e.g. + /providers/Microsoft.Management/managementGroups/{name}. + :type management_group_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_management_group.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_management_group.metadata = {'url': '/{managementGroupId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_subscription( + self, subscription_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the resources under the subscription. + + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_subscription.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_resource_group( + self, subscription_id, resource_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the resources under the resource group. + + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_resource_group.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_resource( + self, resource_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the resource. + + :param resource_id: Resource ID. + :type resource_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_resource.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_policy_set_definition( + self, policy_set_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the policy set definition. + + :param policy_set_definition_id: Subscription level policy set + definition ID. + :type policy_set_definition_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_policy_set_definition.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'policySetDefinitionId': self._serialize.url("policy_set_definition_id", policy_set_definition_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_set_definition.metadata = {'url': '/{policySetDefinitionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_policy_definition( + self, policy_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the policy definition. + + :param policy_definition_id: Subscription level policy definition ID. + :type policy_definition_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_policy_definition.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'policyDefinitionId': self._serialize.url("policy_definition_id", policy_definition_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_definition.metadata = {'url': '/{policyDefinitionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_policy_assignment( + self, policy_assignment_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the policy assignment. + + :param policy_assignment_id: Subscription level or a resource group + level policy assignment ID. + :type policy_assignment_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_policy_assignment.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_assignment.metadata = {'url': '/{policyAssignmentId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def get_metadata( + self, scope, custom_headers=None, raw=False, **operation_config): + """Gets OData metadata XML document. + + :param scope: A valid scope, i.e. management group, subscription, + resource group, or resource ID. Scope used has no effect on metadata + returned. + :type scope: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: str or ClientRawResponse if raw=true + :rtype: str or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + # Construct URL + url = self.get_metadata.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('str', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_metadata.metadata = {'url': '/{scope}/providers/Microsoft.PolicyInsights/policyEvents/$metadata'} diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_insights_operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_insights_operations.py new file mode 100644 index 000000000000..fe716d973117 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_insights_operations.py @@ -0,0 +1,88 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class PolicyInsightsOperations(object): + """PolicyInsightsOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: API version to use with the client requests. Constant value: "2017-12-12-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-12-12-preview" + + self.config = config + + def list_operations( + self, custom_headers=None, raw=False, **operation_config): + """Lists available operations. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: Operations or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.Operations or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + # Construct URL + url = self.list_operations.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('Operations', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_operations.metadata = {'url': '/providers/Microsoft.PolicyInsights/operations'} diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py new file mode 100644 index 000000000000..ad202677b5ae --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py @@ -0,0 +1,1390 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class PolicyStatesOperations(object): + """PolicyStatesOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: API version to use with the client requests. Constant value: "2017-12-12-preview". + :ivar 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. Constant value: "latest". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2017-12-12-preview" + self.policy_states_summary_resource = "latest" + + self.config = config + + def list_query_results_for_management_group( + self, policy_states_resource, management_group_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param management_group_id: Management group ID, e.g. + /providers/Microsoft.Management/managementGroups/{name}. + :type management_group_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_management_group.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_management_group.metadata = {'url': '/{managementGroupId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_management_group( + self, management_group_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the resources under the management group. + + :param management_group_id: Management group ID, e.g. + /providers/Microsoft.Management/managementGroups/{name}. + :type management_group_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_management_group.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_management_group.metadata = {'url': '/{managementGroupId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_subscription( + self, policy_states_resource, subscription_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_subscription.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_subscription( + self, subscription_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the resources under the subscription. + + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_subscription.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_resource_group( + self, policy_states_resource, subscription_id, resource_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_resource_group.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_resource_group( + self, subscription_id, resource_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the resources under the resource group. + + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_resource_group.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_resource( + self, policy_states_resource, resource_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param resource_id: Resource ID. + :type resource_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_resource.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_resource( + self, resource_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the resource. + + :param resource_id: Resource ID. + :type resource_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_resource.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_policy_set_definition( + self, policy_states_resource, policy_set_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy states for the 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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_set_definition_id: Subscription level policy set + definition ID. + :type policy_set_definition_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_policy_set_definition.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'policySetDefinitionId': self._serialize.url("policy_set_definition_id", policy_set_definition_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_set_definition.metadata = {'url': '/{policySetDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_policy_set_definition( + self, policy_set_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the policy set definition. + + :param policy_set_definition_id: Subscription level policy set + definition ID. + :type policy_set_definition_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_policy_set_definition.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'policySetDefinitionId': self._serialize.url("policy_set_definition_id", policy_set_definition_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_policy_set_definition.metadata = {'url': '/{policySetDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_policy_definition( + self, policy_states_resource, policy_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy states for the 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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_definition_id: Subscription level policy definition ID. + :type policy_definition_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_policy_definition.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'policyDefinitionId': self._serialize.url("policy_definition_id", policy_definition_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_definition.metadata = {'url': '/{policyDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_policy_definition( + self, policy_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the policy definition. + + :param policy_definition_id: Subscription level policy definition ID. + :type policy_definition_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_policy_definition.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'policyDefinitionId': self._serialize.url("policy_definition_id", policy_definition_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_policy_definition.metadata = {'url': '/{policyDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_policy_assignment( + self, policy_states_resource, policy_assignment_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy states for the 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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param policy_assignment_id: Subscription level or a resource group + level policy assignment ID. + :type policy_assignment_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_policy_assignment.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_assignment.metadata = {'url': '/{policyAssignmentId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_policy_assignment( + self, policy_assignment_id, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the policy assignment. + + :param policy_assignment_id: Subscription level or a resource group + level policy assignment ID. + :type policy_assignment_id: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_policy_assignment.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_policy_assignment.metadata = {'url': '/{policyAssignmentId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def get_metadata( + self, scope, custom_headers=None, raw=False, **operation_config): + """Gets OData metadata XML document. + + :param scope: A valid scope, i.e. management group, subscription, + resource group, or resource ID. Scope used has no effect on metadata + returned. + :type scope: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: str or ClientRawResponse if raw=true + :rtype: str or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + # Construct URL + url = self.get_metadata.metadata['url'] + path_format_arguments = { + 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('str', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_metadata.metadata = {'url': '/{scope}/providers/Microsoft.PolicyInsights/policyStates/$metadata'} diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py new file mode 100644 index 000000000000..293d73bd5681 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py @@ -0,0 +1,84 @@ +# 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 msrest.service_client import ServiceClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from .operations.policy_events_operations import PolicyEventsOperations +from .operations.policy_insights_operations import PolicyInsightsOperations +from .operations.policy_states_operations import PolicyStatesOperations +from . import models + + +class PolicyInsightsClientConfiguration(AzureConfiguration): + """Configuration for PolicyInsightsClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(PolicyInsightsClientConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-mgmt-policyinsights/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + + +class PolicyInsightsClient(object): + """PolicyInsightsClient + + :ivar config: Configuration for client. + :vartype config: PolicyInsightsClientConfiguration + + :ivar policy_events: PolicyEvents operations + :vartype policy_events: azure.mgmt.policyinsights.operations.PolicyEventsOperations + :ivar policy_insights: PolicyInsights operations + :vartype policy_insights: azure.mgmt.policyinsights.operations.PolicyInsightsOperations + :ivar policy_states: PolicyStates operations + :vartype policy_states: azure.mgmt.policyinsights.operations.PolicyStatesOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param str base_url: Service URL + """ + + def __init__( + self, credentials, base_url=None): + + self.config = PolicyInsightsClientConfiguration(credentials, base_url) + self._client = ServiceClient(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2017-12-12-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.policy_events = PolicyEventsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.policy_insights = PolicyInsightsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.policy_states = PolicyStatesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py new file mode 100644 index 000000000000..c78d6ddcf530 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "2017-12-12-preview" + From 00e7ab632733c8ff919d34536faa5b7cdec8ad02 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 23 Feb 2018 00:45:32 +0000 Subject: [PATCH 2/4] Generated from d9049128d132e3534c20e457690253fa7904ff9d Remove EQUIVALENT_PATH suppressions; add extendedProperties as additionalProperties; add @odata.count to operations; remove "type" from "rows" in first 2017-08-09-preview and add descriptions --- .../azure/mgmt/policyinsights/models/operations.py | 11 ++++++++++- .../azure/mgmt/policyinsights/models/policy_event.py | 7 ++++++- .../azure/mgmt/policyinsights/models/policy_state.py | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py index c14b6e8cae0c..c30cc8fae45a 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py @@ -15,14 +15,23 @@ class Operations(Model): """List of available operations. + :param odatacount: OData entity count; represents the number of operations + returned. + :type odatacount: int :param value: List of available operations. :type value: list[~azure.mgmt.policyinsights.models.Operation] """ + _validation = { + 'odatacount': {'minimum': 1}, + } + _attribute_map = { + 'odatacount': {'key': '@odata\\.count', 'type': 'int'}, 'value': {'key': 'value', 'type': '[Operation]'}, } - def __init__(self, value=None): + def __init__(self, odatacount=None, value=None): super(Operations, self).__init__() + self.odatacount = odatacount self.value = value diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py index 267875115603..f9c15b490638 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py @@ -87,6 +87,9 @@ class PolicyEvent(Model): :param principal_oid: Principal object ID for the user who initiated the resource operation that triggered the policy event. :type principal_oid: str + :param extended_properties: The collection of extended properties, e.g. + aggregates. + :type extended_properties: dict[str, object] """ _attribute_map = { @@ -119,9 +122,10 @@ class PolicyEvent(Model): 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, 'principal_oid': {'key': 'principalOid', 'type': 'str'}, + 'extended_properties': {'key': 'extendedProperties', 'type': '{object}'}, } - def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, tenant_id=None, principal_oid=None): + def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, tenant_id=None, principal_oid=None, extended_properties=None): super(PolicyEvent, self).__init__() self.odataid = odataid self.odatacontext = odatacontext @@ -152,3 +156,4 @@ def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id= self.policy_definition_reference_id = policy_definition_reference_id self.tenant_id = tenant_id self.principal_oid = principal_oid + self.extended_properties = extended_properties diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py index be7151e7d7c4..ab6036817616 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py @@ -82,6 +82,9 @@ class PolicyState(Model): definition inside the policy set, if the policy assignment is for a policy set. :type policy_definition_reference_id: str + :param extended_properties: The collection of extended properties, e.g. + aggregates. + :type extended_properties: dict[str, object] """ _attribute_map = { @@ -112,9 +115,10 @@ class PolicyState(Model): 'policy_set_definition_parameters': {'key': 'policySetDefinitionParameters', 'type': 'str'}, 'management_group_ids': {'key': 'managementGroupIds', 'type': 'str'}, 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'extended_properties': {'key': 'extendedProperties', 'type': '{object}'}, } - def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None): + def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, extended_properties=None): super(PolicyState, self).__init__() self.odataid = odataid self.odatacontext = odatacontext @@ -143,3 +147,4 @@ def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id= 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.extended_properties = extended_properties From 19977a429e0c1a72069e1c8470bb423895de6917 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Sat, 24 Feb 2018 00:27:39 +0000 Subject: [PATCH 3/4] Generated from 55e64b92fb810633a0a1b918c6c4cc234b9e9ea7 Fix additionalParameters definition; fix duplicate paths --- .../policyinsights/models/policy_event.py | 12 +- .../policyinsights/models/policy_state.py | 12 +- .../operations/policy_events_operations.py | 173 +++++++-- .../operations/policy_states_operations.py | 335 +++++++++++++++--- 4 files changed, 436 insertions(+), 96 deletions(-) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py index f9c15b490638..d380142e430e 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py @@ -15,6 +15,9 @@ class PolicyEvent(Model): """Policy event record. + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] :param odataid: OData entity ID; always set to null since policy event records do not have an entity ID. :type odataid: str @@ -87,12 +90,10 @@ class PolicyEvent(Model): :param principal_oid: Principal object ID for the user who initiated the resource operation that triggered the policy event. :type principal_oid: str - :param extended_properties: The collection of extended properties, e.g. - aggregates. - :type extended_properties: dict[str, object] """ _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, 'odataid': {'key': '@odata\\.id', 'type': 'str'}, 'odatacontext': {'key': '@odata\\.context', 'type': 'str'}, 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, @@ -122,11 +123,11 @@ class PolicyEvent(Model): 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, 'principal_oid': {'key': 'principalOid', 'type': 'str'}, - 'extended_properties': {'key': 'extendedProperties', 'type': '{object}'}, } - def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, tenant_id=None, principal_oid=None, extended_properties=None): + def __init__(self, additional_properties=None, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, tenant_id=None, principal_oid=None): super(PolicyEvent, self).__init__() + self.additional_properties = additional_properties self.odataid = odataid self.odatacontext = odatacontext self.timestamp = timestamp @@ -156,4 +157,3 @@ def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id= self.policy_definition_reference_id = policy_definition_reference_id self.tenant_id = tenant_id self.principal_oid = principal_oid - self.extended_properties = extended_properties diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py index ab6036817616..a37f84849604 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py @@ -15,6 +15,9 @@ class PolicyState(Model): """Policy state record. + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] :param odataid: OData entity ID; always set to null since policy state records do not have an entity ID. :type odataid: str @@ -82,12 +85,10 @@ class PolicyState(Model): definition inside the policy set, if the policy assignment is for a policy set. :type policy_definition_reference_id: str - :param extended_properties: The collection of extended properties, e.g. - aggregates. - :type extended_properties: dict[str, object] """ _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, 'odataid': {'key': '@odata\\.id', 'type': 'str'}, 'odatacontext': {'key': '@odata\\.context', 'type': 'str'}, 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, @@ -115,11 +116,11 @@ class PolicyState(Model): 'policy_set_definition_parameters': {'key': 'policySetDefinitionParameters', 'type': 'str'}, 'management_group_ids': {'key': 'managementGroupIds', 'type': 'str'}, 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, - 'extended_properties': {'key': 'extendedProperties', 'type': '{object}'}, } - def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None, extended_properties=None): + def __init__(self, additional_properties=None, odataid=None, odatacontext=None, timestamp=None, resource_id=None, policy_assignment_id=None, policy_definition_id=None, effective_parameters=None, is_compliant=None, subscription_id=None, resource_type=None, resource_location=None, resource_group=None, resource_tags=None, policy_assignment_name=None, policy_assignment_owner=None, policy_assignment_parameters=None, policy_assignment_scope=None, policy_definition_name=None, policy_definition_action=None, policy_definition_category=None, policy_set_definition_id=None, policy_set_definition_name=None, policy_set_definition_owner=None, policy_set_definition_category=None, policy_set_definition_parameters=None, management_group_ids=None, policy_definition_reference_id=None): super(PolicyState, self).__init__() + self.additional_properties = additional_properties self.odataid = odataid self.odatacontext = odatacontext self.timestamp = timestamp @@ -147,4 +148,3 @@ def __init__(self, odataid=None, odatacontext=None, timestamp=None, resource_id= 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.extended_properties = extended_properties diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py index f9e04c568e84..990382d3e2ca 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py @@ -23,7 +23,9 @@ class PolicyEventsOperations(object): :param serializer: An object model serializer. :param deserializer: An object model deserializer. :ivar policy_events_resource: The name of the virtual resource under PolicyEvents resource type; only "default" is allowed. Constant value: "default". + :ivar management_groups_namespace: The namespace for Microsoft Management RP; only "Microsoft.Management" is allowed. Constant value: "Microsoft.Management". :ivar api_version: API version to use with the client requests. Constant value: "2017-12-12-preview". + :ivar authorization_namespace: The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is allowed. Constant value: "Microsoft.Authorization". """ models = models @@ -34,17 +36,18 @@ def __init__(self, client, config, serializer, deserializer): self._serialize = serializer self._deserialize = deserializer self.policy_events_resource = "default" + self.management_groups_namespace = "Microsoft.Management" self.api_version = "2017-12-12-preview" + self.authorization_namespace = "Microsoft.Authorization" self.config = config def list_query_results_for_management_group( - self, management_group_id, query_options=None, custom_headers=None, raw=False, **operation_config): + self, management_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): """Queries policy events for the resources under the management group. - :param management_group_id: Management group ID, e.g. - /providers/Microsoft.Management/managementGroups/{name}. - :type management_group_id: str + :param management_group_name: Management group name. + :type management_group_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -84,7 +87,8 @@ def list_query_results_for_management_group( url = self.list_query_results_for_management_group.metadata['url'] path_format_arguments = { 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True) + 'managementGroupsNamespace': self._serialize.url("self.management_groups_namespace", self.management_groups_namespace, 'str'), + 'managementGroupName': self._serialize.url("management_group_name", management_group_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -133,7 +137,7 @@ def list_query_results_for_management_group( return client_raw_response return deserialized - list_query_results_for_management_group.metadata = {'url': '/{managementGroupId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + list_query_results_for_management_group.metadata = {'url': '/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} def list_query_results_for_subscription( self, subscription_id, query_options=None, custom_headers=None, raw=False, **operation_config): @@ -427,12 +431,13 @@ def list_query_results_for_resource( list_query_results_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} def list_query_results_for_policy_set_definition( - self, policy_set_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Queries policy events for the policy set definition. + self, subscription_id, policy_set_definition_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the subscription level policy set definition. - :param policy_set_definition_id: Subscription level policy set - definition ID. - :type policy_set_definition_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_set_definition_name: Policy set definition name. + :type policy_set_definition_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -472,7 +477,9 @@ def list_query_results_for_policy_set_definition( url = self.list_query_results_for_policy_set_definition.metadata['url'] path_format_arguments = { 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), - 'policySetDefinitionId': self._serialize.url("policy_set_definition_id", policy_set_definition_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -521,14 +528,16 @@ def list_query_results_for_policy_set_definition( return client_raw_response return deserialized - list_query_results_for_policy_set_definition.metadata = {'url': '/{policySetDefinitionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + list_query_results_for_policy_set_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} def list_query_results_for_policy_definition( - self, policy_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Queries policy events for the policy definition. + self, subscription_id, policy_definition_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the subscription level policy definition. - :param policy_definition_id: Subscription level policy definition ID. - :type policy_definition_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_definition_name: Policy definition name. + :type policy_definition_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -568,7 +577,109 @@ def list_query_results_for_policy_definition( url = self.list_query_results_for_policy_definition.metadata['url'] path_format_arguments = { 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), - 'policyDefinitionId': self._serialize.url("policy_definition_id", policy_definition_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyEventsQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_policy_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_subscription_level_policy_assignment( + self, subscription_id, policy_assignment_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the subscription level policy assignment. + + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyEventsQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyEventsQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_subscription_level_policy_assignment.metadata['url'] + path_format_arguments = { + 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -617,15 +728,18 @@ def list_query_results_for_policy_definition( return client_raw_response return deserialized - list_query_results_for_policy_definition.metadata = {'url': '/{policyDefinitionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + list_query_results_for_subscription_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} - def list_query_results_for_policy_assignment( - self, policy_assignment_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Queries policy events for the policy assignment. + def list_query_results_for_resource_group_level_policy_assignment( + self, subscription_id, resource_group_name, policy_assignment_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the resource group level policy assignment. - :param policy_assignment_id: Subscription level or a resource group - level policy assignment ID. - :type policy_assignment_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -662,10 +776,13 @@ def list_query_results_for_policy_assignment( apply = query_options.apply # Construct URL - url = self.list_query_results_for_policy_assignment.metadata['url'] + url = self.list_query_results_for_resource_group_level_policy_assignment.metadata['url'] path_format_arguments = { 'policyEventsResource': self._serialize.url("self.policy_events_resource", self.policy_events_resource, 'str'), - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -714,7 +831,7 @@ def list_query_results_for_policy_assignment( return client_raw_response return deserialized - list_query_results_for_policy_assignment.metadata = {'url': '/{policyAssignmentId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + list_query_results_for_resource_group_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} def get_metadata( self, scope, custom_headers=None, raw=False, **operation_config): diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py index ad202677b5ae..17a128c17d7e 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py @@ -22,8 +22,10 @@ class PolicyStatesOperations(object): :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. + :ivar management_groups_namespace: The namespace for Microsoft Management RP; only "Microsoft.Management" is allowed. Constant value: "Microsoft.Management". :ivar api_version: API version to use with the client requests. Constant value: "2017-12-12-preview". :ivar 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. Constant value: "latest". + :ivar authorization_namespace: The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is allowed. Constant value: "Microsoft.Authorization". """ models = models @@ -33,13 +35,15 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer + self.management_groups_namespace = "Microsoft.Management" self.api_version = "2017-12-12-preview" self.policy_states_summary_resource = "latest" + self.authorization_namespace = "Microsoft.Authorization" self.config = config def list_query_results_for_management_group( - self, policy_states_resource, management_group_id, query_options=None, custom_headers=None, raw=False, **operation_config): + self, policy_states_resource, management_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): """Queries policy states for the resources under the management group. :param policy_states_resource: The virtual resource under PolicyStates @@ -48,9 +52,8 @@ def list_query_results_for_management_group( Possible values include: 'default', 'latest' :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param management_group_id: Management group ID, e.g. - /providers/Microsoft.Management/managementGroups/{name}. - :type management_group_id: str + :param management_group_name: Management group name. + :type management_group_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -90,7 +93,8 @@ def list_query_results_for_management_group( url = self.list_query_results_for_management_group.metadata['url'] path_format_arguments = { 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True) + 'managementGroupsNamespace': self._serialize.url("self.management_groups_namespace", self.management_groups_namespace, 'str'), + 'managementGroupName': self._serialize.url("management_group_name", management_group_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -139,15 +143,14 @@ def list_query_results_for_management_group( return client_raw_response return deserialized - list_query_results_for_management_group.metadata = {'url': '/{managementGroupId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + list_query_results_for_management_group.metadata = {'url': '/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} def summarize_for_management_group( - self, management_group_id, query_options=None, custom_headers=None, raw=False, **operation_config): + self, management_group_name, query_options=None, custom_headers=None, raw=False, **operation_config): """Summarizes policy states for the resources under the management group. - :param management_group_id: Management group ID, e.g. - /providers/Microsoft.Management/managementGroups/{name}. - :type management_group_id: str + :param management_group_name: Management group name. + :type management_group_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -178,7 +181,8 @@ def summarize_for_management_group( url = self.summarize_for_management_group.metadata['url'] path_format_arguments = { 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True) + 'managementGroupsNamespace': self._serialize.url("self.management_groups_namespace", self.management_groups_namespace, 'str'), + 'managementGroupName': self._serialize.url("management_group_name", management_group_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -221,7 +225,7 @@ def summarize_for_management_group( return client_raw_response return deserialized - summarize_for_management_group.metadata = {'url': '/{managementGroupId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + summarize_for_management_group.metadata = {'url': '/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} def list_query_results_for_subscription( self, policy_states_resource, subscription_id, query_options=None, custom_headers=None, raw=False, **operation_config): @@ -779,8 +783,8 @@ def summarize_for_resource( summarize_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} def list_query_results_for_policy_set_definition( - self, policy_states_resource, policy_set_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Queries policy states for the policy set definition. + self, policy_states_resource, subscription_id, policy_set_definition_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """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 @@ -788,9 +792,10 @@ def list_query_results_for_policy_set_definition( Possible values include: 'default', 'latest' :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param policy_set_definition_id: Subscription level policy set - definition ID. - :type policy_set_definition_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_set_definition_name: Policy set definition name. + :type policy_set_definition_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -830,7 +835,9 @@ def list_query_results_for_policy_set_definition( url = self.list_query_results_for_policy_set_definition.metadata['url'] path_format_arguments = { 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), - 'policySetDefinitionId': self._serialize.url("policy_set_definition_id", policy_set_definition_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -879,15 +886,17 @@ def list_query_results_for_policy_set_definition( return client_raw_response return deserialized - list_query_results_for_policy_set_definition.metadata = {'url': '/{policySetDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + list_query_results_for_policy_set_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} def summarize_for_policy_set_definition( - self, policy_set_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Summarizes policy states for the policy set definition. + self, subscription_id, policy_set_definition_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the subscription level policy set + definition. - :param policy_set_definition_id: Subscription level policy set - definition ID. - :type policy_set_definition_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_set_definition_name: Policy set definition name. + :type policy_set_definition_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -918,7 +927,9 @@ def summarize_for_policy_set_definition( url = self.summarize_for_policy_set_definition.metadata['url'] path_format_arguments = { 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), - 'policySetDefinitionId': self._serialize.url("policy_set_definition_id", policy_set_definition_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policySetDefinitionName': self._serialize.url("policy_set_definition_name", policy_set_definition_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -961,11 +972,11 @@ def summarize_for_policy_set_definition( return client_raw_response return deserialized - summarize_for_policy_set_definition.metadata = {'url': '/{policySetDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + summarize_for_policy_set_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} def list_query_results_for_policy_definition( - self, policy_states_resource, policy_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Queries policy states for the policy definition. + self, policy_states_resource, subscription_id, policy_definition_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """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 @@ -973,8 +984,10 @@ def list_query_results_for_policy_definition( Possible values include: 'default', 'latest' :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param policy_definition_id: Subscription level policy definition ID. - :type policy_definition_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_definition_name: Policy definition name. + :type policy_definition_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -1014,7 +1027,9 @@ def list_query_results_for_policy_definition( url = self.list_query_results_for_policy_definition.metadata['url'] path_format_arguments = { 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), - 'policyDefinitionId': self._serialize.url("policy_definition_id", policy_definition_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1063,14 +1078,16 @@ def list_query_results_for_policy_definition( return client_raw_response return deserialized - list_query_results_for_policy_definition.metadata = {'url': '/{policyDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + list_query_results_for_policy_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} def summarize_for_policy_definition( - self, policy_definition_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Summarizes policy states for the policy definition. + self, subscription_id, policy_definition_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the subscription level policy definition. - :param policy_definition_id: Subscription level policy definition ID. - :type policy_definition_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_definition_name: Policy definition name. + :type policy_definition_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -1101,7 +1118,9 @@ def summarize_for_policy_definition( url = self.summarize_for_policy_definition.metadata['url'] path_format_arguments = { 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), - 'policyDefinitionId': self._serialize.url("policy_definition_id", policy_definition_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyDefinitionName': self._serialize.url("policy_definition_name", policy_definition_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1144,11 +1163,11 @@ def summarize_for_policy_definition( return client_raw_response return deserialized - summarize_for_policy_definition.metadata = {'url': '/{policyDefinitionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + summarize_for_policy_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} - def list_query_results_for_policy_assignment( - self, policy_states_resource, policy_assignment_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Queries policy states for the policy assignment. + def list_query_results_for_subscription_level_policy_assignment( + self, policy_states_resource, subscription_id, policy_assignment_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """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 @@ -1156,9 +1175,10 @@ def list_query_results_for_policy_assignment( Possible values include: 'default', 'latest' :type policy_states_resource: str or ~azure.mgmt.policyinsights.models.PolicyStatesResource - :param policy_assignment_id: Subscription level or a resource group - level policy assignment ID. - :type policy_assignment_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -1195,10 +1215,12 @@ def list_query_results_for_policy_assignment( apply = query_options.apply # Construct URL - url = self.list_query_results_for_policy_assignment.metadata['url'] + url = self.list_query_results_for_subscription_level_policy_assignment.metadata['url'] path_format_arguments = { 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1247,15 +1269,16 @@ def list_query_results_for_policy_assignment( return client_raw_response return deserialized - list_query_results_for_policy_assignment.metadata = {'url': '/{policyAssignmentId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + list_query_results_for_subscription_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} - def summarize_for_policy_assignment( - self, policy_assignment_id, query_options=None, custom_headers=None, raw=False, **operation_config): - """Summarizes policy states for the policy assignment. + def summarize_for_subscription_level_policy_assignment( + self, subscription_id, policy_assignment_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the subscription level policy assignment. - :param policy_assignment_id: Subscription level or a resource group - level policy assignment ID. - :type policy_assignment_id: str + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str :param query_options: Additional parameters for the operation :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions :param dict custom_headers: headers that will be added to the request @@ -1283,10 +1306,210 @@ def summarize_for_policy_assignment( filter = query_options.filter # Construct URL - url = self.summarize_for_policy_assignment.metadata['url'] + url = self.summarize_for_subscription_level_policy_assignment.metadata['url'] path_format_arguments = { 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), - 'policyAssignmentId': self._serialize.url("policy_assignment_id", policy_assignment_id, 'str', skip_quote=True) + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('SummarizeResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + summarize_for_subscription_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_resource_group_level_policy_assignment( + self, policy_states_resource, subscription_id, resource_group_name, policy_assignment_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """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). + Possible values include: 'default', 'latest' + :type policy_states_resource: str or + ~azure.mgmt.policyinsights.models.PolicyStatesResource + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: PolicyStatesQueryResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.PolicyStatesQueryResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + order_by = None + if query_options is not None: + order_by = query_options.order_by + select = None + if query_options is not None: + select = query_options.select + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + apply = None + if query_options is not None: + apply = query_options.apply + + # Construct URL + url = self.list_query_results_for_resource_group_level_policy_assignment.metadata['url'] + path_format_arguments = { + 'policyStatesResource': self._serialize.url("policy_states_resource", policy_states_resource, 'PolicyStatesResource'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=0) + if order_by is not None: + query_parameters['$orderby'] = self._serialize.query("order_by", order_by, 'str') + if select is not None: + query_parameters['$select'] = self._serialize.query("select", select, 'str') + if from_parameter is not None: + query_parameters['$from'] = self._serialize.query("from_parameter", from_parameter, 'iso-8601') + if to is not None: + query_parameters['$to'] = self._serialize.query("to", to, 'iso-8601') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if apply is not None: + query_parameters['$apply'] = self._serialize.query("apply", apply, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('PolicyStatesQueryResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list_query_results_for_resource_group_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_resource_group_level_policy_assignment( + self, subscription_id, resource_group_name, policy_assignment_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Summarizes policy states for the resource group level policy + assignment. + + :param subscription_id: Microsoft Azure subscription ID. + :type subscription_id: str + :param resource_group_name: Resource group name. + :type resource_group_name: str + :param policy_assignment_name: Policy assignment name. + :type policy_assignment_name: str + :param query_options: Additional parameters for the operation + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SummarizeResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + top = None + if query_options is not None: + top = query_options.top + from_parameter = None + if query_options is not None: + from_parameter = query_options.from_property + to = None + if query_options is not None: + to = query_options.to + filter = None + if query_options is not None: + filter = query_options.filter + + # Construct URL + url = self.summarize_for_resource_group_level_policy_assignment.metadata['url'] + path_format_arguments = { + 'policyStatesSummaryResource': self._serialize.url("self.policy_states_summary_resource", self.policy_states_summary_resource, 'str'), + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'authorizationNamespace': self._serialize.url("self.authorization_namespace", self.authorization_namespace, 'str'), + 'policyAssignmentName': self._serialize.url("policy_assignment_name", policy_assignment_name, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -1329,7 +1552,7 @@ def summarize_for_policy_assignment( return client_raw_response return deserialized - summarize_for_policy_assignment.metadata = {'url': '/{policyAssignmentId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + summarize_for_resource_group_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} def get_metadata( self, scope, custom_headers=None, raw=False, **operation_config): From bf035fb9275242b41db1ea651c27e574521f4ce7 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 27 Feb 2018 22:55:57 +0000 Subject: [PATCH 4/4] Generated from a01973b3be2e1a8c0fd6a05e3d3472cd37a99c98 Remove redundant operations path/definitions from one of the swagger files for each version (one per namespace is sufficient as long as both files are fed into autorest as a bundle) --- .../azure/mgmt/policyinsights/models/__init__.py | 12 ++++++------ .../azure/mgmt/policyinsights/operations/__init__.py | 4 ++-- .../mgmt/policyinsights/policy_insights_client.py | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py index 169c632f046c..2bd089ec4ddc 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py @@ -13,9 +13,6 @@ from .policy_events_query_results import PolicyEventsQueryResults from .query_failure_error import QueryFailureError from .query_failure import QueryFailure, QueryFailureException -from .operation_display import OperationDisplay -from .operation import Operation -from .operations import Operations from .policy_state import PolicyState from .policy_states_query_results import PolicyStatesQueryResults from .summary_results import SummaryResults @@ -23,6 +20,9 @@ from .policy_assignment_summary import PolicyAssignmentSummary from .summary import Summary from .summarize_results import SummarizeResults +from .operation_display import OperationDisplay +from .operation import Operation +from .operations import Operations from .query_options import QueryOptions from .policy_insights_client_enums import ( PolicyStatesResource, @@ -33,9 +33,6 @@ 'PolicyEventsQueryResults', 'QueryFailureError', 'QueryFailure', 'QueryFailureException', - 'OperationDisplay', - 'Operation', - 'Operations', 'PolicyState', 'PolicyStatesQueryResults', 'SummaryResults', @@ -43,6 +40,9 @@ 'PolicyAssignmentSummary', 'Summary', 'SummarizeResults', + 'OperationDisplay', + 'Operation', + 'Operations', 'QueryOptions', 'PolicyStatesResource', ] diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py index 17712904e12d..6ea788480046 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py @@ -10,11 +10,11 @@ # -------------------------------------------------------------------------- from .policy_events_operations import PolicyEventsOperations -from .policy_insights_operations import PolicyInsightsOperations from .policy_states_operations import PolicyStatesOperations +from .policy_insights_operations import PolicyInsightsOperations __all__ = [ 'PolicyEventsOperations', - 'PolicyInsightsOperations', 'PolicyStatesOperations', + 'PolicyInsightsOperations', ] diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py index 293d73bd5681..21e594110caf 100644 --- a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/policy_insights_client.py @@ -14,8 +14,8 @@ from msrestazure import AzureConfiguration from .version import VERSION from .operations.policy_events_operations import PolicyEventsOperations -from .operations.policy_insights_operations import PolicyInsightsOperations from .operations.policy_states_operations import PolicyStatesOperations +from .operations.policy_insights_operations import PolicyInsightsOperations from . import models @@ -54,10 +54,10 @@ class PolicyInsightsClient(object): :ivar policy_events: PolicyEvents operations :vartype policy_events: azure.mgmt.policyinsights.operations.PolicyEventsOperations - :ivar policy_insights: PolicyInsights operations - :vartype policy_insights: azure.mgmt.policyinsights.operations.PolicyInsightsOperations :ivar policy_states: PolicyStates operations :vartype policy_states: azure.mgmt.policyinsights.operations.PolicyStatesOperations + :ivar policy_insights: PolicyInsights operations + :vartype policy_insights: azure.mgmt.policyinsights.operations.PolicyInsightsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -78,7 +78,7 @@ def __init__( self.policy_events = PolicyEventsOperations( self._client, self.config, self._serialize, self._deserialize) - self.policy_insights = PolicyInsightsOperations( - self._client, self.config, self._serialize, self._deserialize) self.policy_states = PolicyStatesOperations( self._client, self.config, self._serialize, self._deserialize) + self.policy_insights = PolicyInsightsOperations( + self._client, self.config, self._serialize, self._deserialize)