diff --git a/azure-mgmt-policyinsights/HISTORY.rst b/azure-mgmt-policyinsights/HISTORY.rst new file mode 100644 index 000000000000..64953245a942 --- /dev/null +++ b/azure-mgmt-policyinsights/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (2018-05-04) +++++++++++++++++++ + +* Initial Release diff --git a/azure-mgmt-policyinsights/MANIFEST.in b/azure-mgmt-policyinsights/MANIFEST.in new file mode 100644 index 000000000000..9ecaeb15de50 --- /dev/null +++ b/azure-mgmt-policyinsights/MANIFEST.in @@ -0,0 +1,2 @@ +include *.rst +include azure_bdist_wheel.py \ No newline at end of file diff --git a/azure-mgmt-policyinsights/README.rst b/azure-mgmt-policyinsights/README.rst new file mode 100644 index 000000000000..ed70aaf0537f --- /dev/null +++ b/azure-mgmt-policyinsights/README.rst @@ -0,0 +1,49 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure Policy Insights Client Library. + +Azure Resource Manager (ARM) is the next generation of management APIs that +replace the old Azure Service Management (ASM). + +This package has been tested with Python 2.7, 3.4, 3.5 and 3.6. + +For the older Azure Service Management (ASM) libraries, see +`azure-servicemanagement-legacy `__ library. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Compatibility +============= + +**IMPORTANT**: If you have an earlier version of the azure package +(version < 1.0), you should uninstall it before installing this package. + +You can check the version using pip: + +.. code:: shell + + pip freeze + +If you see azure==0.11.0 (or any version below 1.0), uninstall it first: + +.. code:: shell + + pip uninstall azure + + +Usage +===== + +For code examples, see `Policy Insights +`__ +on docs.microsoft.com. + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. diff --git a/azure-mgmt-policyinsights/azure/__init__.py b/azure-mgmt-policyinsights/azure/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-mgmt-policyinsights/azure/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) diff --git a/azure-mgmt-policyinsights/azure/mgmt/__init__.py b/azure-mgmt-policyinsights/azure/mgmt/__init__.py new file mode 100644 index 000000000000..849489fca33c --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__import__('pkg_resources').declare_namespace(__name__) 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..acf6eca04eb0 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py @@ -0,0 +1,65 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from .policy_event_py3 import PolicyEvent + from .policy_events_query_results_py3 import PolicyEventsQueryResults + from .query_failure_error_py3 import QueryFailureError + from .query_failure_py3 import QueryFailure, QueryFailureException + from .policy_state_py3 import PolicyState + from .policy_states_query_results_py3 import PolicyStatesQueryResults + from .summary_results_py3 import SummaryResults + from .policy_definition_summary_py3 import PolicyDefinitionSummary + from .policy_assignment_summary_py3 import PolicyAssignmentSummary + from .summary_py3 import Summary + from .summarize_results_py3 import SummarizeResults + from .operation_display_py3 import OperationDisplay + from .operation_py3 import Operation + from .operations_list_results_py3 import OperationsListResults + from .query_options_py3 import QueryOptions +except (SyntaxError, ImportError): + 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_list_results import OperationsListResults + 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', + 'OperationsListResults', + '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..b1de7ee85c7e --- /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, **kwargs): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) 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..49e584de324d --- /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, **kwargs): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display_py3.py new file mode 100644 index 000000000000..3ed545a5f6d2 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_display_py3.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: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_py3.py new file mode 100644 index 000000000000..d20a3bced084 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operation_py3.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: str=None, display=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations_list_results.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations_list_results.py new file mode 100644 index 000000000000..69e4222179da --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations_list_results.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 OperationsListResults(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, **kwargs): + super(OperationsListResults, self).__init__(**kwargs) + self.odatacount = kwargs.get('odatacount', None) + self.value = kwargs.get('value', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations_list_results_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations_list_results_py3.py new file mode 100644 index 000000000000..794009aa62e4 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/operations_list_results_py3.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 OperationsListResults(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: int=None, value=None, **kwargs) -> None: + super(OperationsListResults, self).__init__(**kwargs) + 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..33988b36213c --- /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, **kwargs): + super(PolicyAssignmentSummary, self).__init__(**kwargs) + self.policy_assignment_id = kwargs.get('policy_assignment_id', None) + self.policy_set_definition_id = kwargs.get('policy_set_definition_id', None) + self.results = kwargs.get('results', None) + self.policy_definitions = kwargs.get('policy_definitions', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary_py3.py new file mode 100644 index 000000000000..7a1eec689ae3 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_assignment_summary_py3.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: str=None, policy_set_definition_id: str=None, results=None, policy_definitions=None, **kwargs) -> None: + super(PolicyAssignmentSummary, self).__init__(**kwargs) + self.policy_assignment_id = policy_assignment_id + self.policy_set_definition_id = policy_set_definition_id + self.results = results + self.policy_definitions = policy_definitions 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..db73df83fd6a --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary.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 PolicyDefinitionSummary(Model): + """Policy definition summary. + + :param policy_definition_id: Policy definition ID. + :type policy_definition_id: str + :param policy_definition_reference_id: Policy definition reference ID. + :type policy_definition_reference_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'}, + 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'effect': {'key': 'effect', 'type': 'str'}, + 'results': {'key': 'results', 'type': 'SummaryResults'}, + } + + def __init__(self, **kwargs): + super(PolicyDefinitionSummary, self).__init__(**kwargs) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) + self.effect = kwargs.get('effect', None) + self.results = kwargs.get('results', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary_py3.py new file mode 100644 index 000000000000..6ed5afbba2da --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_definition_summary_py3.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 PolicyDefinitionSummary(Model): + """Policy definition summary. + + :param policy_definition_id: Policy definition ID. + :type policy_definition_id: str + :param policy_definition_reference_id: Policy definition reference ID. + :type policy_definition_reference_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'}, + 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'effect': {'key': 'effect', 'type': 'str'}, + 'results': {'key': 'results', 'type': 'SummaryResults'}, + } + + def __init__(self, *, policy_definition_id: str=None, policy_definition_reference_id: str=None, effect: str=None, results=None, **kwargs) -> None: + super(PolicyDefinitionSummary, self).__init__(**kwargs) + self.policy_definition_id = policy_definition_id + self.policy_definition_reference_id = policy_definition_reference_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..eac7944437cc --- /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, **kwargs): + super(PolicyEvent, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.odataid = kwargs.get('odataid', None) + self.odatacontext = kwargs.get('odatacontext', None) + self.timestamp = kwargs.get('timestamp', None) + self.resource_id = kwargs.get('resource_id', None) + self.policy_assignment_id = kwargs.get('policy_assignment_id', None) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.effective_parameters = kwargs.get('effective_parameters', None) + self.is_compliant = kwargs.get('is_compliant', None) + self.subscription_id = kwargs.get('subscription_id', None) + self.resource_type = kwargs.get('resource_type', None) + self.resource_location = kwargs.get('resource_location', None) + self.resource_group = kwargs.get('resource_group', None) + self.resource_tags = kwargs.get('resource_tags', None) + self.policy_assignment_name = kwargs.get('policy_assignment_name', None) + self.policy_assignment_owner = kwargs.get('policy_assignment_owner', None) + self.policy_assignment_parameters = kwargs.get('policy_assignment_parameters', None) + self.policy_assignment_scope = kwargs.get('policy_assignment_scope', None) + self.policy_definition_name = kwargs.get('policy_definition_name', None) + self.policy_definition_action = kwargs.get('policy_definition_action', None) + self.policy_definition_category = kwargs.get('policy_definition_category', None) + self.policy_set_definition_id = kwargs.get('policy_set_definition_id', None) + self.policy_set_definition_name = kwargs.get('policy_set_definition_name', None) + self.policy_set_definition_owner = kwargs.get('policy_set_definition_owner', None) + self.policy_set_definition_category = kwargs.get('policy_set_definition_category', None) + self.policy_set_definition_parameters = kwargs.get('policy_set_definition_parameters', None) + self.management_group_ids = kwargs.get('management_group_ids', None) + self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) + self.tenant_id = kwargs.get('tenant_id', None) + self.principal_oid = kwargs.get('principal_oid', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event_py3.py new file mode 100644 index 000000000000..41638d99fb4b --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_event_py3.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: str=None, odatacontext: str=None, timestamp=None, resource_id: str=None, policy_assignment_id: str=None, policy_definition_id: str=None, effective_parameters: str=None, is_compliant: bool=None, subscription_id: str=None, resource_type: str=None, resource_location: str=None, resource_group: str=None, resource_tags: str=None, policy_assignment_name: str=None, policy_assignment_owner: str=None, policy_assignment_parameters: str=None, policy_assignment_scope: str=None, policy_definition_name: str=None, policy_definition_action: str=None, policy_definition_category: str=None, policy_set_definition_id: str=None, policy_set_definition_name: str=None, policy_set_definition_owner: str=None, policy_set_definition_category: str=None, policy_set_definition_parameters: str=None, management_group_ids: str=None, policy_definition_reference_id: str=None, tenant_id: str=None, principal_oid: str=None, **kwargs) -> None: + super(PolicyEvent, self).__init__(**kwargs) + 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..ef3a73ebac0f --- /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, **kwargs): + super(PolicyEventsQueryResults, self).__init__(**kwargs) + self.odatacontext = kwargs.get('odatacontext', None) + self.odatacount = kwargs.get('odatacount', None) + self.value = kwargs.get('value', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results_py3.py new file mode 100644 index 000000000000..e1876afab02a --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_events_query_results_py3.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: str=None, odatacount: int=None, value=None, **kwargs) -> None: + super(PolicyEventsQueryResults, self).__init__(**kwargs) + 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..98a1f368192d --- /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(str, 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..9f85ee45e1b9 --- /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, **kwargs): + super(PolicyState, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.odataid = kwargs.get('odataid', None) + self.odatacontext = kwargs.get('odatacontext', None) + self.timestamp = kwargs.get('timestamp', None) + self.resource_id = kwargs.get('resource_id', None) + self.policy_assignment_id = kwargs.get('policy_assignment_id', None) + self.policy_definition_id = kwargs.get('policy_definition_id', None) + self.effective_parameters = kwargs.get('effective_parameters', None) + self.is_compliant = kwargs.get('is_compliant', None) + self.subscription_id = kwargs.get('subscription_id', None) + self.resource_type = kwargs.get('resource_type', None) + self.resource_location = kwargs.get('resource_location', None) + self.resource_group = kwargs.get('resource_group', None) + self.resource_tags = kwargs.get('resource_tags', None) + self.policy_assignment_name = kwargs.get('policy_assignment_name', None) + self.policy_assignment_owner = kwargs.get('policy_assignment_owner', None) + self.policy_assignment_parameters = kwargs.get('policy_assignment_parameters', None) + self.policy_assignment_scope = kwargs.get('policy_assignment_scope', None) + self.policy_definition_name = kwargs.get('policy_definition_name', None) + self.policy_definition_action = kwargs.get('policy_definition_action', None) + self.policy_definition_category = kwargs.get('policy_definition_category', None) + self.policy_set_definition_id = kwargs.get('policy_set_definition_id', None) + self.policy_set_definition_name = kwargs.get('policy_set_definition_name', None) + self.policy_set_definition_owner = kwargs.get('policy_set_definition_owner', None) + self.policy_set_definition_category = kwargs.get('policy_set_definition_category', None) + self.policy_set_definition_parameters = kwargs.get('policy_set_definition_parameters', None) + self.management_group_ids = kwargs.get('management_group_ids', None) + self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state_py3.py new file mode 100644 index 000000000000..766127a8abcc --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_state_py3.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: str=None, odatacontext: str=None, timestamp=None, resource_id: str=None, policy_assignment_id: str=None, policy_definition_id: str=None, effective_parameters: str=None, is_compliant: bool=None, subscription_id: str=None, resource_type: str=None, resource_location: str=None, resource_group: str=None, resource_tags: str=None, policy_assignment_name: str=None, policy_assignment_owner: str=None, policy_assignment_parameters: str=None, policy_assignment_scope: str=None, policy_definition_name: str=None, policy_definition_action: str=None, policy_definition_category: str=None, policy_set_definition_id: str=None, policy_set_definition_name: str=None, policy_set_definition_owner: str=None, policy_set_definition_category: str=None, policy_set_definition_parameters: str=None, management_group_ids: str=None, policy_definition_reference_id: str=None, **kwargs) -> None: + super(PolicyState, self).__init__(**kwargs) + 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..d4e45f98a688 --- /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, **kwargs): + super(PolicyStatesQueryResults, self).__init__(**kwargs) + self.odatacontext = kwargs.get('odatacontext', None) + self.odatacount = kwargs.get('odatacount', None) + self.value = kwargs.get('value', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results_py3.py new file mode 100644 index 000000000000..29cd60ec18d2 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/policy_states_query_results_py3.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: str=None, odatacount: int=None, value=None, **kwargs) -> None: + super(PolicyStatesQueryResults, self).__init__(**kwargs) + 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..de37462dd02e --- /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, **kwargs): + super(QueryFailure, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +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..6fea350785bf --- /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, **kwargs): + super(QueryFailureError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error_py3.py new file mode 100644 index 000000000000..40d0b77dc4c9 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_error_py3.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: str=None, message: str=None, **kwargs) -> None: + super(QueryFailureError, self).__init__(**kwargs) + self.code = code + self.message = message diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_py3.py new file mode 100644 index 000000000000..9b2d224bed03 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_failure_py3.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, **kwargs) -> None: + super(QueryFailure, self).__init__(**kwargs) + 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_options.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options.py new file mode 100644 index 000000000000..6e245f40e72b --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options.py @@ -0,0 +1,59 @@ +# 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 + """ + + _attribute_map = { + 'top': {'key': '', 'type': 'int'}, + 'order_by': {'key': '', 'type': 'str'}, + 'select': {'key': '', 'type': 'str'}, + 'from_property': {'key': '', 'type': 'iso-8601'}, + 'to': {'key': '', 'type': 'iso-8601'}, + 'filter': {'key': '', 'type': 'str'}, + 'apply': {'key': '', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(QueryOptions, self).__init__(**kwargs) + self.top = kwargs.get('top', None) + self.order_by = kwargs.get('order_by', None) + self.select = kwargs.get('select', None) + self.from_property = kwargs.get('from_property', None) + self.to = kwargs.get('to', None) + self.filter = kwargs.get('filter', None) + self.apply = kwargs.get('apply', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options_py3.py new file mode 100644 index 000000000000..fde9a44d983e --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/query_options_py3.py @@ -0,0 +1,59 @@ +# 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 + """ + + _attribute_map = { + 'top': {'key': '', 'type': 'int'}, + 'order_by': {'key': '', 'type': 'str'}, + 'select': {'key': '', 'type': 'str'}, + 'from_property': {'key': '', 'type': 'iso-8601'}, + 'to': {'key': '', 'type': 'iso-8601'}, + 'filter': {'key': '', 'type': 'str'}, + 'apply': {'key': '', 'type': 'str'}, + } + + def __init__(self, *, top: int=None, order_by: str=None, select: str=None, from_property=None, to=None, filter: str=None, apply: str=None, **kwargs) -> None: + super(QueryOptions, self).__init__(**kwargs) + 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..60c4d510c6b4 --- /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, **kwargs): + super(SummarizeResults, self).__init__(**kwargs) + self.odatacontext = kwargs.get('odatacontext', None) + self.odatacount = kwargs.get('odatacount', None) + self.value = kwargs.get('value', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results_py3.py new file mode 100644 index 000000000000..40345a92bfb7 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summarize_results_py3.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: str=None, odatacount: int=None, value=None, **kwargs) -> None: + super(SummarizeResults, self).__init__(**kwargs) + 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..75aee548d8e0 --- /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, **kwargs): + super(Summary, self).__init__(**kwargs) + self.odataid = kwargs.get('odataid', None) + self.odatacontext = kwargs.get('odatacontext', None) + self.results = kwargs.get('results', None) + self.policy_assignments = kwargs.get('policy_assignments', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_py3.py new file mode 100644 index 000000000000..9ede585c9116 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_py3.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: str=None, odatacontext: str=None, results=None, policy_assignments=None, **kwargs) -> None: + super(Summary, self).__init__(**kwargs) + 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..eedc207cfe04 --- /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, **kwargs): + super(SummaryResults, self).__init__(**kwargs) + self.query_results_uri = kwargs.get('query_results_uri', None) + self.non_compliant_resources = kwargs.get('non_compliant_resources', None) + self.non_compliant_policies = kwargs.get('non_compliant_policies', None) diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results_py3.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results_py3.py new file mode 100644 index 000000000000..a5bf422386e6 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/summary_results_py3.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: str=None, non_compliant_resources: int=None, non_compliant_policies: int=None, **kwargs) -> None: + super(SummaryResults, self).__init__(**kwargs) + 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..12605ac45d0f --- /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 .operations import Operations + +__all__ = [ + 'PolicyEventsOperations', + 'PolicyStatesOperations', + 'Operations', +] diff --git a/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/operations.py new file mode 100644 index 000000000000..b91e00dbf3d1 --- /dev/null +++ b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/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 Operations(object): + """Operations 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: "2018-04-04". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-04-04" + + self.config = config + + def list( + 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: OperationsListResults or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.policyinsights.models.OperationsListResults or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`QueryFailureException` + """ + # Construct URL + url = self.list.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('OperationsListResults', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.PolicyInsights/operations'} 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..784455cd7d62 --- /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: "2018-04-04". + :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 = "2018-04-04" + 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_states_operations.py b/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/policy_states_operations.py new file mode 100644 index 000000000000..46c80a060483 --- /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: "2018-04-04". + :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 = "2018-04-04" + 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, '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('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, '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('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, '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('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, '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('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, '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('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, '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('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, '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('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, '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('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..4a8ec57b07a8 --- /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 SDKClient +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.operations import Operations +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(SDKClient): + """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 operations: Operations operations + :vartype operations: azure.mgmt.policyinsights.operations.Operations + + :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) + super(PolicyInsightsClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2018-04-04' + 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.operations = Operations( + 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..e0ec669828cb --- /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 = "0.1.0" + diff --git a/azure-mgmt-policyinsights/azure_bdist_wheel.py b/azure-mgmt-policyinsights/azure_bdist_wheel.py new file mode 100644 index 000000000000..8a81d1b61775 --- /dev/null +++ b/azure-mgmt-policyinsights/azure_bdist_wheel.py @@ -0,0 +1,54 @@ +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +from distutils import log as logger +import os.path + +from wheel.bdist_wheel import bdist_wheel +class azure_bdist_wheel(bdist_wheel): + """The purpose of this class is to build wheel a little differently than the sdist, + without requiring to build the wheel from the sdist (i.e. you can build the wheel + directly from source). + """ + + description = "Create an Azure wheel distribution" + + user_options = bdist_wheel.user_options + \ + [('azure-namespace-package=', None, + "Name of the deepest nspkg used")] + + def initialize_options(self): + bdist_wheel.initialize_options(self) + self.azure_namespace_package = None + + def finalize_options(self): + bdist_wheel.finalize_options(self) + if self.azure_namespace_package and not self.azure_namespace_package.endswith("-nspkg"): + raise ValueError("azure_namespace_package must finish by -nspkg") + + def run(self): + if not self.distribution.install_requires: + self.distribution.install_requires = [] + self.distribution.install_requires.append( + "{}>=2.0.0".format(self.azure_namespace_package)) + bdist_wheel.run(self) + + def write_record(self, bdist_dir, distinfo_dir): + if self.azure_namespace_package: + # Split and remove last part, assuming it's "nspkg" + subparts = self.azure_namespace_package.split('-')[0:-1] + folder_with_init = [os.path.join(*subparts[0:i+1]) for i in range(len(subparts))] + for azure_sub_package in folder_with_init: + init_file = os.path.join(bdist_dir, azure_sub_package, '__init__.py') + if os.path.isfile(init_file): + logger.info("manually remove {} while building the wheel".format(init_file)) + os.remove(init_file) + else: + raise ValueError("Unable to find {}. Are you sure of your namespace package?".format(init_file)) + bdist_wheel.write_record(self, bdist_dir, distinfo_dir) +cmdclass = { + 'bdist_wheel': azure_bdist_wheel, +} diff --git a/azure-mgmt-policyinsights/setup.cfg b/azure-mgmt-policyinsights/setup.cfg new file mode 100644 index 000000000000..856f4164982c --- /dev/null +++ b/azure-mgmt-policyinsights/setup.cfg @@ -0,0 +1,3 @@ +[bdist_wheel] +universal=1 +azure-namespace-package=azure-mgmt-nspkg \ No newline at end of file diff --git a/azure-mgmt-policyinsights/setup.py b/azure-mgmt-policyinsights/setup.py new file mode 100644 index 000000000000..ed08d1623368 --- /dev/null +++ b/azure-mgmt-policyinsights/setup.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup +try: + from azure_bdist_wheel import cmdclass +except ImportError: + from distutils import log as logger + logger.warn("Wheel is not available, disabling bdist_wheel hook") + cmdclass = {} + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-policyinsights" +PACKAGE_PPRINT_NAME = "Policy Insights" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=["tests"]), + install_requires=[ + 'msrestazure>=0.4.27,<2.0.0', + 'azure-common~=1.1', + ], + cmdclass=cmdclass +)