From e523e3065934b35e12721dd195c713f0352d28d5 Mon Sep 17 00:00:00 2001 From: Azure CLI Bot Date: Tue, 24 Aug 2021 10:18:19 +0800 Subject: [PATCH] [AutoRelease] t2-policyinsights-2021-08-23-78735 (#20381) * CodeGen from PR 15165 in Azure/azure-rest-api-specs [policyinsights] Fix next_link (#15165) * fix next_link * directive * Update readme.nodejs.md * js directvie * Update readme.md * supress other language * Update readme.go.md * swagger lint * swagger lint * swagger lint * Update readme.md * version,CHANGELOG Co-authored-by: SDKAuto Co-authored-by: PythonSdkPipelines Co-authored-by: Zed Lei <59104634+RAY-316@users.noreply.github.com> --- .../azure-mgmt-policyinsights/CHANGELOG.md | 6 + .../azure-mgmt-policyinsights/MANIFEST.in | 1 + .../azure-mgmt-policyinsights/_meta.json | 11 + .../azure/mgmt/policyinsights/_metadata.json | 110 ++ .../policyinsights/_policy_insights_client.py | 24 + .../azure/mgmt/policyinsights/_version.py | 2 +- .../aio/_policy_insights_client.py | 23 + .../policyinsights/aio/operations/__init__.py | 2 + .../operations/_attestations_operations.py | 1004 ++++++++++++++++ .../aio/operations/_operations.py | 4 +- .../operations/_policy_events_operations.py | 136 ++- .../operations/_policy_metadata_operations.py | 8 +- .../_policy_restrictions_operations.py | 10 +- .../operations/_policy_states_operations.py | 188 ++- .../_policy_tracked_resources_operations.py | 16 +- .../operations/_remediations_operations.py | 96 +- .../mgmt/policyinsights/models/__init__.py | 25 + .../mgmt/policyinsights/models/_models.py | 307 ++++- .../mgmt/policyinsights/models/_models_py3.py | 343 +++++- .../models/_policy_insights_client_enums.py | 36 +- .../policyinsights/operations/__init__.py | 2 + .../operations/_attestations_operations.py | 1023 +++++++++++++++++ .../policyinsights/operations/_operations.py | 2 +- .../operations/_policy_events_operations.py | 120 +- .../operations/_policy_metadata_operations.py | 4 +- .../_policy_restrictions_operations.py | 6 +- .../operations/_policy_states_operations.py | 148 ++- .../_policy_tracked_resources_operations.py | 8 +- .../operations/_remediations_operations.py | 48 +- .../azure-mgmt-policyinsights/setup.py | 2 +- shared_requirements.txt | 1 + 31 files changed, 3424 insertions(+), 292 deletions(-) create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/_meta.json create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_metadata.json create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_attestations_operations.py create mode 100644 sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_attestations_operations.py diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md index cecb2669e0f0..4501310484cd 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md +++ b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0b1 (2021-08-23) + +**Features** + + - Added operation group AttestationsOperations + ## 1.0.0 (2020-12-22) **Features** diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in b/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in +++ b/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json b/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json new file mode 100644 index 000000000000..f9e83a05af21 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.5", + "use": [ + "@autorest/python@5.8.4", + "@autorest/modelerfour@4.19.2" + ], + "commit": "e7682aa897902920f3a95b2f358b6f7729d18666", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/policyinsights/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "readme": "specification/policyinsights/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_metadata.json b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_metadata.json new file mode 100644 index 000000000000..e9fc1e55b97a --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "", + "total_api_version_list": ["2018-07-01-preview", "2019-07-01", "2019-10-01", "2020-07-01", "2021-01-01"], + "client": { + "name": "PolicyInsightsClient", + "filename": "_policy_insights_client", + "description": "PolicyInsightsClient.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyInsightsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"PolicyInsightsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Microsoft Azure subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Microsoft Azure subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "policy_tracked_resources": "PolicyTrackedResourcesOperations", + "remediations": "RemediationsOperations", + "policy_events": "PolicyEventsOperations", + "policy_states": "PolicyStatesOperations", + "operations": "Operations", + "policy_metadata": "PolicyMetadataOperations", + "policy_restrictions": "PolicyRestrictionsOperations", + "attestations": "AttestationsOperations" + } +} \ No newline at end of file diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py index 5fec7a26850b..33c6cc7c635e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_policy_insights_client.py @@ -16,6 +16,7 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import PolicyInsightsClientConfiguration from .operations import PolicyTrackedResourcesOperations @@ -25,6 +26,7 @@ from .operations import Operations from .operations import PolicyMetadataOperations from .operations import PolicyRestrictionsOperations +from .operations import AttestationsOperations from . import models @@ -45,6 +47,8 @@ class PolicyInsightsClient(object): :vartype policy_metadata: azure.mgmt.policyinsights.operations.PolicyMetadataOperations :ivar policy_restrictions: PolicyRestrictionsOperations operations :vartype policy_restrictions: azure.mgmt.policyinsights.operations.PolicyRestrictionsOperations + :ivar attestations: AttestationsOperations operations + :vartype attestations: azure.mgmt.policyinsights.operations.AttestationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Microsoft Azure subscription ID. @@ -85,6 +89,26 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.policy_restrictions = PolicyRestrictionsOperations( self._client, self._config, self._serialize, self._deserialize) + self.attestations = AttestationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response def close(self): # type: () -> None 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 c47f66669f1b..653b73a4a199 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_version.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.1.0b1" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py index a25f9650bbb1..0556529830fd 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py @@ -8,6 +8,7 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer @@ -23,6 +24,7 @@ from .operations import Operations from .operations import PolicyMetadataOperations from .operations import PolicyRestrictionsOperations +from .operations import AttestationsOperations from .. import models @@ -43,6 +45,8 @@ class PolicyInsightsClient(object): :vartype policy_metadata: azure.mgmt.policyinsights.aio.operations.PolicyMetadataOperations :ivar policy_restrictions: PolicyRestrictionsOperations operations :vartype policy_restrictions: azure.mgmt.policyinsights.aio.operations.PolicyRestrictionsOperations + :ivar attestations: AttestationsOperations operations + :vartype attestations: azure.mgmt.policyinsights.aio.operations.AttestationsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Microsoft Azure subscription ID. @@ -82,6 +86,25 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.policy_restrictions = PolicyRestrictionsOperations( self._client, self._config, self._serialize, self._deserialize) + self.attestations = AttestationsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response async def close(self) -> None: await self._client.close() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py index 4bbdef723768..91acca23d156 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/__init__.py @@ -13,6 +13,7 @@ from ._operations import Operations from ._policy_metadata_operations import PolicyMetadataOperations from ._policy_restrictions_operations import PolicyRestrictionsOperations +from ._attestations_operations import AttestationsOperations __all__ = [ 'PolicyTrackedResourcesOperations', @@ -22,4 +23,5 @@ 'Operations', 'PolicyMetadataOperations', 'PolicyRestrictionsOperations', + 'AttestationsOperations', ] diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_attestations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_attestations_operations.py new file mode 100644 index 000000000000..4f275f504f4f --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_attestations_operations.py @@ -0,0 +1,1004 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AttestationsOperations: + """AttestationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.policyinsights.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_for_subscription( + self, + query_options: Optional["_models.QueryOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AttestationListResult"]: + """Gets all attestations for the subscription. + + :param query_options: Parameter group. + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AttestationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.AttestationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttestationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _top = None + _filter = None + if query_options is not None: + _top = query_options.top + _filter = query_options.filter + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_for_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if _top is not None: + query_parameters['$top'] = self._serialize.query("top", _top, 'int', minimum=0) + if _filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", _filter, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AttestationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations'} # type: ignore + + async def _create_or_update_at_subscription_initial( + self, + attestation_name: str, + parameters: "_models.Attestation", + **kwargs: Any + ) -> "_models.Attestation": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_subscription_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Attestation') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Attestation', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_subscription_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def begin_create_or_update_at_subscription( + self, + attestation_name: str, + parameters: "_models.Attestation", + **kwargs: Any + ) -> AsyncLROPoller["_models.Attestation"]: + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. + :type attestation_name: str + :param parameters: The attestation parameters. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Attestation or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_subscription_initial( + attestation_name=attestation_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def get_at_subscription( + self, + attestation_name: str, + **kwargs: Any + ) -> "_models.Attestation": + """Gets an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Attestation, or the result of cls(response) + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def delete_at_subscription( + self, + attestation_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name: str, + query_options: Optional["_models.QueryOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AttestationListResult"]: + """Gets all attestations for the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_options: Parameter group. + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AttestationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.AttestationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttestationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _top = None + _filter = None + if query_options is not None: + _top = query_options.top + _filter = query_options.filter + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_for_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if _top is not None: + query_parameters['$top'] = self._serialize.query("top", _top, 'int', minimum=0) + if _filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", _filter, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AttestationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations'} # type: ignore + + async def _create_or_update_at_resource_group_initial( + self, + resource_group_name: str, + attestation_name: str, + parameters: "_models.Attestation", + **kwargs: Any + ) -> "_models.Attestation": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_resource_group_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Attestation') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Attestation', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def begin_create_or_update_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + parameters: "_models.Attestation", + **kwargs: Any + ) -> AsyncLROPoller["_models.Attestation"]: + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :param parameters: The attestation parameters. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Attestation or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_resource_group_initial( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def get_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + **kwargs: Any + ) -> "_models.Attestation": + """Gets an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Attestation, or the result of cls(response) + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def delete_at_resource_group( + self, + resource_group_name: str, + attestation_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def list_for_resource( + self, + resource_id: str, + query_options: Optional["_models.QueryOptions"] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AttestationListResult"]: + """Gets all attestations for a resource. + + :param resource_id: Resource ID. + :type resource_id: str + :param query_options: Parameter group. + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AttestationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.AttestationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttestationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _top = None + _filter = None + if query_options is not None: + _top = query_options.top + _filter = query_options.filter + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_for_resource.metadata['url'] # type: ignore + path_format_arguments = { + '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 = {} # type: Dict[str, Any] + if _top is not None: + query_parameters['$top'] = self._serialize.query("top", _top, 'int', minimum=0) + if _filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", _filter, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('AttestationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations'} # type: ignore + + async def _create_or_update_at_resource_initial( + self, + resource_id: str, + attestation_name: str, + parameters: "_models.Attestation", + **kwargs: Any + ) -> "_models.Attestation": + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_resource_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Attestation') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Attestation', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_resource_initial.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def begin_create_or_update_at_resource( + self, + resource_id: str, + attestation_name: str, + parameters: "_models.Attestation", + **kwargs: Any + ) -> AsyncLROPoller["_models.Attestation"]: + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. + :type resource_id: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :param parameters: The attestation parameters. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Attestation or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_at_resource_initial( + resource_id=resource_id, + attestation_name=attestation_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def get_at_resource( + self, + resource_id: str, + attestation_name: str, + **kwargs: Any + ) -> "_models.Attestation": + """Gets an existing attestation at resource scope. + + :param resource_id: Resource ID. + :type resource_id: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Attestation, or the result of cls(response) + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_resource.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + async def delete_at_resource( + self, + resource_id: str, + attestation_name: str, + **kwargs: Any + ) -> None: + """Deletes an existing attestation at individual resource scope. + + :param resource_id: Resource ID. + :type resource_id: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_resource.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py index 8cfd0d1c363d..641f29cf3ee3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_operations.py @@ -42,7 +42,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def list( self, - **kwargs + **kwargs: Any ) -> "_models.OperationsListResults": """Lists available operations. @@ -76,7 +76,7 @@ async def list( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('OperationsListResults', pipeline_response) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py index 73091e34d4f2..ad883b494f7d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_events_operations.py @@ -46,7 +46,7 @@ def list_query_results_for_management_group( self, management_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the resources under the management group. @@ -123,9 +123,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -142,7 +151,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -157,7 +166,7 @@ def list_query_results_for_subscription( self, subscription_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the resources under the subscription. @@ -232,9 +241,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -251,7 +269,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -267,7 +285,7 @@ def list_query_results_for_resource_group( subscription_id: str, resource_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the resources under the resource group. @@ -345,9 +363,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -364,7 +391,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -379,7 +406,7 @@ def list_query_results_for_resource( self, resource_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the resource. @@ -458,9 +485,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -477,7 +513,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -493,7 +529,7 @@ def list_query_results_for_policy_set_definition( subscription_id: str, policy_set_definition_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the subscription level policy set definition. @@ -573,9 +609,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -592,7 +637,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -608,7 +653,7 @@ def list_query_results_for_policy_definition( subscription_id: str, policy_definition_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the subscription level policy definition. @@ -688,9 +733,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -707,7 +761,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -723,7 +777,7 @@ def list_query_results_for_subscription_level_policy_assignment( subscription_id: str, policy_assignment_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the subscription level policy assignment. @@ -803,9 +857,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -822,7 +885,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -839,7 +902,7 @@ def list_query_results_for_resource_group_level_policy_assignment( resource_group_name: str, policy_assignment_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyEventsQueryResults"]: """Queries policy events for the resource group level policy assignment. @@ -922,9 +985,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -941,7 +1013,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py index b2488814080f..e9e5c96bd425 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_metadata_operations.py @@ -44,7 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_resource( self, resource_name: str, - **kwargs + **kwargs: Any ) -> "_models.PolicyMetadata": """Get policy metadata resource. @@ -84,7 +84,7 @@ async def get_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyMetadata', pipeline_response) @@ -98,7 +98,7 @@ async def get_resource( def list( self, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyMetadataCollection"]: """Get a list of the policy metadata resources. @@ -156,7 +156,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py index 8c3907b612c3..d9496ceb4a23 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_restrictions_operations.py @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def check_at_subscription_scope( self, parameters: "_models.CheckRestrictionsRequest", - **kwargs + **kwargs: Any ) -> "_models.CheckRestrictionsResult": """Checks what restrictions Azure Policy will place on a resource within a subscription. @@ -88,7 +88,7 @@ async def check_at_subscription_scope( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckRestrictionsResult', pipeline_response) @@ -103,7 +103,7 @@ async def check_at_resource_group_scope( self, resource_group_name: str, parameters: "_models.CheckRestrictionsRequest", - **kwargs + **kwargs: Any ) -> "_models.CheckRestrictionsResult": """Checks what restrictions Azure Policy will place on a resource within a resource group. Use this when the resource group the resource will be created in is already known. @@ -130,7 +130,7 @@ async def check_at_resource_group_scope( url = self.check_at_resource_group_scope.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -152,7 +152,7 @@ async def check_at_resource_group_scope( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckRestrictionsResult', pipeline_response) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py index 6d6684a697c9..1781596a2e6d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_states_operations.py @@ -49,7 +49,7 @@ def list_query_results_for_management_group( policy_states_resource: Union[str, "_models.PolicyStatesResource"], management_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the resources under the management group. @@ -129,9 +129,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -148,7 +157,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -163,7 +172,7 @@ async def summarize_for_management_group( self, management_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the resources under the management group. @@ -227,7 +236,7 @@ async def summarize_for_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -243,7 +252,7 @@ def list_query_results_for_subscription( policy_states_resource: Union[str, "_models.PolicyStatesResource"], subscription_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the resources under the subscription. @@ -321,9 +330,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -340,7 +358,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -355,7 +373,7 @@ async def summarize_for_subscription( self, subscription_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the resources under the subscription. @@ -417,7 +435,7 @@ async def summarize_for_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -434,7 +452,7 @@ def list_query_results_for_resource_group( subscription_id: str, resource_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the resources under the resource group. @@ -515,9 +533,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -534,7 +561,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -550,7 +577,7 @@ async def summarize_for_resource_group( subscription_id: str, resource_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the resources under the resource group. @@ -615,7 +642,7 @@ async def summarize_for_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -631,7 +658,7 @@ def list_query_results_for_resource( policy_states_resource: Union[str, "_models.PolicyStatesResource"], resource_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the resource. @@ -713,9 +740,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -732,7 +768,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -747,7 +783,7 @@ async def summarize_for_resource( self, resource_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the resource. @@ -809,7 +845,7 @@ async def summarize_for_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -823,7 +859,7 @@ async def summarize_for_resource( async def _trigger_subscription_evaluation_initial( self, subscription_id: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -854,7 +890,7 @@ async def _trigger_subscription_evaluation_initial( if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -865,7 +901,7 @@ async def _trigger_subscription_evaluation_initial( async def begin_trigger_subscription_evaluation( self, subscription_id: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Triggers a policy evaluation scan for all the resources under the subscription. @@ -873,8 +909,8 @@ async def begin_trigger_subscription_evaluation( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) @@ -924,7 +960,7 @@ async def _trigger_resource_group_evaluation_initial( self, subscription_id: str, resource_group_name: str, - **kwargs + **kwargs: Any ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { @@ -956,7 +992,7 @@ async def _trigger_resource_group_evaluation_initial( if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -968,7 +1004,7 @@ async def begin_trigger_resource_group_evaluation( self, subscription_id: str, resource_group_name: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller[None]: """Triggers a policy evaluation scan for all the resources under the resource group. @@ -978,8 +1014,8 @@ async def begin_trigger_resource_group_evaluation( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be AsyncARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) @@ -1033,7 +1069,7 @@ def list_query_results_for_policy_set_definition( subscription_id: str, policy_set_definition_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the subscription level policy set definition. @@ -1116,9 +1152,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -1135,7 +1180,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1151,7 +1196,7 @@ async def summarize_for_policy_set_definition( subscription_id: str, policy_set_definition_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the subscription level policy set definition. @@ -1218,7 +1263,7 @@ async def summarize_for_policy_set_definition( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -1235,7 +1280,7 @@ def list_query_results_for_policy_definition( subscription_id: str, policy_definition_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the subscription level policy definition. @@ -1318,9 +1363,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -1337,7 +1391,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1353,7 +1407,7 @@ async def summarize_for_policy_definition( subscription_id: str, policy_definition_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the subscription level policy definition. @@ -1420,7 +1474,7 @@ async def summarize_for_policy_definition( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -1437,7 +1491,7 @@ def list_query_results_for_subscription_level_policy_assignment( subscription_id: str, policy_assignment_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the subscription level policy assignment. @@ -1520,9 +1574,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -1539,7 +1602,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1555,7 +1618,7 @@ async def summarize_for_subscription_level_policy_assignment( subscription_id: str, policy_assignment_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the subscription level policy assignment. @@ -1622,7 +1685,7 @@ async def summarize_for_subscription_level_policy_assignment( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -1640,7 +1703,7 @@ def list_query_results_for_resource_group_level_policy_assignment( resource_group_name: str, policy_assignment_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyStatesQueryResults"]: """Queries policy states for the resource group level policy assignment. @@ -1726,9 +1789,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): @@ -1745,7 +1817,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1762,7 +1834,7 @@ async def summarize_for_resource_group_level_policy_assignment( resource_group_name: str, policy_assignment_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> "_models.SummarizeResults": """Summarizes policy states for the resource group level policy assignment. @@ -1832,7 +1904,7 @@ async def summarize_for_resource_group_level_policy_assignment( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py index b6265dc74008..284d2241b3b8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_policy_tracked_resources_operations.py @@ -45,7 +45,7 @@ def list_query_results_for_management_group( self, management_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyTrackedResourcesQueryResults"]: """Queries policy tracked resources under the management group. @@ -117,7 +117,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -131,7 +131,7 @@ async def get_next(next_link=None): def list_query_results_for_subscription( self, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyTrackedResourcesQueryResults"]: """Queries policy tracked resources under the subscription. @@ -199,7 +199,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -214,7 +214,7 @@ def list_query_results_for_resource_group( self, resource_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyTrackedResourcesQueryResults"]: """Queries policy tracked resources under the resource group. @@ -285,7 +285,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -300,7 +300,7 @@ def list_query_results_for_resource( self, resource_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.PolicyTrackedResourcesQueryResults"]: """Queries policy tracked resources under the resource. @@ -370,7 +370,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py index 60c530affebd..8b1120d457fd 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_remediations_operations.py @@ -46,7 +46,7 @@ def list_deployments_at_management_group( management_group_id: str, remediation_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationDeploymentsListResult"]: """Gets all deployments for a remediation at management group scope. @@ -115,7 +115,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -130,7 +130,7 @@ async def cancel_at_management_group( self, management_group_id: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Cancels a remediation at management group scope. @@ -175,7 +175,7 @@ async def cancel_at_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -190,7 +190,7 @@ def list_for_management_group( self, management_group_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationListResult"]: """Gets all remediations for the management group. @@ -260,7 +260,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -276,7 +276,7 @@ async def create_or_update_at_management_group( management_group_id: str, remediation_name: str, parameters: "_models.Remediation", - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Creates or updates a remediation at management group scope. @@ -328,7 +328,7 @@ async def create_or_update_at_management_group( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -347,7 +347,7 @@ async def get_at_management_group( self, management_group_id: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Gets an existing remediation at management group scope. @@ -392,7 +392,7 @@ async def get_at_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -407,7 +407,7 @@ async def delete_at_management_group( self, management_group_id: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> Optional["_models.Remediation"]: """Deletes an existing remediation at management group scope. @@ -452,7 +452,7 @@ async def delete_at_management_group( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -469,7 +469,7 @@ def list_deployments_at_subscription( self, remediation_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationDeploymentsListResult"]: """Gets all deployments for a remediation at subscription scope. @@ -534,7 +534,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -548,7 +548,7 @@ async def get_next(next_link=None): async def cancel_at_subscription( self, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Cancels a remediation at subscription scope. @@ -589,7 +589,7 @@ async def cancel_at_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -603,7 +603,7 @@ async def cancel_at_subscription( def list_for_subscription( self, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationListResult"]: """Gets all remediations for the subscription. @@ -669,7 +669,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -684,7 +684,7 @@ async def create_or_update_at_subscription( self, remediation_name: str, parameters: "_models.Remediation", - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Creates or updates a remediation at subscription scope. @@ -732,7 +732,7 @@ async def create_or_update_at_subscription( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -750,7 +750,7 @@ async def create_or_update_at_subscription( async def get_at_subscription( self, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Gets an existing remediation at subscription scope. @@ -791,7 +791,7 @@ async def get_at_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -805,7 +805,7 @@ async def get_at_subscription( async def delete_at_subscription( self, remediation_name: str, - **kwargs + **kwargs: Any ) -> Optional["_models.Remediation"]: """Deletes an existing remediation at subscription scope. @@ -846,7 +846,7 @@ async def delete_at_subscription( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -864,7 +864,7 @@ def list_deployments_at_resource_group( resource_group_name: str, remediation_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationDeploymentsListResult"]: """Gets all deployments for a remediation at resource group scope. @@ -932,7 +932,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -947,7 +947,7 @@ async def cancel_at_resource_group( self, resource_group_name: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Cancels a remediation at resource group scope. @@ -991,7 +991,7 @@ async def cancel_at_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1006,7 +1006,7 @@ def list_for_resource_group( self, resource_group_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationListResult"]: """Gets all remediations for the subscription. @@ -1075,7 +1075,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1091,7 +1091,7 @@ async def create_or_update_at_resource_group( resource_group_name: str, remediation_name: str, parameters: "_models.Remediation", - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Creates or updates a remediation at resource group scope. @@ -1142,7 +1142,7 @@ async def create_or_update_at_resource_group( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -1161,7 +1161,7 @@ async def get_at_resource_group( self, resource_group_name: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Gets an existing remediation at resource group scope. @@ -1205,7 +1205,7 @@ async def get_at_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1220,7 +1220,7 @@ async def delete_at_resource_group( self, resource_group_name: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> Optional["_models.Remediation"]: """Deletes an existing remediation at resource group scope. @@ -1264,7 +1264,7 @@ async def delete_at_resource_group( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -1282,7 +1282,7 @@ def list_deployments_at_resource( resource_id: str, remediation_name: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationDeploymentsListResult"]: """Gets all deployments for a remediation at resource scope. @@ -1349,7 +1349,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1364,7 +1364,7 @@ async def cancel_at_resource( self, resource_id: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Cancel a remediation at resource scope. @@ -1407,7 +1407,7 @@ async def cancel_at_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1422,7 +1422,7 @@ def list_for_resource( self, resource_id: str, query_options: Optional["_models.QueryOptions"] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.RemediationListResult"]: """Gets all remediations for a resource. @@ -1490,7 +1490,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1506,7 +1506,7 @@ async def create_or_update_at_resource( resource_id: str, remediation_name: str, parameters: "_models.Remediation", - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Creates or updates a remediation at resource scope. @@ -1556,7 +1556,7 @@ async def create_or_update_at_resource( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -1575,7 +1575,7 @@ async def get_at_resource( self, resource_id: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> "_models.Remediation": """Gets an existing remediation at resource scope. @@ -1618,7 +1618,7 @@ async def get_at_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1633,7 +1633,7 @@ async def delete_at_resource( self, resource_id: str, remediation_name: str, - **kwargs + **kwargs: Any ) -> Optional["_models.Remediation"]: """Deletes an existing remediation at individual resource scope. @@ -1676,7 +1676,7 @@ async def delete_at_resource( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None 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 a50103be3989..00ee9be05f6e 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 @@ -7,6 +7,9 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import Attestation + from ._models_py3 import AttestationEvidence + from ._models_py3 import AttestationListResult from ._models_py3 import CheckRestrictionsRequest from ._models_py3 import CheckRestrictionsResourceDetails from ._models_py3 import CheckRestrictionsResult @@ -16,8 +19,10 @@ from ._models_py3 import ComponentStateDetails from ._models_py3 import ErrorDefinition from ._models_py3 import ErrorDefinitionAutoGenerated + from ._models_py3 import ErrorDefinitionAutoGenerated2 from ._models_py3 import ErrorResponse from ._models_py3 import ErrorResponseAutoGenerated + from ._models_py3 import ErrorResponseAutoGenerated2 from ._models_py3 import ExpressionEvaluationDetails from ._models_py3 import FieldRestriction from ._models_py3 import FieldRestrictions @@ -52,13 +57,18 @@ from ._models_py3 import RemediationDeploymentsListResult from ._models_py3 import RemediationFilters from ._models_py3 import RemediationListResult + from ._models_py3 import Resource from ._models_py3 import SlimPolicyMetadata from ._models_py3 import SummarizeResults from ._models_py3 import Summary from ._models_py3 import SummaryResults + from ._models_py3 import SystemData from ._models_py3 import TrackedResourceModificationDetails from ._models_py3 import TypedErrorInfo except (SyntaxError, ImportError): + from ._models import Attestation # type: ignore + from ._models import AttestationEvidence # type: ignore + from ._models import AttestationListResult # type: ignore from ._models import CheckRestrictionsRequest # type: ignore from ._models import CheckRestrictionsResourceDetails # type: ignore from ._models import CheckRestrictionsResult # type: ignore @@ -68,8 +78,10 @@ from ._models import ComponentStateDetails # type: ignore from ._models import ErrorDefinition # type: ignore from ._models import ErrorDefinitionAutoGenerated # type: ignore + from ._models import ErrorDefinitionAutoGenerated2 # type: ignore from ._models import ErrorResponse # type: ignore from ._models import ErrorResponseAutoGenerated # type: ignore + from ._models import ErrorResponseAutoGenerated2 # type: ignore from ._models import ExpressionEvaluationDetails # type: ignore from ._models import FieldRestriction # type: ignore from ._models import FieldRestrictions # type: ignore @@ -104,20 +116,27 @@ from ._models import RemediationDeploymentsListResult # type: ignore from ._models import RemediationFilters # type: ignore from ._models import RemediationListResult # type: ignore + from ._models import Resource # type: ignore from ._models import SlimPolicyMetadata # type: ignore from ._models import SummarizeResults # type: ignore from ._models import Summary # type: ignore from ._models import SummaryResults # type: ignore + from ._models import SystemData # type: ignore from ._models import TrackedResourceModificationDetails # type: ignore from ._models import TypedErrorInfo # type: ignore from ._policy_insights_client_enums import ( + ComplianceState, + CreatedByType, FieldRestrictionResult, PolicyStatesResource, ResourceDiscoveryMode, ) __all__ = [ + 'Attestation', + 'AttestationEvidence', + 'AttestationListResult', 'CheckRestrictionsRequest', 'CheckRestrictionsResourceDetails', 'CheckRestrictionsResult', @@ -127,8 +146,10 @@ 'ComponentStateDetails', 'ErrorDefinition', 'ErrorDefinitionAutoGenerated', + 'ErrorDefinitionAutoGenerated2', 'ErrorResponse', 'ErrorResponseAutoGenerated', + 'ErrorResponseAutoGenerated2', 'ExpressionEvaluationDetails', 'FieldRestriction', 'FieldRestrictions', @@ -163,12 +184,16 @@ 'RemediationDeploymentsListResult', 'RemediationFilters', 'RemediationListResult', + 'Resource', 'SlimPolicyMetadata', 'SummarizeResults', 'Summary', 'SummaryResults', + 'SystemData', 'TrackedResourceModificationDetails', 'TypedErrorInfo', + 'ComplianceState', + 'CreatedByType', 'FieldRestrictionResult', 'PolicyStatesResource', 'ResourceDiscoveryMode', 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 3129367f2ef0..6d0131209fa1 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 @@ -10,6 +10,184 @@ import msrest.serialization +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Attestation(Resource): + """An attestation resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + :param policy_assignment_id: Required. The resource ID of the policy assignment that the + attestation is setting the state for. + :type policy_assignment_id: str + :param policy_definition_reference_id: The policy definition reference ID from a policy set + definition that the attestation is setting the state for. If the policy assignment assigns a + policy set definition the attestation can choose a definition within the set definition with + this property or omit this and set the state for the entire set definition. + :type policy_definition_reference_id: str + :param compliance_state: The compliance state that should be set on the resource. Possible + values include: "Compliant", "NonCompliant", "Unknown". + :type compliance_state: str or ~azure.mgmt.policyinsights.models.ComplianceState + :param expires_on: The time the compliance state should expire. + :type expires_on: ~datetime.datetime + :param owner: The person responsible for setting the state of the resource. This value is + typically an Azure Active Directory object ID. + :type owner: str + :param comments: Comments describing why this attestation was created. + :type comments: str + :param evidence: The evidence supporting the compliance state set in this attestation. + :type evidence: list[~azure.mgmt.policyinsights.models.AttestationEvidence] + :ivar provisioning_state: The status of the attestation. + :vartype provisioning_state: str + :ivar last_compliance_state_change_at: The time the compliance state was last changed in this + attestation. + :vartype last_compliance_state_change_at: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'policy_assignment_id': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'last_compliance_state_change_at': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'policy_assignment_id': {'key': 'properties.policyAssignmentId', 'type': 'str'}, + 'policy_definition_reference_id': {'key': 'properties.policyDefinitionReferenceId', 'type': 'str'}, + 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, + 'expires_on': {'key': 'properties.expiresOn', 'type': 'iso-8601'}, + 'owner': {'key': 'properties.owner', 'type': 'str'}, + 'comments': {'key': 'properties.comments', 'type': 'str'}, + 'evidence': {'key': 'properties.evidence', 'type': '[AttestationEvidence]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'last_compliance_state_change_at': {'key': 'properties.lastComplianceStateChangeAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(Attestation, self).__init__(**kwargs) + self.system_data = None + self.policy_assignment_id = kwargs['policy_assignment_id'] + self.policy_definition_reference_id = kwargs.get('policy_definition_reference_id', None) + self.compliance_state = kwargs.get('compliance_state', None) + self.expires_on = kwargs.get('expires_on', None) + self.owner = kwargs.get('owner', None) + self.comments = kwargs.get('comments', None) + self.evidence = kwargs.get('evidence', None) + self.provisioning_state = None + self.last_compliance_state_change_at = None + + +class AttestationEvidence(msrest.serialization.Model): + """A piece of evidence supporting the compliance state set in the attestation. + + :param description: The description for this piece of evidence. + :type description: str + :param source_uri: The URI location of the evidence. + :type source_uri: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'source_uri': {'key': 'sourceUri', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AttestationEvidence, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.source_uri = kwargs.get('source_uri', None) + + +class AttestationListResult(msrest.serialization.Model): + """List of attestations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of attestation definitions. + :vartype value: list[~azure.mgmt.policyinsights.models.Attestation] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Attestation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AttestationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class CheckRestrictionsRequest(msrest.serialization.Model): """The check policy restrictions parameters describing the resource that is being evaluated. @@ -47,7 +225,7 @@ class CheckRestrictionsResourceDetails(msrest.serialization.Model): :param resource_content: Required. The resource content. This should include whatever properties are already known and can be a partial set of all resource properties. - :type resource_content: object + :type resource_content: any :param api_version: The api-version of the resource content. :type api_version: str :param scope: The scope where the resource is being created. For example, if the resource is a @@ -155,7 +333,7 @@ class ComponentEventDetails(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Component Id. :type id: str :param type: Component type. @@ -204,7 +382,7 @@ class ComponentStateDetails(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Component Id. :type id: str :param type: Component type. @@ -329,6 +507,51 @@ def __init__( self.additional_info = None +class ErrorDefinitionAutoGenerated2(msrest.serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated2] + :ivar additional_info: Additional scenario specific error details. + :vartype additional_info: list[~azure.mgmt.policyinsights.models.TypedErrorInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinitionAutoGenerated2]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[TypedErrorInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinitionAutoGenerated2, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + class ErrorResponse(msrest.serialization.Model): """Error response. @@ -367,6 +590,25 @@ def __init__( self.error = kwargs.get('error', None) +class ErrorResponseAutoGenerated2(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated2 + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinitionAutoGenerated2'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponseAutoGenerated2, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + class ExpressionEvaluationDetails(msrest.serialization.Model): """Evaluation details of policy language expressions. @@ -381,9 +623,9 @@ class ExpressionEvaluationDetails(msrest.serialization.Model): :param path: Property path if the expression is a field or an alias. :type path: str :param expression_value: Value of the expression. - :type expression_value: object + :type expression_value: any :param target_value: Target value to be compared with the expression value. - :type target_value: object + :type target_value: any :param operator: Operator to compare the expression value and the target value. :type operator: str """ @@ -812,7 +1054,7 @@ class PolicyEvent(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param odata_id: OData entity ID; always set to null since policy event records do not have an entity ID. :type odata_id: str @@ -1044,7 +1286,7 @@ class PolicyMetadata(msrest.serialization.Model): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any :ivar description: The description of the policy metadata. :vartype description: str :ivar requirements: The requirements of the policy metadata. @@ -1143,7 +1385,7 @@ class PolicyMetadataSlimProperties(msrest.serialization.Model): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any """ _validation = { @@ -1193,7 +1435,7 @@ class PolicyMetadataProperties(PolicyMetadataSlimProperties): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any :ivar description: The description of the policy metadata. :vartype description: str :ivar requirements: The requirements of the policy metadata. @@ -1279,7 +1521,7 @@ class PolicyState(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param odata_id: OData entity ID; always set to null since policy state records do not have an entity ID. :type odata_id: str @@ -1943,7 +2185,7 @@ class SlimPolicyMetadata(msrest.serialization.Model): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any """ _validation = { @@ -2099,6 +2341,47 @@ def __init__( self.policy_group_details = kwargs.get('policy_group_details', None) +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.policyinsights.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.policyinsights.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + class TrackedResourceModificationDetails(msrest.serialization.Model): """The details of the policy triggered deployment that created or modified the tracked resource. @@ -2143,7 +2426,7 @@ class TypedErrorInfo(msrest.serialization.Model): :ivar type: The type of included error details. :vartype type: str :ivar info: The scenario specific error details. - :vartype info: object + :vartype info: any """ _validation = { 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 e2f211c86063..4d05c6b521cc 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 @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -15,6 +15,195 @@ from ._policy_insights_client_enums import * +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Attestation(Resource): + """An attestation resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.policyinsights.models.SystemData + :param policy_assignment_id: Required. The resource ID of the policy assignment that the + attestation is setting the state for. + :type policy_assignment_id: str + :param policy_definition_reference_id: The policy definition reference ID from a policy set + definition that the attestation is setting the state for. If the policy assignment assigns a + policy set definition the attestation can choose a definition within the set definition with + this property or omit this and set the state for the entire set definition. + :type policy_definition_reference_id: str + :param compliance_state: The compliance state that should be set on the resource. Possible + values include: "Compliant", "NonCompliant", "Unknown". + :type compliance_state: str or ~azure.mgmt.policyinsights.models.ComplianceState + :param expires_on: The time the compliance state should expire. + :type expires_on: ~datetime.datetime + :param owner: The person responsible for setting the state of the resource. This value is + typically an Azure Active Directory object ID. + :type owner: str + :param comments: Comments describing why this attestation was created. + :type comments: str + :param evidence: The evidence supporting the compliance state set in this attestation. + :type evidence: list[~azure.mgmt.policyinsights.models.AttestationEvidence] + :ivar provisioning_state: The status of the attestation. + :vartype provisioning_state: str + :ivar last_compliance_state_change_at: The time the compliance state was last changed in this + attestation. + :vartype last_compliance_state_change_at: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'policy_assignment_id': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'last_compliance_state_change_at': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'policy_assignment_id': {'key': 'properties.policyAssignmentId', 'type': 'str'}, + 'policy_definition_reference_id': {'key': 'properties.policyDefinitionReferenceId', 'type': 'str'}, + 'compliance_state': {'key': 'properties.complianceState', 'type': 'str'}, + 'expires_on': {'key': 'properties.expiresOn', 'type': 'iso-8601'}, + 'owner': {'key': 'properties.owner', 'type': 'str'}, + 'comments': {'key': 'properties.comments', 'type': 'str'}, + 'evidence': {'key': 'properties.evidence', 'type': '[AttestationEvidence]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'last_compliance_state_change_at': {'key': 'properties.lastComplianceStateChangeAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + policy_assignment_id: str, + policy_definition_reference_id: Optional[str] = None, + compliance_state: Optional[Union[str, "ComplianceState"]] = None, + expires_on: Optional[datetime.datetime] = None, + owner: Optional[str] = None, + comments: Optional[str] = None, + evidence: Optional[List["AttestationEvidence"]] = None, + **kwargs + ): + super(Attestation, self).__init__(**kwargs) + self.system_data = None + self.policy_assignment_id = policy_assignment_id + self.policy_definition_reference_id = policy_definition_reference_id + self.compliance_state = compliance_state + self.expires_on = expires_on + self.owner = owner + self.comments = comments + self.evidence = evidence + self.provisioning_state = None + self.last_compliance_state_change_at = None + + +class AttestationEvidence(msrest.serialization.Model): + """A piece of evidence supporting the compliance state set in the attestation. + + :param description: The description for this piece of evidence. + :type description: str + :param source_uri: The URI location of the evidence. + :type source_uri: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'source_uri': {'key': 'sourceUri', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + source_uri: Optional[str] = None, + **kwargs + ): + super(AttestationEvidence, self).__init__(**kwargs) + self.description = description + self.source_uri = source_uri + + +class AttestationListResult(msrest.serialization.Model): + """List of attestations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Array of attestation definitions. + :vartype value: list[~azure.mgmt.policyinsights.models.Attestation] + :ivar next_link: The URL to get the next set of results. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Attestation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AttestationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + class CheckRestrictionsRequest(msrest.serialization.Model): """The check policy restrictions parameters describing the resource that is being evaluated. @@ -55,7 +244,7 @@ class CheckRestrictionsResourceDetails(msrest.serialization.Model): :param resource_content: Required. The resource content. This should include whatever properties are already known and can be a partial set of all resource properties. - :type resource_content: object + :type resource_content: any :param api_version: The api-version of the resource content. :type api_version: str :param scope: The scope where the resource is being created. For example, if the resource is a @@ -76,7 +265,7 @@ class CheckRestrictionsResourceDetails(msrest.serialization.Model): def __init__( self, *, - resource_content: object, + resource_content: Any, api_version: Optional[str] = None, scope: Optional[str] = None, **kwargs @@ -172,7 +361,7 @@ class ComponentEventDetails(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Component Id. :type id: str :param type: Component type. @@ -204,7 +393,7 @@ class ComponentEventDetails(msrest.serialization.Model): def __init__( self, *, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, id: Optional[str] = None, type: Optional[str] = None, name: Optional[str] = None, @@ -230,7 +419,7 @@ class ComponentStateDetails(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param id: Component Id. :type id: str :param type: Component type. @@ -255,7 +444,7 @@ class ComponentStateDetails(msrest.serialization.Model): def __init__( self, *, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, id: Optional[str] = None, type: Optional[str] = None, name: Optional[str] = None, @@ -362,6 +551,51 @@ def __init__( self.additional_info = None +class ErrorDefinitionAutoGenerated2(msrest.serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar target: The target of the error. + :vartype target: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated2] + :ivar additional_info: Additional scenario specific error details. + :vartype additional_info: list[~azure.mgmt.policyinsights.models.TypedErrorInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinitionAutoGenerated2]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[TypedErrorInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDefinitionAutoGenerated2, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + class ErrorResponse(msrest.serialization.Model): """Error response. @@ -404,6 +638,27 @@ def __init__( self.error = error +class ErrorResponseAutoGenerated2(msrest.serialization.Model): + """Error response. + + :param error: The error details. + :type error: ~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated2 + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinitionAutoGenerated2'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinitionAutoGenerated2"] = None, + **kwargs + ): + super(ErrorResponseAutoGenerated2, self).__init__(**kwargs) + self.error = error + + class ExpressionEvaluationDetails(msrest.serialization.Model): """Evaluation details of policy language expressions. @@ -418,9 +673,9 @@ class ExpressionEvaluationDetails(msrest.serialization.Model): :param path: Property path if the expression is a field or an alias. :type path: str :param expression_value: Value of the expression. - :type expression_value: object + :type expression_value: any :param target_value: Target value to be compared with the expression value. - :type target_value: object + :type target_value: any :param operator: Operator to compare the expression value and the target value. :type operator: str """ @@ -445,8 +700,8 @@ def __init__( result: Optional[str] = None, expression: Optional[str] = None, path: Optional[str] = None, - expression_value: Optional[object] = None, - target_value: Optional[object] = None, + expression_value: Optional[Any] = None, + target_value: Optional[Any] = None, operator: Optional[str] = None, **kwargs ): @@ -890,7 +1145,7 @@ class PolicyEvent(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param odata_id: OData entity ID; always set to null since policy event records do not have an entity ID. :type odata_id: str @@ -1005,7 +1260,7 @@ class PolicyEvent(msrest.serialization.Model): def __init__( self, *, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, odata_id: Optional[str] = None, odata_context: Optional[str] = None, timestamp: Optional[datetime.datetime] = None, @@ -1163,7 +1418,7 @@ class PolicyMetadata(msrest.serialization.Model): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any :ivar description: The description of the policy metadata. :vartype description: str :ivar requirements: The requirements of the policy metadata. @@ -1262,7 +1517,7 @@ class PolicyMetadataSlimProperties(msrest.serialization.Model): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any """ _validation = { @@ -1312,7 +1567,7 @@ class PolicyMetadataProperties(PolicyMetadataSlimProperties): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any :ivar description: The description of the policy metadata. :vartype description: str :ivar requirements: The requirements of the policy metadata. @@ -1398,7 +1653,7 @@ class PolicyState(msrest.serialization.Model): :param additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, object] + :type additional_properties: dict[str, any] :param odata_id: OData entity ID; always set to null since policy state records do not have an entity ID. :type odata_id: str @@ -1528,7 +1783,7 @@ class PolicyState(msrest.serialization.Model): def __init__( self, *, - additional_properties: Optional[Dict[str, object]] = None, + additional_properties: Optional[Dict[str, Any]] = None, odata_id: Optional[str] = None, odata_context: Optional[str] = None, timestamp: Optional[datetime.datetime] = None, @@ -2119,7 +2374,7 @@ class SlimPolicyMetadata(msrest.serialization.Model): :ivar additional_content_url: Url for getting additional content about the resource metadata. :vartype additional_content_url: str :ivar metadata: Additional metadata. - :vartype metadata: object + :vartype metadata: any """ _validation = { @@ -2291,6 +2546,54 @@ def __init__( self.policy_group_details = policy_group_details +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.policyinsights.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.policyinsights.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TrackedResourceModificationDetails(msrest.serialization.Model): """The details of the policy triggered deployment that created or modified the tracked resource. @@ -2335,7 +2638,7 @@ class TypedErrorInfo(msrest.serialization.Model): :ivar type: The type of included error details. :vartype type: str :ivar info: The scenario specific error details. - :vartype info: object + :vartype info: any """ _validation = { diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py index e713fd7f9e3c..ada9f0a6b76a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/models/_policy_insights_client_enums.py @@ -26,13 +26,36 @@ def __getattr__(cls, name): raise AttributeError(name) +class ComplianceState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The compliance state that should be set on the resource. + """ + + #: The resource is in compliance with the policy. + COMPLIANT = "Compliant" + #: The resource is not in compliance with the policy. + NON_COMPLIANT = "NonCompliant" + #: The compliance state of the resource is not known. + UNKNOWN = "Unknown" + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + class FieldRestrictionResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """The type of restriction that is imposed on the field. """ - REQUIRED = "Required" #: The field and/or values are required by policy. - REMOVED = "Removed" #: The field will be removed by policy. - DENY = "Deny" #: The field and/or values will be denied by policy. + #: The field and/or values are required by policy. + REQUIRED = "Required" + #: The field will be removed by policy. + REMOVED = "Removed" + #: The field and/or values will be denied by policy. + DENY = "Deny" class PolicyStatesResource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): @@ -44,5 +67,8 @@ class ResourceDiscoveryMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) specified. """ - EXISTING_NON_COMPLIANT = "ExistingNonCompliant" #: Remediate resources that are already known to be non-compliant. - RE_EVALUATE_COMPLIANCE = "ReEvaluateCompliance" #: Re-evaluate the compliance state of resources and then remediate the resources found to be non-compliant. + #: Remediate resources that are already known to be non-compliant. + EXISTING_NON_COMPLIANT = "ExistingNonCompliant" + #: Re-evaluate the compliance state of resources and then remediate the resources found to be + #: non-compliant. + RE_EVALUATE_COMPLIANCE = "ReEvaluateCompliance" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py index 4bbdef723768..91acca23d156 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/__init__.py @@ -13,6 +13,7 @@ from ._operations import Operations from ._policy_metadata_operations import PolicyMetadataOperations from ._policy_restrictions_operations import PolicyRestrictionsOperations +from ._attestations_operations import AttestationsOperations __all__ = [ 'PolicyTrackedResourcesOperations', @@ -22,4 +23,5 @@ 'Operations', 'PolicyMetadataOperations', 'PolicyRestrictionsOperations', + 'AttestationsOperations', ] diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_attestations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_attestations_operations.py new file mode 100644 index 000000000000..f4644b6556b8 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_attestations_operations.py @@ -0,0 +1,1023 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AttestationsOperations(object): + """AttestationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.policyinsights.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_for_subscription( + self, + query_options=None, # type: Optional["_models.QueryOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AttestationListResult"] + """Gets all attestations for the subscription. + + :param query_options: Parameter group. + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AttestationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.AttestationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttestationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _top = None + _filter = None + if query_options is not None: + _top = query_options.top + _filter = query_options.filter + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_for_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if _top is not None: + query_parameters['$top'] = self._serialize.query("top", _top, 'int', minimum=0) + if _filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", _filter, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AttestationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations'} # type: ignore + + def _create_or_update_at_subscription_initial( + self, + attestation_name, # type: str + parameters, # type: "_models.Attestation" + **kwargs # type: Any + ): + # type: (...) -> "_models.Attestation" + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_subscription_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Attestation') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Attestation', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_subscription_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def begin_create_or_update_at_subscription( + self, + attestation_name, # type: str + parameters, # type: "_models.Attestation" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Attestation"] + """Creates or updates an attestation at subscription scope. + + :param attestation_name: The name of the attestation. + :type attestation_name: str + :param parameters: The attestation parameters. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Attestation or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_subscription_initial( + attestation_name=attestation_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def get_at_subscription( + self, + attestation_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Attestation" + """Gets an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Attestation, or the result of cls(response) + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def delete_at_subscription( + self, + attestation_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes an existing attestation at subscription scope. + + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_subscription.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def list_for_resource_group( + self, + resource_group_name, # type: str + query_options=None, # type: Optional["_models.QueryOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AttestationListResult"] + """Gets all attestations for the resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param query_options: Parameter group. + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AttestationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.AttestationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttestationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _top = None + _filter = None + if query_options is not None: + _top = query_options.top + _filter = query_options.filter + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_for_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + if _top is not None: + query_parameters['$top'] = self._serialize.query("top", _top, 'int', minimum=0) + if _filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", _filter, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AttestationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations'} # type: ignore + + def _create_or_update_at_resource_group_initial( + self, + resource_group_name, # type: str + attestation_name, # type: str + parameters, # type: "_models.Attestation" + **kwargs # type: Any + ): + # type: (...) -> "_models.Attestation" + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_resource_group_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Attestation') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Attestation', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_resource_group_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def begin_create_or_update_at_resource_group( + self, + resource_group_name, # type: str + attestation_name, # type: str + parameters, # type: "_models.Attestation" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Attestation"] + """Creates or updates an attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :param parameters: The attestation parameters. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Attestation or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_resource_group_initial( + resource_group_name=resource_group_name, + attestation_name=attestation_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def get_at_resource_group( + self, + resource_group_name, # type: str + attestation_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Attestation" + """Gets an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Attestation, or the result of cls(response) + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def delete_at_resource_group( + self, + resource_group_name, # type: str + attestation_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes an existing attestation at resource group scope. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def list_for_resource( + self, + resource_id, # type: str + query_options=None, # type: Optional["_models.QueryOptions"] + **kwargs # type: Any + ): + # type: (...) -> Iterable["_models.AttestationListResult"] + """Gets all attestations for a resource. + + :param resource_id: Resource ID. + :type resource_id: str + :param query_options: Parameter group. + :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AttestationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.AttestationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AttestationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + _top = None + _filter = None + if query_options is not None: + _top = query_options.top + _filter = query_options.filter + api_version = "2021-01-01" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_for_resource.metadata['url'] # type: ignore + path_format_arguments = { + '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 = {} # type: Dict[str, Any] + if _top is not None: + query_parameters['$top'] = self._serialize.query("top", _top, 'int', minimum=0) + if _filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", _filter, 'str') + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('AttestationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_for_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations'} # type: ignore + + def _create_or_update_at_resource_initial( + self, + resource_id, # type: str + attestation_name, # type: str + parameters, # type: "_models.Attestation" + **kwargs # type: Any + ): + # type: (...) -> "_models.Attestation" + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_at_resource_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Attestation') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Attestation', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_at_resource_initial.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def begin_create_or_update_at_resource( + self, + resource_id, # type: str + attestation_name, # type: str + parameters, # type: "_models.Attestation" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["_models.Attestation"] + """Creates or updates an attestation at resource scope. + + :param resource_id: Resource ID. + :type resource_id: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :param parameters: The attestation parameters. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either Attestation or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.policyinsights.models.Attestation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_at_resource_initial( + resource_id=resource_id, + attestation_name=attestation_name, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_at_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def get_at_resource( + self, + resource_id, # type: str + attestation_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.Attestation" + """Gets an existing attestation at resource scope. + + :param resource_id: Resource ID. + :type resource_id: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Attestation, or the result of cls(response) + :rtype: ~azure.mgmt.policyinsights.models.Attestation + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.Attestation"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.get_at_resource.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Attestation', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_at_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore + + def delete_at_resource( + self, + resource_id, # type: str + attestation_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes an existing attestation at individual resource scope. + + :param resource_id: Resource ID. + :type resource_id: str + :param attestation_name: The name of the attestation. + :type attestation_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-01-01" + accept = "application/json" + + # Construct URL + url = self.delete_at_resource.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceId': self._serialize.url("resource_id", resource_id, 'str', skip_quote=True), + 'attestationName': self._serialize.url("attestation_name", attestation_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_at_resource.metadata = {'url': '/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}'} # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py index 20eb9c00c20a..1a9cecc21a3c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py @@ -81,7 +81,7 @@ def list( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('OperationsListResults', pipeline_response) 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 f0b43e3d10c5..3a31b9099118 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 @@ -128,9 +128,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -147,7 +156,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -238,9 +247,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -257,7 +275,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -352,9 +370,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -371,7 +398,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -466,9 +493,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -485,7 +521,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -582,9 +618,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -601,7 +646,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -698,9 +743,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -717,7 +771,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -814,9 +868,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -833,7 +896,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -934,9 +997,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -953,7 +1025,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py index 5ce62077e9c8..de341b26ca16 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_metadata_operations.py @@ -89,7 +89,7 @@ def get_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PolicyMetadata', pipeline_response) @@ -162,7 +162,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py index 784ec4685d81..fc1b7cfaf4cf 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_restrictions_operations.py @@ -93,7 +93,7 @@ def check_at_subscription_scope( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckRestrictionsResult', pipeline_response) @@ -136,7 +136,7 @@ def check_at_resource_group_scope( url = self.check_at_resource_group_scope.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), } url = self._client.format_url(url, **path_format_arguments) @@ -158,7 +158,7 @@ def check_at_resource_group_scope( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CheckRestrictionsResult', pipeline_response) 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 e97d5023ade9..31ce121ac6b2 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 @@ -134,9 +134,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -153,7 +162,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -233,7 +242,7 @@ def summarize_for_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -328,9 +337,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -347,7 +365,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -425,7 +443,7 @@ def summarize_for_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -524,9 +542,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -543,7 +570,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -625,7 +652,7 @@ def summarize_for_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -724,9 +751,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -743,7 +779,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -821,7 +857,7 @@ def summarize_for_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -867,7 +903,7 @@ def _trigger_subscription_evaluation_initial( if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -887,8 +923,8 @@ def begin_trigger_subscription_evaluation( :type subscription_id: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) @@ -971,7 +1007,7 @@ def _trigger_resource_group_evaluation_initial( if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -994,8 +1030,8 @@ def begin_trigger_resource_group_evaluation( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: True for ARMPolling, False for no polling, or a - polling object for personal polling strategy + :keyword polling: By default, your polling method will be ARMPolling. + Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) @@ -1133,9 +1169,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -1152,7 +1197,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1236,7 +1281,7 @@ def summarize_for_policy_set_definition( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -1337,9 +1382,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -1356,7 +1410,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1440,7 +1494,7 @@ def summarize_for_policy_definition( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -1541,9 +1595,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -1560,7 +1623,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1644,7 +1707,7 @@ def summarize_for_subscription_level_policy_assignment( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) @@ -1749,9 +1812,18 @@ def prepare_request(next_link=None): request = self._client.post(url, query_parameters, header_parameters) else: - url = next_link + url = '{nextLink}' + path_format_arguments = { + 'nextLink': self._serialize.url("next_link", next_link, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if _skip_token is not None: + query_parameters['$skiptoken'] = self._serialize.query("skip_token", _skip_token, 'str') + + request = self._client.post(url, query_parameters, header_parameters) return request def extract_data(pipeline_response): @@ -1768,7 +1840,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1856,7 +1928,7 @@ def summarize_for_resource_group_level_policy_assignment( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SummarizeResults', pipeline_response) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py index 041bc997e6e0..d11fa8ce319c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_policy_tracked_resources_operations.py @@ -122,7 +122,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -205,7 +205,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -292,7 +292,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -378,7 +378,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.QueryFailure, response) + error = self._deserialize.failsafe_deserialize(_models.QueryFailure, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py index c0ed1d389296..676ce826e123 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_remediations_operations.py @@ -120,7 +120,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -181,7 +181,7 @@ def cancel_at_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -267,7 +267,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -336,7 +336,7 @@ def create_or_update_at_management_group( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -401,7 +401,7 @@ def get_at_management_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -462,7 +462,7 @@ def delete_at_management_group( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -545,7 +545,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -601,7 +601,7 @@ def cancel_at_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -682,7 +682,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -746,7 +746,7 @@ def create_or_update_at_subscription( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -806,7 +806,7 @@ def get_at_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -862,7 +862,7 @@ def delete_at_subscription( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -949,7 +949,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1009,7 +1009,7 @@ def cancel_at_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1094,7 +1094,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1162,7 +1162,7 @@ def create_or_update_at_resource_group( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -1226,7 +1226,7 @@ def get_at_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1286,7 +1286,7 @@ def delete_at_resource_group( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -1372,7 +1372,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1431,7 +1431,7 @@ def cancel_at_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1515,7 +1515,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -1582,7 +1582,7 @@ def create_or_update_at_resource( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -1645,7 +1645,7 @@ def get_at_resource( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Remediation', pipeline_response) @@ -1704,7 +1704,7 @@ def delete_at_resource( if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/setup.py b/sdk/policyinsights/azure-mgmt-policyinsights/setup.py index 24d521916935..ca0495be95c0 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/setup.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/setup.py @@ -78,7 +78,7 @@ 'azure.mgmt', ]), install_requires=[ - 'msrest>=0.5.0', + 'msrest>=0.6.21', 'azure-common~=1.1', 'azure-mgmt-core>=1.2.0,<2.0.0', ], diff --git a/shared_requirements.txt b/shared_requirements.txt index 567336dd2afc..d100dfb35818 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -330,6 +330,7 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-mgmt-guestconfig msrest>=0.6.21 #override azure-mgmt-recoveryservices msrest>=0.6.21 #override azure-mgmt-avs msrest>=0.6.21 +#override azure-mgmt-policyinsights msrest>=0.6.21 #override azure-mgmt-purview msrest>=0.6.21 #override azure-mgmt-datafactory msrest>=0.6.21 #override azure-mgmt-containerinstance msrest>=0.6.21