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..2bd089ec4ddc --- /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 .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 .operation_display import OperationDisplay +from .operation import Operation +from .operations import Operations +from .query_options import QueryOptions +from .policy_insights_client_enums import ( + PolicyStatesResource, +) + +__all__ = [ + 'PolicyEvent', + 'PolicyEventsQueryResults', + 'QueryFailureError', + 'QueryFailure', 'QueryFailureException', + 'PolicyState', + 'PolicyStatesQueryResults', + 'SummaryResults', + 'PolicyDefinitionSummary', + 'PolicyAssignmentSummary', + 'Summary', + 'SummarizeResults', + 'OperationDisplay', + 'Operation', + 'Operations', + '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..c30cc8fae45a --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations.py @@ -0,0 +1,37 @@ +# 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 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, 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_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..d380142e430e --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event.py @@ -0,0 +1,159 @@ +# 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 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 + :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 = { + 'additional_properties': {'key': '', 'type': '{object}'}, + '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, 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 + 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..a37f84849604 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state.py @@ -0,0 +1,150 @@ +# 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 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 + :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 = { + 'additional_properties': {'key': '', 'type': '{object}'}, + '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, 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 + 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..6ea788480046 --- /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_states_operations import PolicyStatesOperations +from .policy_insights_operations import PolicyInsightsOperations + +__all__ = [ + 'PolicyEventsOperations', + 'PolicyStatesOperations', + 'PolicyInsightsOperations', +] 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..990382d3e2ca --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_events_operations.py @@ -0,0 +1,892 @@ +# 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 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 + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + 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_name, query_options=None, custom_headers=None, raw=False, **operation_config): + """Queries policy events for the resources under the management group. + + :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 + :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'), + '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) + + # 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': '/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): + """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, 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 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 + :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'), + '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) + + # 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': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + def list_query_results_for_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 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 + :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'), + '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) + + # 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_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} + + 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 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: 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_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'), + '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('PolicyEventsQueryResults', 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/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..17a128c17d7e --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py @@ -0,0 +1,1613 @@ +# 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 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 + + 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_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 + 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_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 + :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'), + '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) + + # 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': '/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_management_group( + 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_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 + :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'), + '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) + + # 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': '/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): + """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, 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 + 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 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 + :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'), + '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) + + # 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': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_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 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 + :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'), + '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) + + # 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': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + def list_query_results_for_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 + 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 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 + :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'), + '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('PolicyStatesQueryResults', 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/policyStates/{policyStatesResource}/queryResults'} + + def summarize_for_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 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 + :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'), + '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 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': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'} + + 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 + 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 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_subscription_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'), + '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_subscription_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} + + 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 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: 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_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'), + '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) + + # 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_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): + """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..21e594110caf --- /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_states_operations import PolicyStatesOperations +from .operations.policy_insights_operations import PolicyInsightsOperations +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_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 + 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_states = PolicyStatesOperations( + self._client, self.config, self._serialize, self._deserialize) + self.policy_insights = PolicyInsightsOperations( + 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" +