diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md index 252c7c08d107..4df105f151e2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md +++ b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 0.6.0 (2020-11-11) + +**Features** + + - Model PolicyState has a new parameter components + - Model QueryOptions has a new parameter skip_token + - Model PolicyEvent has a new parameter compliance_state + - Model PolicyEvent has a new parameter components + +**Breaking changes** + + - Removed operation PolicyEventsOperations.get_metadata + ## 0.5.0 (2020-03-20) **Features** diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py index 40245a49addb..d1f747978980 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/__init__.py @@ -11,6 +11,8 @@ try: from ._models_py3 import ComplianceDetail + from ._models_py3 import ComponentEventDetails + from ._models_py3 import ComponentStateDetails from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorResponse, ErrorResponseException from ._models_py3 import ExpressionEvaluationDetails @@ -23,11 +25,9 @@ from ._models_py3 import PolicyDetails from ._models_py3 import PolicyEvaluationDetails from ._models_py3 import PolicyEvent - from ._models_py3 import PolicyEventsQueryResults from ._models_py3 import PolicyGroupSummary from ._models_py3 import PolicyMetadata from ._models_py3 import PolicyState - from ._models_py3 import PolicyStatesQueryResults from ._models_py3 import PolicyTrackedResource from ._models_py3 import QueryFailure, QueryFailureException from ._models_py3 import QueryFailureError @@ -44,6 +44,8 @@ from ._models_py3 import TypedErrorInfo except (SyntaxError, ImportError): from ._models import ComplianceDetail + from ._models import ComponentEventDetails + from ._models import ComponentStateDetails from ._models import ErrorDefinition from ._models import ErrorResponse, ErrorResponseException from ._models import ExpressionEvaluationDetails @@ -56,11 +58,9 @@ from ._models import PolicyDetails from ._models import PolicyEvaluationDetails from ._models import PolicyEvent - from ._models import PolicyEventsQueryResults from ._models import PolicyGroupSummary from ._models import PolicyMetadata from ._models import PolicyState - from ._models import PolicyStatesQueryResults from ._models import PolicyTrackedResource from ._models import QueryFailure, QueryFailureException from ._models import QueryFailureError @@ -75,6 +75,8 @@ from ._models import SummaryResults from ._models import TrackedResourceModificationDetails from ._models import TypedErrorInfo +from ._paged_models import PolicyEventPaged +from ._paged_models import PolicyStatePaged from ._paged_models import PolicyTrackedResourcePaged from ._paged_models import RemediationDeploymentPaged from ._paged_models import RemediationPaged @@ -86,6 +88,8 @@ __all__ = [ 'ComplianceDetail', + 'ComponentEventDetails', + 'ComponentStateDetails', 'ErrorDefinition', 'ErrorResponse', 'ErrorResponseException', 'ExpressionEvaluationDetails', @@ -98,11 +102,9 @@ 'PolicyDetails', 'PolicyEvaluationDetails', 'PolicyEvent', - 'PolicyEventsQueryResults', 'PolicyGroupSummary', 'PolicyMetadata', 'PolicyState', - 'PolicyStatesQueryResults', 'PolicyTrackedResource', 'QueryFailure', 'QueryFailureException', 'QueryFailureError', @@ -120,6 +122,8 @@ 'PolicyTrackedResourcePaged', 'RemediationDeploymentPaged', 'RemediationPaged', + 'PolicyEventPaged', + 'PolicyStatePaged', 'SlimPolicyMetadataPaged', 'ResourceDiscoveryMode', 'PolicyStatesResource', diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py index 5d416b1f7be2..410b4d0a4c69 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models.py @@ -41,6 +41,89 @@ def __init__(self, **kwargs): self.count = kwargs.get('count', None) +class ComponentEventDetails(Model): + """Component event details. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param id: Component Id. + :type id: str + :param type: Component type. + :type type: str + :param name: Component name. + :type name: str + :param timestamp: Timestamp for component policy event record. + :type timestamp: datetime + :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 component operation that triggered the policy event. + :type principal_oid: str + :param policy_definition_action: Policy definition action, i.e. effect. + :type policy_definition_action: str + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'principal_oid': {'key': 'principalOid', 'type': 'str'}, + 'policy_definition_action': {'key': 'policyDefinitionAction', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ComponentEventDetails, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.id = kwargs.get('id', None) + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) + self.timestamp = kwargs.get('timestamp', None) + self.tenant_id = kwargs.get('tenant_id', None) + self.principal_oid = kwargs.get('principal_oid', None) + self.policy_definition_action = kwargs.get('policy_definition_action', None) + + +class ComponentStateDetails(Model): + """Component state details. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param id: Component Id. + :type id: str + :param type: Component type. + :type type: str + :param name: Component name. + :type name: str + :param timestamp: Component compliance evaluation timestamp. + :type timestamp: datetime + :param compliance_state: Component compliance state. + :type compliance_state: str + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ComponentStateDetails, self).__init__(**kwargs) + self.additional_properties = kwargs.get('additional_properties', None) + self.id = kwargs.get('id', None) + self.type = kwargs.get('type', None) + self.name = kwargs.get('name', None) + self.timestamp = kwargs.get('timestamp', None) + self.compliance_state = kwargs.get('compliance_state', None) + + class ErrorDefinition(Model): """Error definition. @@ -459,11 +542,17 @@ class PolicyEvent(Model): definition inside the policy set, if the policy assignment is for a policy set. :type policy_definition_reference_id: str + :param compliance_state: Compliance state of the resource. + :type compliance_state: 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 + :param components: Components events records populated only when URL + contains $expand=components clause. + :type components: + list[~azure.mgmt.policyinsights.models.ComponentEventDetails] """ _attribute_map = { @@ -495,8 +584,10 @@ class PolicyEvent(Model): 'policy_set_definition_parameters': {'key': 'policySetDefinitionParameters', 'type': 'str'}, 'management_group_ids': {'key': 'managementGroupIds', 'type': 'str'}, 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, 'principal_oid': {'key': 'principalOid', 'type': 'str'}, + 'components': {'key': 'components', 'type': '[ComponentEventDetails]'}, } def __init__(self, **kwargs): @@ -529,38 +620,10 @@ def __init__(self, **kwargs): 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.compliance_state = kwargs.get('compliance_state', None) self.tenant_id = kwargs.get('tenant_id', None) self.principal_oid = kwargs.get('principal_oid', None) - - -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) + self.components = kwargs.get('components', None) class PolicyGroupSummary(Model): @@ -741,6 +804,10 @@ class PolicyState(Model): ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails :param policy_definition_group_names: Policy definition group names. :type policy_definition_group_names: list[str] + :param components: Components state compliance records populated only when + URL contains $expand=components clause. + :type components: + list[~azure.mgmt.policyinsights.models.ComponentStateDetails] :ivar policy_definition_version: Evaluated policy definition version. :vartype policy_definition_version: str :ivar policy_set_definition_version: Evaluated policy set definition @@ -788,6 +855,7 @@ class PolicyState(Model): 'compliance_state': {'key': 'complianceState', 'type': 'str'}, 'policy_evaluation_details': {'key': 'policyEvaluationDetails', 'type': 'PolicyEvaluationDetails'}, 'policy_definition_group_names': {'key': 'policyDefinitionGroupNames', 'type': '[str]'}, + 'components': {'key': 'components', 'type': '[ComponentStateDetails]'}, 'policy_definition_version': {'key': 'policyDefinitionVersion', 'type': 'str'}, 'policy_set_definition_version': {'key': 'policySetDefinitionVersion', 'type': 'str'}, 'policy_assignment_version': {'key': 'policyAssignmentVersion', 'type': 'str'}, @@ -826,41 +894,12 @@ def __init__(self, **kwargs): self.compliance_state = kwargs.get('compliance_state', None) self.policy_evaluation_details = kwargs.get('policy_evaluation_details', None) self.policy_definition_group_names = kwargs.get('policy_definition_group_names', None) + self.components = kwargs.get('components', None) self.policy_definition_version = None self.policy_set_definition_version = None self.policy_assignment_version = None -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) - - class PolicyTrackedResource(Model): """Policy tracked resource record. @@ -991,8 +1030,11 @@ class QueryOptions(Model): :type to: datetime :param apply: OData apply expression for aggregations. :type apply: str + :param skip_token: Skiptoken is only provided if a previous response + returned a partial result as a part of nextLink element. + :type skip_token: str :param expand: The $expand query parameter. For example, to expand - policyEvaluationDetails, use $expand=policyEvaluationDetails + components use $expand=components :type expand: str """ @@ -1004,6 +1046,7 @@ class QueryOptions(Model): 'from_property': {'key': '', 'type': 'iso-8601'}, 'to': {'key': '', 'type': 'iso-8601'}, 'apply': {'key': '', 'type': 'str'}, + 'skip_token': {'key': '', 'type': 'str'}, 'expand': {'key': '', 'type': 'str'}, } @@ -1016,6 +1059,7 @@ def __init__(self, **kwargs): self.from_property = kwargs.get('from_property', None) self.to = kwargs.get('to', None) self.apply = kwargs.get('apply', None) + self.skip_token = kwargs.get('skip_token', None) self.expand = kwargs.get('expand', None) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py index dccb0f38b622..af8ff3b760a8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_models_py3.py @@ -41,6 +41,89 @@ def __init__(self, *, compliance_state: str=None, count: int=None, **kwargs) -> self.count = count +class ComponentEventDetails(Model): + """Component event details. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param id: Component Id. + :type id: str + :param type: Component type. + :type type: str + :param name: Component name. + :type name: str + :param timestamp: Timestamp for component policy event record. + :type timestamp: datetime + :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 component operation that triggered the policy event. + :type principal_oid: str + :param policy_definition_action: Policy definition action, i.e. effect. + :type policy_definition_action: str + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'principal_oid': {'key': 'principalOid', 'type': 'str'}, + 'policy_definition_action': {'key': 'policyDefinitionAction', 'type': 'str'}, + } + + def __init__(self, *, additional_properties=None, id: str=None, type: str=None, name: str=None, timestamp=None, tenant_id: str=None, principal_oid: str=None, policy_definition_action: str=None, **kwargs) -> None: + super(ComponentEventDetails, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.id = id + self.type = type + self.name = name + self.timestamp = timestamp + self.tenant_id = tenant_id + self.principal_oid = principal_oid + self.policy_definition_action = policy_definition_action + + +class ComponentStateDetails(Model): + """Component state details. + + :param additional_properties: Unmatched properties from the message are + deserialized this collection + :type additional_properties: dict[str, object] + :param id: Component Id. + :type id: str + :param type: Component type. + :type type: str + :param name: Component name. + :type name: str + :param timestamp: Component compliance evaluation timestamp. + :type timestamp: datetime + :param compliance_state: Component compliance state. + :type compliance_state: str + """ + + _attribute_map = { + 'additional_properties': {'key': '', 'type': '{object}'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, + } + + def __init__(self, *, additional_properties=None, id: str=None, type: str=None, name: str=None, timestamp=None, compliance_state: str=None, **kwargs) -> None: + super(ComponentStateDetails, self).__init__(**kwargs) + self.additional_properties = additional_properties + self.id = id + self.type = type + self.name = name + self.timestamp = timestamp + self.compliance_state = compliance_state + + class ErrorDefinition(Model): """Error definition. @@ -459,11 +542,17 @@ class PolicyEvent(Model): definition inside the policy set, if the policy assignment is for a policy set. :type policy_definition_reference_id: str + :param compliance_state: Compliance state of the resource. + :type compliance_state: 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 + :param components: Components events records populated only when URL + contains $expand=components clause. + :type components: + list[~azure.mgmt.policyinsights.models.ComponentEventDetails] """ _attribute_map = { @@ -495,11 +584,13 @@ class PolicyEvent(Model): 'policy_set_definition_parameters': {'key': 'policySetDefinitionParameters', 'type': 'str'}, 'management_group_ids': {'key': 'managementGroupIds', 'type': 'str'}, 'policy_definition_reference_id': {'key': 'policyDefinitionReferenceId', 'type': 'str'}, + 'compliance_state': {'key': 'complianceState', 'type': 'str'}, 'tenant_id': {'key': 'tenantId', 'type': 'str'}, 'principal_oid': {'key': 'principalOid', 'type': 'str'}, + 'components': {'key': 'components', 'type': '[ComponentEventDetails]'}, } - def __init__(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: + 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, compliance_state: str=None, tenant_id: str=None, principal_oid: str=None, components=None, **kwargs) -> None: super(PolicyEvent, self).__init__(**kwargs) self.additional_properties = additional_properties self.odataid = odataid @@ -529,38 +620,10 @@ def __init__(self, *, additional_properties=None, odataid: str=None, odatacontex self.policy_set_definition_parameters = policy_set_definition_parameters self.management_group_ids = management_group_ids self.policy_definition_reference_id = policy_definition_reference_id + self.compliance_state = compliance_state self.tenant_id = tenant_id self.principal_oid = principal_oid - - -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 + self.components = components class PolicyGroupSummary(Model): @@ -741,6 +804,10 @@ class PolicyState(Model): ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails :param policy_definition_group_names: Policy definition group names. :type policy_definition_group_names: list[str] + :param components: Components state compliance records populated only when + URL contains $expand=components clause. + :type components: + list[~azure.mgmt.policyinsights.models.ComponentStateDetails] :ivar policy_definition_version: Evaluated policy definition version. :vartype policy_definition_version: str :ivar policy_set_definition_version: Evaluated policy set definition @@ -788,12 +855,13 @@ class PolicyState(Model): 'compliance_state': {'key': 'complianceState', 'type': 'str'}, 'policy_evaluation_details': {'key': 'policyEvaluationDetails', 'type': 'PolicyEvaluationDetails'}, 'policy_definition_group_names': {'key': 'policyDefinitionGroupNames', 'type': '[str]'}, + 'components': {'key': 'components', 'type': '[ComponentStateDetails]'}, 'policy_definition_version': {'key': 'policyDefinitionVersion', 'type': 'str'}, 'policy_set_definition_version': {'key': 'policySetDefinitionVersion', 'type': 'str'}, 'policy_assignment_version': {'key': 'policyAssignmentVersion', 'type': 'str'}, } - def __init__(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, compliance_state: str=None, policy_evaluation_details=None, policy_definition_group_names=None, **kwargs) -> None: + 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, compliance_state: str=None, policy_evaluation_details=None, policy_definition_group_names=None, components=None, **kwargs) -> None: super(PolicyState, self).__init__(**kwargs) self.additional_properties = additional_properties self.odataid = odataid @@ -826,41 +894,12 @@ def __init__(self, *, additional_properties=None, odataid: str=None, odatacontex self.compliance_state = compliance_state self.policy_evaluation_details = policy_evaluation_details self.policy_definition_group_names = policy_definition_group_names + self.components = components self.policy_definition_version = None self.policy_set_definition_version = None self.policy_assignment_version = None -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 - - class PolicyTrackedResource(Model): """Policy tracked resource record. @@ -991,8 +1030,11 @@ class QueryOptions(Model): :type to: datetime :param apply: OData apply expression for aggregations. :type apply: str + :param skip_token: Skiptoken is only provided if a previous response + returned a partial result as a part of nextLink element. + :type skip_token: str :param expand: The $expand query parameter. For example, to expand - policyEvaluationDetails, use $expand=policyEvaluationDetails + components use $expand=components :type expand: str """ @@ -1004,10 +1046,11 @@ class QueryOptions(Model): 'from_property': {'key': '', 'type': 'iso-8601'}, 'to': {'key': '', 'type': 'iso-8601'}, 'apply': {'key': '', 'type': 'str'}, + 'skip_token': {'key': '', 'type': 'str'}, 'expand': {'key': '', 'type': 'str'}, } - def __init__(self, *, top: int=None, filter: str=None, order_by: str=None, select: str=None, from_property=None, to=None, apply: str=None, expand: str=None, **kwargs) -> None: + def __init__(self, *, top: int=None, filter: str=None, order_by: str=None, select: str=None, from_property=None, to=None, apply: str=None, skip_token: str=None, expand: str=None, **kwargs) -> None: super(QueryOptions, self).__init__(**kwargs) self.top = top self.filter = filter @@ -1016,6 +1059,7 @@ def __init__(self, *, top: int=None, filter: str=None, order_by: str=None, selec self.from_property = from_property self.to = to self.apply = apply + self.skip_token = skip_token self.expand = expand diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_paged_models.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_paged_models.py index d944feb8b98c..71bbbaba4e81 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_paged_models.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_paged_models.py @@ -51,6 +51,32 @@ class RemediationPaged(Paged): def __init__(self, *args, **kwargs): super(RemediationPaged, self).__init__(*args, **kwargs) +class PolicyEventPaged(Paged): + """ + A paging container for iterating over a list of :class:`PolicyEvent ` object + """ + + _attribute_map = { + 'next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[PolicyEvent]'} + } + + def __init__(self, *args, **kwargs): + + super(PolicyEventPaged, self).__init__(*args, **kwargs) +class PolicyStatePaged(Paged): + """ + A paging container for iterating over a list of :class:`PolicyState ` object + """ + + _attribute_map = { + 'next_link': {'key': '@odata\\.nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[PolicyState]'} + } + + def __init__(self, *args, **kwargs): + + super(PolicyStatePaged, self).__init__(*args, **kwargs) class SlimPolicyMetadataPaged(Paged): """ A paging container for iterating over a list of :class:`SlimPolicyMetadata ` object diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py index 38ff6aef394b..454b0a2bf9a3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_events_operations.py @@ -26,7 +26,7 @@ class PolicyEventsOperations(object): :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 api_version: Client Api Version. Constant value: "2019-10-01". :ivar authorization_namespace: The namespace for Microsoft Authorization resource provider; only "Microsoft.Authorization" is allowed. Constant value: "Microsoft.Authorization". """ @@ -39,7 +39,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self.policy_events_resource = "default" self.management_groups_namespace = "Microsoft.Management" - self.api_version = "2018-04-04" + self.api_version = "2019-10-01" self.authorization_namespace = "Microsoft.Authorization" self.config = config @@ -57,9 +57,9 @@ def list_query_results_for_management_group( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -84,58 +84,74 @@ def list_query_results_for_management_group( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_management_group.metadata = {'url': '/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -153,9 +169,9 @@ def list_query_results_for_subscription( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -180,57 +196,73 @@ def list_query_results_for_subscription( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -250,9 +282,9 @@ def list_query_results_for_resource_group( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -277,58 +309,74 @@ def list_query_results_for_resource_group( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -346,9 +394,9 @@ def list_query_results_for_resource( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -373,57 +421,78 @@ def list_query_results_for_resource( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + expand = None + if query_options is not None: + expand = query_options.expand + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -443,9 +512,9 @@ def list_query_results_for_policy_set_definition( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -470,59 +539,75 @@ def list_query_results_for_policy_set_definition( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_policy_set_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -542,9 +627,9 @@ def list_query_results_for_policy_definition( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -569,59 +654,75 @@ def list_query_results_for_policy_definition( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_policy_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -641,9 +742,9 @@ def list_query_results_for_subscription_level_policy_assignment( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -668,59 +769,75 @@ def list_query_results_for_subscription_level_policy_assignment( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_subscription_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'} @@ -742,9 +859,9 @@ def list_query_results_for_resource_group_level_policy_assignment( 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 + :return: An iterator like instance of PolicyEvent + :rtype: + ~azure.mgmt.policyinsights.models.PolicyEventPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises: :class:`QueryFailureException` """ @@ -769,117 +886,76 @@ def list_query_results_for_resource_group_level_policy_assignment( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyEventPaged(internal_paging, self._deserialize.dependencies, header_dict) 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['Accept'] = 'application/xml' - 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, header_parameters) - response = self._client.send(request, 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/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py index e39c40bae51a..2afc48ce835e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_states_operations.py @@ -65,9 +65,9 @@ def list_query_results_for_management_group( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -92,58 +92,74 @@ def list_query_results_for_management_group( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_management_group.metadata = {'url': '/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -248,9 +264,9 @@ def list_query_results_for_subscription( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -275,57 +291,73 @@ def list_query_results_for_subscription( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -431,9 +463,9 @@ def list_query_results_for_resource_group( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -458,58 +490,74 @@ def list_query_results_for_resource_group( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -616,9 +664,9 @@ def list_query_results_for_resource( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -646,59 +694,75 @@ def list_query_results_for_resource( expand = None if query_options is not None: expand = query_options.expand - - # 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') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -956,9 +1020,9 @@ def list_query_results_for_policy_set_definition( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -983,59 +1047,75 @@ def list_query_results_for_policy_set_definition( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_policy_set_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -1146,9 +1226,9 @@ def list_query_results_for_policy_definition( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -1173,59 +1253,75 @@ def list_query_results_for_policy_definition( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_policy_definition.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -1335,9 +1431,9 @@ def list_query_results_for_subscription_level_policy_assignment( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -1362,59 +1458,75 @@ def list_query_results_for_subscription_level_policy_assignment( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) return deserialized list_query_results_for_subscription_level_policy_assignment.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'} @@ -1526,9 +1638,9 @@ def list_query_results_for_resource_group_level_policy_assignment( 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 + :return: An iterator like instance of PolicyState + :rtype: + ~azure.mgmt.policyinsights.models.PolicyStatePaged[~azure.mgmt.policyinsights.models.PolicyState] :raises: :class:`QueryFailureException` """ @@ -1553,60 +1665,76 @@ def list_query_results_for_resource_group_level_policy_assignment( 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['Accept'] = 'application/json' - 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, header_parameters) - response = self._client.send(request, 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) - + skip_token = None + if query_options is not None: + skip_token = query_options.skip_token + + def prepare_request(next_link=None): + if not next_link: + # 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') + if skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", skip_token, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.QueryFailureException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response + header_dict = {} + deserialized = models.PolicyStatePaged(internal_paging, self._deserialize.dependencies, header_dict) 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'} diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py index 266f5a486d79..5a7feab42d26 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.5.0" +VERSION = "0.6.0" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/setup.py b/sdk/policyinsights/azure-mgmt-policyinsights/setup.py index df5f109ce806..11d02ac515c1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/setup.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/setup.py @@ -36,7 +36,9 @@ pass # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1)