diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md index 3c6b7c6040ad..89d50114e3ab 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md +++ b/sdk/policyinsights/azure-mgmt-policyinsights/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 1.1.0b5 (2025-07-21) + +### Features Added + + - Model `CheckRestrictionsRequest` added property `include_audit_effect` + - Model `FieldRestriction` added property `policy_effect` + - Model `FieldRestriction` added property `reason` + - Enum `FieldRestrictionResult` added member `AUDIT` + - Model `PolicyEvaluationResult` added property `effect_details` + - Model `RemediationFilters` added property `resource_ids` + - Added model `CheckRestrictionEvaluationDetails` + - Added model `PolicyEffectDetails` + ## 1.1.0b4 (2022-12-29) ### Features Added diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in b/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in index c663bd7fa2de..18dbe2ffa8e0 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in +++ b/sdk/policyinsights/azure-mgmt-policyinsights/MANIFEST.in @@ -1,4 +1,3 @@ -include _meta.json recursive-include tests *.py *.json recursive-include samples *.py *.md include *.md diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/README.md b/sdk/policyinsights/azure-mgmt-policyinsights/README.md index 917e6a709c5e..8ba2cf139715 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/README.md +++ b/sdk/policyinsights/azure-mgmt-policyinsights/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Policy Insights Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.9+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.9+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -24,7 +24,7 @@ pip install azure-identity ### Authentication -By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. @@ -45,7 +45,9 @@ client = PolicyInsightsClient(credential=DefaultAzureCredential(), subscription_ ## Examples -Code samples for this package can be found at [Policy Insights](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com and [Samples Repo](https://github.com/Azure-Samples/azure-samples-python-management/tree/main/samples/policyinsights) +Code samples for this package can be found at: +- [Search Policy Insights](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) ## Troubleshooting @@ -57,6 +59,3 @@ Code samples for this package can be found at [Policy Insights](https://docs.mic If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - - diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json b/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json deleted file mode 100644 index 0839a738a4e9..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "f38115ac455af89493b0a0719d9a987404560dda", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", - "use": [ - "@autorest/python@6.2.7", - "@autorest/modelerfour@4.24.3" - ], - "autorest_command": "autorest specification/policyinsights/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", - "readme": "specification/policyinsights/resource-manager/readme.md" -} \ No newline at end of file diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json b/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json new file mode 100644 index 000000000000..931fbe436c0b --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/_metadata.json @@ -0,0 +1,11 @@ +{ + "commit": "6c548b0bd279f5e233661b1c81fb5b61b19965cd", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.10.2", + "use": [ + "@autorest/python@6.35.0", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/policyinsights/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.35.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "readme": "specification/policyinsights/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py index 021c2d54c34e..8461746b6906 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/__init__.py @@ -5,15 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._policy_insights_client import PolicyInsightsClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._policy_insights_client import PolicyInsightsClient # type: ignore from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -21,6 +27,6 @@ __all__ = [ "PolicyInsightsClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py index e4f19bd2600a..641d213da409 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for PolicyInsightsClient. Note that all parameters used to create this instance are saved as instance @@ -32,7 +30,6 @@ class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-m """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(PolicyInsightsClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -42,6 +39,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-policyinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -50,9 +48,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( 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 70b828c54000..e3939b49adb6 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 @@ -7,14 +7,19 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, TYPE_CHECKING +from typing import Any, Optional, TYPE_CHECKING, cast +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse +from azure.core.settings import settings from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from . import models as _models from ._configuration import PolicyInsightsClientConfiguration -from ._serialization import Deserializer, Serializer +from ._utils.serialization import Deserializer, Serializer from .operations import ( AttestationsOperations, ComponentPolicyStatesOperations, @@ -28,7 +33,6 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -59,23 +63,43 @@ class PolicyInsightsClient: # pylint: disable=client-accepts-api-version-keywor :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Microsoft Azure subscription ID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = PolicyInsightsClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -97,7 +121,7 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.attestations = AttestationsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -117,14 +141,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "PolicyInsightsClient": + def __enter__(self) -> Self: self._client.__enter__() return self - def __exit__(self, *exc_details) -> None: + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py new file mode 100644 index 000000000000..0af9b28f6607 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_serialization.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py similarity index 77% rename from sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_serialization.py rename to sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py index 2c170e28dbca..f5187701d7be 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_serialization.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_utils/serialization.py @@ -1,30 +1,12 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines +# coding=utf-8 # -------------------------------------------------------------------------- -# # Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# +# 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. # -------------------------------------------------------------------------- -# pylint: skip-file # pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode @@ -38,7 +20,19 @@ import re import sys import codecs -from typing import Optional, Union, AnyStr, IO, Mapping +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + MutableMapping, + List, +) try: from urllib import quote # type: ignore @@ -47,13 +41,15 @@ import xml.etree.ElementTree as ET import isodate # type: ignore +from typing_extensions import Self -from typing import Dict, Any, cast - -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") +JSON = MutableMapping[str, Any] + class RawDeserializer: @@ -74,6 +70,8 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: :param data: Input, could be bytes or stream (will be decoded with UTF8) or text :type data: str or bytes or IO :param str content_type: The content type. + :return: The deserialized data. + :rtype: object """ if hasattr(data, "read"): # Assume a stream @@ -95,7 +93,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: try: return json.loads(data_as_str) except ValueError as err: - raise DeserializationError("JSON is invalid: {}".format(err), err) + raise DeserializationError("JSON is invalid: {}".format(err), err) from err elif "xml" in (content_type or []): try: @@ -107,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -126,7 +124,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -136,6 +136,11 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" + + :param bytes body_bytes: The body of the response. + :param dict headers: The headers of the response. + :returns: The deserialized data. + :rtype: object """ # Try to use content-type from headers if available content_type = None @@ -153,13 +158,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -167,80 +165,31 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0.""" - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation.""" - return "Z" - - def dst(self, dt): - """No daylight saving for UTC.""" - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset): - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[Dict[str, Any]] = {} + for k in kwargs: # pylint: disable=consider-using-dict-items if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) elif k in self._validation and self._validation[k].get("readonly", False): @@ -287,25 +243,35 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): - """Compare objects by comparing all attributes.""" + def __eq__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are equal + :rtype: bool + """ if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): - """Compare objects by comparing all attributes.""" + def __ne__(self, other: Any) -> bool: + """Compare objects by comparing all attributes. + + :param object other: The object to compare + :returns: True if objects are not equal + :rtype: bool + """ return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: cls._xml_map # type: ignore except AttributeError: @@ -314,7 +280,11 @@ def is_xml_model(cls): @classmethod def _create_xml_node(cls): - """Create XML node.""" + """Create XML node. + + :returns: The XML node + :rtype: xml.etree.ElementTree.Element + """ try: xml_map = cls._xml_map # type: ignore except AttributeError: @@ -322,8 +292,8 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - def serialize(self, keep_readonly=False, **kwargs): - """Return the JSON that would be sent to azure from this model. + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -334,10 +304,17 @@ def serialize(self, keep_readonly=False, **kwargs): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, keep_readonly=keep_readonly, **kwargs + ) - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -363,12 +340,15 @@ def my_key_transformer(key, attr_desc, value): If you want XML serialization, you can pass the kwargs is_xml=True. + :param bool keep_readonly: If you want to serialize the readonly attributes :param function key_transformer: A key transformer function. :returns: A dict JSON compatible object :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize( # type: ignore # pylint: disable=protected-access + self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs + ) @classmethod def _infer_class_models(cls): @@ -378,25 +358,31 @@ def _infer_class_models(cls): client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: raise ValueError("Not Autorest generated code") - except Exception: + except Exception: # pylint: disable=broad-exception-caught # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. client_models = {cls.__name__: cls} return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls, data: Any, content_type: Optional[str] = None) -> Self: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls, + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> Self: """Parse a dict using given key extractor return a model. By default consider key @@ -404,13 +390,15 @@ def from_dict(cls, data, key_extractors=None, content_type=None): and last_rest_key_case_insensitive_extractor) :param dict data: A dict using RestAPI structure + :param function key_extractors: A key extractor function. :param str content_type: JSON by default, set application/xml if XML. :returns: An instance of this model - :raises: DeserializationError if something went wrong + :raises DeserializationError: if something went wrong + :rtype: Self """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -418,7 +406,7 @@ def from_dict(cls, data, key_extractors=None, content_type=None): if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -426,21 +414,25 @@ def _flatten_subtype(cls, key, objects): return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): - result.update(objects[valuetype]._flatten_subtype(key, objects)) + result.update(objects[valuetype]._flatten_subtype(key, objects)) # pylint: disable=protected-access return result @classmethod def _classify(cls, response, objects): """Check the class _subtype_map for any child classes. We want to ignore any inherited _subtype_maps. - Remove the polymorphic key from the initial data. + + :param dict response: The initial data + :param dict objects: The class objects + :returns: The class to be used + :rtype: class """ for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] - subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + subtype_value = response.get(rest_api_response_key, None) or response.get(subtype_key, None) else: subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: @@ -479,11 +471,13 @@ def _decode_attribute_map_key(key): inside the received data. :param str key: A key string from the generated code + :returns: The decoded key + :rtype: str """ return key.replace("\\.", ".") -class Serializer(object): +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -518,7 +512,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -534,17 +528,20 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True - def _serialize(self, target_obj, data_type=None, **kwargs): + def _serialize( # pylint: disable=too-many-nested-blocks, too-many-branches, too-many-statements, too-many-locals + self, target_obj, data_type=None, **kwargs + ): """Serialize data into a string according to type. - :param target_obj: The data to be serialized. + :param object target_obj: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str, dict - :raises: SerializationError if serialization fails. + :raises SerializationError: if serialization fails. + :returns: The serialized data. """ key_transformer = kwargs.get("key_transformer", self.key_transformer) keep_readonly = kwargs.get("keep_readonly", False) @@ -570,12 +567,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): serialized = {} if is_xml_model_serialization: - serialized = target_obj._create_xml_node() + serialized = target_obj._create_xml_node() # pylint: disable=protected-access try: - attributes = target_obj._attribute_map + attributes = target_obj._attribute_map # pylint: disable=protected-access for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + if not keep_readonly and target_obj._validation.get( # pylint: disable=protected-access + attr_name, {} + ).get("readonly", False): continue if attr_name == "additional_properties" and attr_desc["key"] == "": @@ -602,7 +601,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): @@ -611,7 +610,8 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if isinstance(new_attr, list): serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): - # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + # If the down XML has no XML/Name, + # we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") if len(splitted_tag) == 2: # Namespace @@ -622,12 +622,11 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore - unflattened = {k: new_attr} - new_attr = unflattened + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized @@ -636,28 +635,29 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _serialized.update(_new_attr) # type: ignore _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) - else: - return serialized + raise SerializationError(msg) from err + return serialized def body(self, data, data_type, **kwargs): """Serialize data intended for a request body. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: dict - :raises: SerializationError if serialization fails. - :raises: ValueError if data is None + :raises SerializationError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized request body """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -681,20 +681,22 @@ def body(self, data, data_type, **kwargs): attribute_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, ] - data = deserializer._deserialize(data_type, data) + data = deserializer._deserialize(data_type, data) # pylint: disable=protected-access except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) def url(self, name, data, data_type, **kwargs): """Serialize data intended for a URL path. - :param data: The data to be serialized. + :param str name: The name of the URL path parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :returns: The serialized URL path + :raises TypeError: if serialization fails. + :raises ValueError: if data is None """ try: output = self.serialize_data(data, data_type, **kwargs) @@ -703,30 +705,30 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return output + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return output def query(self, name, data, data_type, **kwargs): """Serialize data intended for a URL query. - :param data: The data to be serialized. + :param str name: The name of the query parameter. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :rtype: str, list + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized query parameter """ try: # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -736,19 +738,20 @@ def query(self, name, data, data_type, **kwargs): output = str(output) else: output = quote(str(output), safe="") - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def header(self, name, data, data_type, **kwargs): """Serialize data intended for a request header. - :param data: The data to be serialized. + :param str name: The name of the header. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. :rtype: str - :raises: TypeError if serialization fails. - :raises: ValueError if data is None + :raises TypeError: if serialization fails. + :raises ValueError: if data is None + :returns: The serialized header """ try: if data_type in ["[str]"]: @@ -757,30 +760,31 @@ def header(self, name, data, data_type, **kwargs): output = self.serialize_data(data, data_type, **kwargs) if data_type == "bool": output = json.dumps(output) - except SerializationError: - raise TypeError("{} must be type {}.".format(name, data_type)) - else: - return str(output) + except SerializationError as exc: + raise TypeError("{} must be type {}.".format(name, data_type)) from exc + return str(output) def serialize_data(self, data, data_type, **kwargs): """Serialize generic data according to supplied data type. - :param data: The data to be serialized. + :param object data: The data to be serialized. :param str data_type: The type to be serialized from. - :param bool required: Whether it's essential that the data not be - empty or None - :raises: AttributeError if required data is None. - :raises: ValueError if data is None - :raises: SerializationError if serialization fails. + :raises AttributeError: if required data is None. + :raises ValueError: if data is None + :raises SerializationError: if serialization fails. + :returns: The serialized data. + :rtype: str, int, float, bool, dict, list """ if data is None: raise ValueError("No value for given attribute") try: + if data is CoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) - elif data_type in self.serialize_type: + if data_type in self.serialize_type: return self.serialize_type[data_type](data, **kwargs) # If dependencies is empty, try with current data class @@ -795,12 +799,11 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) - else: - return self._serialize(data, **kwargs) + raise SerializationError(msg.format(data, data_type)) from err + return self._serialize(data, **kwargs) @classmethod - def _get_custom_serializers(cls, data_type, **kwargs): + def _get_custom_serializers(cls, data_type, **kwargs): # pylint: disable=inconsistent-return-statements custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) if custom_serializer: return custom_serializer @@ -816,23 +819,26 @@ def serialize_basic(cls, data, data_type, **kwargs): - basic_types_serializers dict[str, callable] : If set, use the callable as serializer - is_xml bool : If set, use xml_basic_types_serializers - :param data: Object to be serialized. + :param obj data: Object to be serialized. :param str data_type: Type of object in the iterable. + :rtype: str, int, float, bool + :return: serialized object """ custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) if data_type == "str": return cls.serialize_unicode(data) - return eval(data_type)(data) # nosec + return eval(data_type)(data) # nosec # pylint: disable=eval-used @classmethod def serialize_unicode(cls, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. - :param data: Object to be serialized. + :param str data: Object to be serialized. :rtype: str + :return: serialized object """ try: # If I received an enum, return its value return data.value @@ -846,8 +852,7 @@ def serialize_unicode(cls, data): return data except NameError: return str(data) - else: - return str(data) + return str(data) def serialize_iter(self, data, iter_type, div=None, **kwargs): """Serialize iterable. @@ -857,13 +862,13 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialization_ctxt['type'] should be same as data_type. - is_xml bool : If set, serialize as XML - :param list attr: Object to be serialized. + :param list data: Object to be serialized. :param str iter_type: Type of object in the iterable. - :param bool required: Whether the objects in the iterable must - not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + Defaults to False. :rtype: list, str + :return: serialized iterable """ if isinstance(data, str): raise SerializationError("Refuse str type as a valid iter type.") @@ -875,9 +880,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -913,16 +923,17 @@ def serialize_dict(self, attr, dict_type, **kwargs): :param dict attr: Object to be serialized. :param str dict_type: Type of object in the dictionary. - :param bool required: Whether the objects in the dictionary must - not be None or empty. :rtype: dict + :return: serialized dictionary """ serialization_ctxt = kwargs.get("serialization_ctxt", {}) serialized = {} for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -937,7 +948,7 @@ def serialize_dict(self, attr, dict_type, **kwargs): return serialized - def serialize_object(self, attr, **kwargs): + def serialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Serialize a generic object. This will be handled as a dictionary. If object passed in is not a basic type (str, int, float, dict, list) it will simply be @@ -945,6 +956,7 @@ def serialize_object(self, attr, **kwargs): :param dict attr: Object to be serialized. :rtype: dict or str + :return: serialized object """ if attr is None: return None @@ -955,7 +967,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -969,7 +981,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_decimal(attr) # If it's a model or I know this dependency, serialize as a Model - elif obj_type in self.dependencies.values() or isinstance(attr, Model): + if obj_type in self.dependencies.values() or isinstance(attr, Model): return self._serialize(attr) if obj_type == dict: @@ -1000,56 +1012,61 @@ def serialize_enum(attr, enum_obj=None): try: enum_obj(result) # type: ignore return result - except ValueError: + except ValueError as exc: for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" - raise SerializationError(error.format(attr, enum_obj)) + raise SerializationError(error.format(attr, enum_obj)) from exc @staticmethod - def serialize_bytearray(attr, **kwargs): + def serialize_bytearray(attr, **kwargs): # pylint: disable=unused-argument """Serialize bytearray into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ return b64encode(attr).decode() @staticmethod - def serialize_base64(attr, **kwargs): + def serialize_base64(attr, **kwargs): # pylint: disable=unused-argument """Serialize str into base-64 string. - :param attr: Object to be serialized. + :param str attr: Object to be serialized. :rtype: str + :return: serialized base64 """ encoded = b64encode(attr).decode("ascii") return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod - def serialize_decimal(attr, **kwargs): + def serialize_decimal(attr, **kwargs): # pylint: disable=unused-argument """Serialize Decimal object to float. - :param attr: Object to be serialized. + :param decimal attr: Object to be serialized. :rtype: float + :return: serialized decimal """ return float(attr) @staticmethod - def serialize_long(attr, **kwargs): + def serialize_long(attr, **kwargs): # pylint: disable=unused-argument """Serialize long (Py2) or int (Py3). - :param attr: Object to be serialized. + :param int attr: Object to be serialized. :rtype: int/long + :return: serialized long """ return _long_type(attr) @staticmethod - def serialize_date(attr, **kwargs): + def serialize_date(attr, **kwargs): # pylint: disable=unused-argument """Serialize Date object into ISO-8601 formatted string. :param Date attr: Object to be serialized. :rtype: str + :return: serialized date """ if isinstance(attr, str): attr = isodate.parse_date(attr) @@ -1057,11 +1074,12 @@ def serialize_date(attr, **kwargs): return t @staticmethod - def serialize_time(attr, **kwargs): + def serialize_time(attr, **kwargs): # pylint: disable=unused-argument """Serialize Time object into ISO-8601 formatted string. :param datetime.time attr: Object to be serialized. :rtype: str + :return: serialized time """ if isinstance(attr, str): attr = isodate.parse_time(attr) @@ -1071,30 +1089,32 @@ def serialize_time(attr, **kwargs): return t @staticmethod - def serialize_duration(attr, **kwargs): + def serialize_duration(attr, **kwargs): # pylint: disable=unused-argument """Serialize TimeDelta object into ISO-8601 formatted string. :param TimeDelta attr: Object to be serialized. :rtype: str + :return: serialized duration """ if isinstance(attr, str): attr = isodate.parse_duration(attr) return isodate.duration_isoformat(attr) @staticmethod - def serialize_rfc(attr, **kwargs): + def serialize_rfc(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into RFC-1123 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: TypeError if format invalid. + :raises TypeError: if format invalid. + :return: serialized rfc """ try: if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() - except AttributeError: - raise TypeError("RFC1123 object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("RFC1123 object must be valid Datetime object.") from exc return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( Serializer.days[utc.tm_wday], @@ -1107,12 +1127,13 @@ def serialize_rfc(attr, **kwargs): ) @staticmethod - def serialize_iso(attr, **kwargs): + def serialize_iso(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into ISO-8601 formatted string. :param Datetime attr: Object to be serialized. :rtype: str - :raises: SerializationError if format invalid. + :raises SerializationError: if format invalid. + :return: serialized iso """ if isinstance(attr, str): attr = isodate.parse_datetime(attr) @@ -1132,19 +1153,20 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod - def serialize_unix(attr, **kwargs): + def serialize_unix(attr, **kwargs): # pylint: disable=unused-argument """Serialize Datetime object into IntTime format. This is represented as seconds. :param Datetime attr: Object to be serialized. :rtype: int - :raises: SerializationError if format invalid + :raises SerializationError: if format invalid + :return: serialied unix """ if isinstance(attr, int): return attr @@ -1152,16 +1174,17 @@ def serialize_unix(attr, **kwargs): if not attr.tzinfo: _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) - except AttributeError: - raise TypeError("Unix time object must be valid Datetime object.") + except AttributeError as exc: + raise TypeError("Unix time object must be valid Datetime object.") from exc -def rest_key_extractor(attr, attr_desc, data): +def rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument key = attr_desc["key"] working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1170,14 +1193,15 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) return working_data.get(key) -def rest_key_case_insensitive_extractor(attr, attr_desc, data): +def rest_key_case_insensitive_extractor( # pylint: disable=unused-argument, inconsistent-return-statements + attr, attr_desc, data +): key = attr_desc["key"] working_data = data @@ -1191,7 +1215,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1199,17 +1222,29 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): return attribute_key_case_insensitive_extractor(key, None, working_data) -def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key.""" +def last_rest_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument + """Extract the attribute in "data" based on the last part of the JSON path key. + + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute + """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) -def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): # pylint: disable=unused-argument """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" + :param str attr: The attribute to extract + :param dict attr_desc: The attribute description + :param dict data: The data to extract from + :rtype: object + :returns: The extracted attribute """ key = attr_desc["key"] dict_keys = _FLATTEN.split(key) @@ -1242,11 +1277,11 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name -def xml_key_extractor(attr, attr_desc, data): +def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument,too-many-return-statements if isinstance(data, dict): return None @@ -1266,7 +1301,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1298,22 +1333,21 @@ def xml_key_extractor(attr, attr_desc, data): if is_iter_type: if is_wrapped: return None # is_wrapped no node, we want None - else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) - if len(children) != 1: - raise DeserializationError( - "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( - xml_name - ) + # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name ) - return list(children[0]) # Might be empty list and that's ok. + ) + return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty if len(children) > 1: @@ -1321,7 +1355,7 @@ def xml_key_extractor(attr, attr_desc, data): return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1330,9 +1364,9 @@ class Deserializer(object): basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None) -> None: self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1352,7 +1386,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1368,27 +1402,29 @@ def __call__(self, target_obj, response_data, content_type=None): :param str target_obj: Target data type to deserialize to. :param requests.Response response_data: REST response object. :param str content_type: Swagger "produces" if available. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ data = self._unpack_content(response_data, content_type) return self._deserialize(target_obj, data) - def _deserialize(self, target_obj, data): + def _deserialize(self, target_obj, data): # pylint: disable=inconsistent-return-statements """Call the deserializer on a model. Data needs to be already deserialized as JSON or XML ElementTree :param str target_obj: Target data type to deserialize to. :param object data: Object to deserialize. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: - for attr, mapconfig in data._attribute_map.items(): + for attr, mapconfig in data._attribute_map.items(): # pylint: disable=protected-access if attr in constants: continue value = getattr(data, attr) @@ -1405,15 +1441,15 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) - elif isinstance(response, type) and issubclass(response, Enum): + if isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: - attributes = response._attribute_map # type: ignore + attributes = response._attribute_map # type: ignore # pylint: disable=protected-access d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1442,10 +1478,9 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) - else: - additional_properties = self._build_additional_properties(attributes, data) - return self._instantiate_model(response, d_attrs, additional_properties) + raise DeserializationError(msg) from err + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: @@ -1471,22 +1506,24 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. + :return: The classified target object and its class name. + :rtype: tuple """ if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore # pylint: disable=protected-access except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1496,12 +1533,14 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. + :return: Deserialized object. + :rtype: object """ try: return self(target_obj, data, content_type=content_type) - except: + except: # pylint: disable=bare-except _LOGGER.debug( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1519,10 +1558,12 @@ def _unpack_content(raw_data, content_type=None): If raw_data is something else, bypass all logic and return it directly. - :param raw_data: Data to be processed. - :param content_type: How to parse if raw_data is a string/bytes. + :param obj raw_data: Data to be processed. + :param str content_type: How to parse if raw_data is a string/bytes. :raises JSONDecodeError: If JSON is requested and parsing is impossible. :raises UnicodeDecodeError: If bytes is not UTF8 + :rtype: object + :return: Unpacked content. """ # Assume this is enough to detect a Pipeline Response without importing it context = getattr(raw_data, "context", {}) @@ -1539,31 +1580,42 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): """Instantiate a response model passing in deserialized args. - :param response: The response model class. - :param d_attrs: The deserialized response attributes. + :param Response response: The response model class. + :param dict attrs: The deserialized response attributes. + :param dict additional_properties: Additional properties to be set. + :rtype: Response + :return: The instantiated response model. """ if callable(response): subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() if v.get("readonly")] - const = [k for k, v in response._validation.items() if v.get("constant")] + readonly = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") + ] + const = [ + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("constant") + ] kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) if additional_properties: - response_obj.additional_properties = additional_properties + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore - raise DeserializationError(msg + str(err)) + raise DeserializationError(msg + str(err)) from err else: try: for attr, value in attrs.items(): @@ -1572,15 +1624,16 @@ def _instantiate_model(self, response, attrs, additional_properties=None): except Exception as exp: msg = "Unable to populate response model. " msg += "Type: {}, Error: {}".format(type(response), exp) - raise DeserializationError(msg) + raise DeserializationError(msg) from exp - def deserialize_data(self, data, data_type): + def deserialize_data(self, data, data_type): # pylint: disable=too-many-return-statements """Process data for deserialization according to data type. :param str data: The response string to be deserialized. :param str data_type: The type to deserialize to. - :raises: DeserializationError if deserialization fails. + :raises DeserializationError: if deserialization fails. :return: Deserialized object. + :rtype: object """ if data is None: return data @@ -1594,7 +1647,11 @@ def deserialize_data(self, data, data_type): if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): return data - is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + is_a_text_parsing_type = lambda x: x not in [ # pylint: disable=unnecessary-lambda-assignment + "object", + "[]", + r"{}", + ] if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: return None data_val = self.deserialize_type[data_type](data) @@ -1613,15 +1670,15 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) - else: - return self._deserialize(obj_type, data) + raise DeserializationError(msg) from err + return self._deserialize(obj_type, data) def deserialize_iter(self, attr, iter_type): """Deserialize an iterable. :param list attr: Iterable to be deserialized. :param str iter_type: The type of object in the iterable. + :return: Deserialized iterable. :rtype: list """ if attr is None: @@ -1638,6 +1695,7 @@ def deserialize_dict(self, attr, dict_type): :param dict/list attr: Dictionary to be deserialized. Also accepts a list of key, value pairs. :param str dict_type: The object type of the items in the dictionary. + :return: Deserialized dictionary. :rtype: dict """ if isinstance(attr, list): @@ -1648,20 +1706,21 @@ def deserialize_dict(self, attr, dict_type): attr = {el.tag: el.text for el in attr} return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} - def deserialize_object(self, attr, **kwargs): + def deserialize_object(self, attr, **kwargs): # pylint: disable=too-many-return-statements """Deserialize a generic object. This will be handled as a dictionary. :param dict attr: Dictionary to be deserialized. + :return: Deserialized object. :rtype: dict - :raises: TypeError if non-builtin datatype encountered. + :raises TypeError: if non-builtin datatype encountered. """ if attr is None: return None if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1687,11 +1746,10 @@ def deserialize_object(self, attr, **kwargs): pass return deserialized - else: - error = "Cannot deserialize generic object with type: " - raise TypeError(error + str(obj_type)) + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) - def deserialize_basic(self, attr, data_type): + def deserialize_basic(self, attr, data_type): # pylint: disable=too-many-return-statements """Deserialize basic builtin data type from string. Will attempt to convert to str, int, float and bool. This function will also accept '1', '0', 'true' and 'false' as @@ -1699,8 +1757,9 @@ def deserialize_basic(self, attr, data_type): :param str attr: response string to be deserialized. :param str data_type: deserialization data type. + :return: Deserialized basic type. :rtype: str, int, float or bool - :raises: TypeError if string format is not valid. + :raises TypeError: if string format is not valid. """ # If we're here, data is supposed to be a basic type. # If it's still an XML node, take the text @@ -1710,24 +1769,23 @@ def deserialize_basic(self, attr, data_type): if data_type == "str": # None or '', node is empty string. return "" - else: - # None or '', node with a strong type is None. - # Don't try to model "empty bool" or "empty int" - return None + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + if isinstance(attr, str): if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ["false", "0"]: + if attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) if data_type == "str": return self.deserialize_unicode(attr) - return eval(data_type)(attr) # nosec + return eval(data_type)(attr) # nosec # pylint: disable=eval-used @staticmethod def deserialize_unicode(data): @@ -1735,6 +1793,7 @@ def deserialize_unicode(data): as a string. :param str data: response string to be deserialized. + :return: Deserialized string. :rtype: str or unicode """ # We might be here because we have an enum modeled as string, @@ -1748,8 +1807,7 @@ def deserialize_unicode(data): return data except NameError: return str(data) - else: - return str(data) + return str(data) @staticmethod def deserialize_enum(data, enum_obj): @@ -1761,6 +1819,7 @@ def deserialize_enum(data, enum_obj): :param str data: Response string to be deserialized. If this value is None or invalid it will be returned as-is. :param Enum enum_obj: Enum object to deserialize to. + :return: Deserialized enum object. :rtype: Enum """ if isinstance(data, enum_obj) or data is None: @@ -1769,12 +1828,11 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] - except IndexError: + except IndexError as exc: error = "{!r} is not a valid index for enum {!r}" - raise DeserializationError(error.format(data, enum_obj)) + raise DeserializationError(error.format(data, enum_obj)) from exc try: return enum_obj(str(data)) except ValueError: @@ -1790,8 +1848,9 @@ def deserialize_bytearray(attr): """Deserialize string into bytearray. :param str attr: response string to be deserialized. + :return: Deserialized bytearray :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1802,8 +1861,9 @@ def deserialize_base64(attr): """Deserialize base64 encoded string into string. :param str attr: response string to be deserialized. + :return: Deserialized base64 string :rtype: bytearray - :raises: TypeError if string format invalid. + :raises TypeError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1817,24 +1877,26 @@ def deserialize_decimal(attr): """Deserialize string into Decimal object. :param str attr: response string to be deserialized. - :rtype: Decimal - :raises: DeserializationError if string format invalid. + :return: Deserialized decimal + :raises DeserializationError: if string format invalid. + :rtype: decimal """ if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): """Deserialize string into long (Py2) or int (Py3). :param str attr: response string to be deserialized. + :return: Deserialized int :rtype: long or int - :raises: ValueError if string format invalid. + :raises ValueError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1845,8 +1907,9 @@ def deserialize_duration(attr): """Deserialize ISO-8601 formatted string into TimeDelta object. :param str attr: response string to be deserialized. + :return: Deserialized duration :rtype: TimeDelta - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1854,32 +1917,33 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) - else: - return duration + raise DeserializationError(msg) from err + return duration @staticmethod def deserialize_date(attr): """Deserialize ISO-8601 formatted string into Date object. :param str attr: response string to be deserialized. + :return: Deserialized date :rtype: Date - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): """Deserialize ISO-8601 formatted string into time object. :param str attr: response string to be deserialized. + :return: Deserialized time :rtype: datetime.time - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1892,31 +1956,32 @@ def deserialize_rfc(attr): """Deserialize RFC-1123 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized RFC datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text try: parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + *parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_iso(attr): """Deserialize ISO-8601 formatted string into Datetime object. :param str attr: response string to be deserialized. + :return: Deserialized ISO datetime :rtype: Datetime - :raises: DeserializationError if string format invalid. + :raises DeserializationError: if string format invalid. """ if isinstance(attr, ET.Element): attr = attr.text @@ -1943,9 +2008,8 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj @staticmethod def deserialize_unix(attr): @@ -1953,15 +2017,16 @@ def deserialize_unix(attr): This is represented as seconds. :param int attr: Object to be serialized. + :return: Deserialized datetime :rtype: Datetime - :raises: DeserializationError if format invalid + :raises DeserializationError: if format invalid """ if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) - else: - return date_obj + raise DeserializationError(msg) from err + return date_obj diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_vendor.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_vendor.py deleted file mode 100644 index 9aad73fc743e..000000000000 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_vendor.py +++ /dev/null @@ -1,27 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) 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 a741dc7b69b5..44192a0f2b11 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.1.0b4" +VERSION = "1.1.0b5" diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py index 62e08f3a667e..78e779b05c32 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/__init__.py @@ -5,12 +5,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._policy_insights_client import PolicyInsightsClient +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._policy_insights_client import PolicyInsightsClient # type: ignore try: from ._patch import __all__ as _patch_all - from ._patch import * # pylint: disable=unused-wildcard-import + from ._patch import * except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk @@ -18,6 +24,6 @@ __all__ = [ "PolicyInsightsClient", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py index 68371755dd09..dc8dd2d6bff6 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_configuration.py @@ -8,18 +8,16 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-attributes """Configuration for PolicyInsightsClient. Note that all parameters used to create this instance are saved as instance @@ -32,7 +30,6 @@ class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-m """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(PolicyInsightsClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -42,6 +39,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-policyinsights/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -50,9 +48,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( 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 cbbc2695b40e..2653b2e84748 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 @@ -7,13 +7,18 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, TYPE_CHECKING +from typing import Any, Awaitable, Optional, TYPE_CHECKING, cast +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.settings import settings from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy +from azure.mgmt.core.tools import get_arm_endpoints from .. import models as _models -from .._serialization import Deserializer, Serializer +from .._utils.serialization import Deserializer, Serializer from ._configuration import PolicyInsightsClientConfiguration from .operations import ( AttestationsOperations, @@ -28,7 +33,6 @@ ) if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -60,23 +64,45 @@ class PolicyInsightsClient: # pylint: disable=client-accepts-api-version-keywor :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Microsoft Azure subscription ID. Required. :type subscription_id: str - :param base_url: Service URL. Default value is "https://management.azure.com". + :param base_url: Service URL. Default value is None. :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - base_url: str = "https://management.azure.com", - **kwargs: Any + self, credential: "AsyncTokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any ) -> None: + _cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore + _endpoints = get_arm_endpoints(_cloud) + if not base_url: + base_url = _endpoints["resource_manager"] + credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"]) self._config = PolicyInsightsClientConfiguration( - credential=credential, subscription_id=subscription_id, **kwargs + credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs + ) + + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient( + base_url=cast(str, base_url), policies=_policies, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -98,7 +124,9 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.attestations = AttestationsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -118,14 +146,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "PolicyInsightsClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) 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 0471b79db988..4ff80dcf0f86 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 @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._policy_tracked_resources_operations import PolicyTrackedResourcesOperations -from ._remediations_operations import RemediationsOperations -from ._policy_events_operations import PolicyEventsOperations -from ._policy_states_operations import PolicyStatesOperations -from ._policy_metadata_operations import PolicyMetadataOperations -from ._policy_restrictions_operations import PolicyRestrictionsOperations -from ._component_policy_states_operations import ComponentPolicyStatesOperations -from ._operations import Operations -from ._attestations_operations import AttestationsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._policy_tracked_resources_operations import PolicyTrackedResourcesOperations # type: ignore +from ._remediations_operations import RemediationsOperations # type: ignore +from ._policy_events_operations import PolicyEventsOperations # type: ignore +from ._policy_states_operations import PolicyStatesOperations # type: ignore +from ._policy_metadata_operations import PolicyMetadataOperations # type: ignore +from ._policy_restrictions_operations import PolicyRestrictionsOperations # type: ignore +from ._component_policy_states_operations import ComponentPolicyStatesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._attestations_operations import AttestationsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -31,5 +37,5 @@ "Operations", "AttestationsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 index 1e9c5d0d72b7..b2eb360fcad9 100644 --- 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 @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +32,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._attestations_operations import ( build_create_or_update_at_resource_group_request, build_create_or_update_at_resource_request, @@ -44,11 +47,8 @@ build_list_for_resource_request, build_list_for_subscription_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,20 +67,19 @@ class AttestationsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_subscription( self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Attestation"]: + ) -> AsyncItemPaged["_models.Attestation"]: """Gets all attestations for the subscription. :param query_options: Parameter group. Default value is None. :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 Attestation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -88,10 +87,10 @@ def list_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.AttestationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,24 +106,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AttestationListResult", pipeline_response) @@ -134,10 +130,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,14 +147,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations" - } - - async def _create_or_update_at_subscription_initial( - self, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any - ) -> _models.Attestation: - error_map = { + async def _create_or_update_at_subscription_initial( # pylint: disable=name-too-long + self, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,58 +161,54 @@ async def _create_or_update_at_subscription_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Attestation") - request = build_create_or_update_at_subscription_request( + _request = build_create_or_update_at_subscription_request( attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_at_subscription_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_at_subscription_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } - @overload async def begin_create_or_update_at_subscription( self, @@ -238,14 +227,6 @@ async def begin_create_or_update_at_subscription( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -254,25 +235,17 @@ async def begin_create_or_update_at_subscription( @overload async def begin_create_or_update_at_subscription( - self, attestation_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, attestation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.Attestation]: """Creates or updates an attestation at subscription scope. :param attestation_name: The name of the attestation. Required. :type attestation_name: str :param parameters: The attestation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -281,25 +254,15 @@ async def begin_create_or_update_at_subscription( @distributed_trace_async async def begin_create_or_update_at_subscription( - self, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any + self, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Attestation]: """Creates or updates an attestation at subscription scope. :param attestation_name: The name of the attestation. Required. :type attestation_name: str - :param parameters: The attestation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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: 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. + :param parameters: The attestation parameters. Is either a Attestation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO[bytes] :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] @@ -308,7 +271,7 @@ async def begin_create_or_update_at_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -325,12 +288,13 @@ async def begin_create_or_update_at_subscription( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -340,17 +304,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Attestation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return AsyncLROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.Attestation: @@ -358,12 +320,11 @@ async def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _mo :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,22 +335,21 @@ async def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) - request = build_get_at_subscription_request( + _request = build_get_at_subscription_request( attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -399,31 +359,24 @@ async def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_at_subscription( # pylint: disable=inconsistent-return-statements - self, attestation_name: str, **kwargs: Any - ) -> None: + 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. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +387,21 @@ async def delete_at_subscription( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_at_subscription_request( + _request = build_delete_at_subscription_request( attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -460,16 +412,12 @@ async def delete_at_subscription( # pylint: disable=inconsistent-return-stateme 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}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_resource_group( self, resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Attestation"]: + ) -> AsyncItemPaged["_models.Attestation"]: """Gets all attestations for the resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -477,7 +425,6 @@ def list_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 Attestation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -485,10 +432,10 @@ def list_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.AttestationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,25 +451,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AttestationListResult", pipeline_response) @@ -532,10 +476,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,14 +493,14 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations" - } - - async def _create_or_update_at_resource_group_initial( - self, resource_group_name: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any - ) -> _models.Attestation: - error_map = { + async def _create_or_update_at_resource_group_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,19 +511,19 @@ async def _create_or_update_at_resource_group_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Attestation") - request = build_create_or_update_at_resource_group_request( + _request = build_create_or_update_at_resource_group_request( resource_group_name=resource_group_name, attestation_name=attestation_name, subscription_id=self._config.subscription_id, @@ -586,39 +531,35 @@ async def _create_or_update_at_resource_group_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_at_resource_group_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_at_resource_group_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } - @overload async def begin_create_or_update_at_resource_group( self, @@ -641,14 +582,6 @@ async def begin_create_or_update_at_resource_group( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -660,7 +593,7 @@ async def begin_create_or_update_at_resource_group( self, resource_group_name: str, attestation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -673,18 +606,10 @@ async def begin_create_or_update_at_resource_group( :param attestation_name: The name of the attestation. Required. :type attestation_name: str :param parameters: The attestation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -693,7 +618,11 @@ async def begin_create_or_update_at_resource_group( @distributed_trace_async async def begin_create_or_update_at_resource_group( - self, resource_group_name: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.Attestation]: """Creates or updates an attestation at resource group scope. @@ -702,19 +631,9 @@ async def begin_create_or_update_at_resource_group( :type resource_group_name: str :param attestation_name: The name of the attestation. Required. :type attestation_name: str - :param parameters: The attestation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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: 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. + :param parameters: The attestation parameters. Is either a Attestation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO[bytes] :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] @@ -723,7 +642,7 @@ async def begin_create_or_update_at_resource_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -741,12 +660,13 @@ async def begin_create_or_update_at_resource_group( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -756,17 +676,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Attestation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return AsyncLROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get_at_resource_group( @@ -779,12 +697,11 @@ async def get_at_resource_group( :type resource_group_name: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,23 +712,22 @@ async def get_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) - request = build_get_at_resource_group_request( + _request = build_get_at_resource_group_request( resource_group_name=resource_group_name, attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -821,21 +737,15 @@ async def get_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_at_resource_group( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, attestation_name: str, **kwargs: Any - ) -> None: + 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. @@ -843,12 +753,11 @@ async def delete_at_resource_group( # pylint: disable=inconsistent-return-state :type resource_group_name: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -859,23 +768,22 @@ async def delete_at_resource_group( # pylint: disable=inconsistent-return-state _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_at_resource_group_request( + _request = build_delete_at_resource_group_request( resource_group_name=resource_group_name, attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -886,23 +794,18 @@ async def delete_at_resource_group( # pylint: disable=inconsistent-return-state 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}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_resource( self, resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Attestation"]: + ) -> AsyncItemPaged["_models.Attestation"]: """Gets all attestations for a resource. :param resource_id: Resource ID. Required. :type resource_id: str :param query_options: Parameter group. Default value is None. :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 Attestation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -910,10 +813,10 @@ def list_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.AttestationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -929,24 +832,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_id=resource_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("AttestationListResult", pipeline_response) @@ -956,10 +856,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -972,12 +873,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = {"url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations"} - async def _create_or_update_at_resource_initial( - self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any - ) -> _models.Attestation: - error_map = { + self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,58 +887,54 @@ async def _create_or_update_at_resource_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Attestation") - request = build_create_or_update_at_resource_request( + _request = build_create_or_update_at_resource_request( resource_id=resource_id, attestation_name=attestation_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_at_resource_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_at_resource_initial.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } - @overload async def begin_create_or_update_at_resource( self, @@ -1061,14 +956,6 @@ async def begin_create_or_update_at_resource( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -1080,7 +967,7 @@ async def begin_create_or_update_at_resource( self, resource_id: str, attestation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1092,18 +979,10 @@ async def begin_create_or_update_at_resource( :param attestation_name: The name of the attestation. Required. :type attestation_name: str :param parameters: The attestation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -1112,7 +991,7 @@ async def begin_create_or_update_at_resource( @distributed_trace_async async def begin_create_or_update_at_resource( - self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any + self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Attestation]: """Creates or updates an attestation at resource scope. @@ -1120,19 +999,9 @@ async def begin_create_or_update_at_resource( :type resource_id: str :param attestation_name: The name of the attestation. Required. :type attestation_name: str - :param parameters: The attestation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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: 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. + :param parameters: The attestation parameters. Is either a Attestation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO[bytes] :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] @@ -1141,7 +1010,7 @@ async def begin_create_or_update_at_resource( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -1159,12 +1028,13 @@ async def begin_create_or_update_at_resource( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1174,17 +1044,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Attestation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return AsyncLROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any) -> _models.Attestation: @@ -1194,12 +1062,11 @@ async def get_at_resource(self, resource_id: str, attestation_name: str, **kwarg :type resource_id: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1210,22 +1077,21 @@ async def get_at_resource(self, resource_id: str, attestation_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) - request = build_get_at_resource_request( + _request = build_get_at_resource_request( resource_id=resource_id, attestation_name=attestation_name, api_version=api_version, - template_url=self.get_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1235,33 +1101,26 @@ async def get_at_resource(self, resource_id: str, attestation_name: str, **kwarg error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return deserialized # type: ignore @distributed_trace_async - async def delete_at_resource( # pylint: disable=inconsistent-return-statements - self, resource_id: str, attestation_name: str, **kwargs: Any - ) -> None: + 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. Required. :type resource_id: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1272,22 +1131,21 @@ async def delete_at_resource( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_at_resource_request( + _request = build_delete_at_resource_request( resource_id=resource_id, attestation_name=attestation_name, api_version=api_version, - template_url=self.delete_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1298,8 +1156,4 @@ async def delete_at_resource( # pylint: disable=inconsistent-return-statements 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}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_component_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_component_policy_states_operations.py index 5fe586f6804f..fc8804e30563 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_component_policy_states_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_component_policy_states_operations.py @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime -import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,14 +19,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._component_policy_states_operations import ( build_list_query_results_for_policy_definition_request, build_list_query_results_for_resource_group_level_policy_assignment_request, @@ -35,11 +34,8 @@ build_list_query_results_for_subscription_level_policy_assignment_request, build_list_query_results_for_subscription_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -58,10 +54,10 @@ class ComponentPolicyStatesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list_query_results_for_subscription( @@ -105,12 +101,11 @@ async def list_query_results_for_subscription( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,10 +116,10 @@ async def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( subscription_id=subscription_id, component_policy_states_resource=component_policy_states_resource, top=top, @@ -135,15 +130,14 @@ async def list_query_results_for_subscription( filter=filter, apply=apply, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -153,16 +147,12 @@ async def list_query_results_for_subscription( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace_async async def list_query_results_for_resource_group( @@ -209,12 +199,11 @@ async def list_query_results_for_resource_group( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,10 +214,10 @@ async def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( subscription_id=subscription_id, resource_group_name=resource_group_name, component_policy_states_resource=component_policy_states_resource, @@ -240,15 +229,14 @@ async def list_query_results_for_resource_group( filter=filter, apply=apply, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -258,16 +246,12 @@ async def list_query_results_for_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace_async async def list_query_results_for_resource( @@ -314,12 +298,11 @@ async def list_query_results_for_resource( :type apply: str :param expand: The $expand query parameter. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,10 +313,10 @@ async def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( resource_id=resource_id, component_policy_states_resource=component_policy_states_resource, top=top, @@ -345,15 +328,14 @@ async def list_query_results_for_resource( apply=apply, expand=expand, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -363,16 +345,12 @@ async def list_query_results_for_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace_async async def list_query_results_for_policy_definition( @@ -419,16 +397,11 @@ async def list_query_results_for_policy_definition( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,10 +415,10 @@ async def list_query_results_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_policy_definition_request( + _request = build_list_query_results_for_policy_definition_request( subscription_id=subscription_id, policy_definition_name=policy_definition_name, component_policy_states_resource=component_policy_states_resource, @@ -458,15 +431,14 @@ async def list_query_results_for_policy_definition( apply=apply, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -476,19 +448,15 @@ async def list_query_results_for_policy_definition( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_query_results_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace_async - async def list_query_results_for_subscription_level_policy_assignment( + async def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, subscription_id: str, policy_assignment_name: str, @@ -532,16 +500,11 @@ async def list_query_results_for_subscription_level_policy_assignment( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,10 +518,10 @@ async def list_query_results_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_subscription_level_policy_assignment_request( + _request = build_list_query_results_for_subscription_level_policy_assignment_request( subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, component_policy_states_resource=component_policy_states_resource, @@ -571,15 +534,14 @@ async def list_query_results_for_subscription_level_policy_assignment( apply=apply, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -589,19 +551,15 @@ async def list_query_results_for_subscription_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace_async - async def list_query_results_for_resource_group_level_policy_assignment( + async def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, subscription_id: str, resource_group_name: str, @@ -648,16 +606,11 @@ async def list_query_results_for_resource_group_level_policy_assignment( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -671,10 +624,10 @@ async def list_query_results_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_resource_group_level_policy_assignment_request( + _request = build_list_query_results_for_resource_group_level_policy_assignment_request( subscription_id=subscription_id, resource_group_name=resource_group_name, policy_assignment_name=policy_assignment_name, @@ -688,15 +641,14 @@ async def list_query_results_for_resource_group_level_policy_assignment( apply=apply, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -706,13 +658,9 @@ async def list_query_results_for_resource_group_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # 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 d0b493314b59..d266dbe28254 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,20 +18,16 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import build_list_request +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -50,21 +46,20 @@ class Operations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list(self, **kwargs: Any) -> _models.OperationsListResults: """Lists available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationsListResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.OperationsListResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -75,20 +70,19 @@ async def list(self, **kwargs: Any) -> _models.OperationsListResults: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.OperationsListResults] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -98,11 +92,9 @@ async def list(self, **kwargs: Any) -> _models.OperationsListResults: error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationsListResults", pipeline_response) + deserialized = self._deserialize("OperationsListResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.PolicyInsights/operations"} + return deserialized # type: ignore 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 2ca681465d66..0b9d82b4e3db 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 @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,14 +20,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policy_events_operations import ( build_list_query_results_for_management_group_request, build_list_query_results_for_policy_definition_request, @@ -38,11 +38,8 @@ build_list_query_results_for_subscription_request, build_next_link_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,10 +58,10 @@ class PolicyEventsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_management_group( @@ -73,7 +70,7 @@ def list_query_results_for_management_group( management_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the resources under the management group. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -83,11 +80,6 @@ def list_query_results_for_management_group( :type management_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -98,10 +90,10 @@ def list_query_results_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +121,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_management_group_request( + _request = build_list_query_results_for_management_group_request( policy_events_resource=policy_events_resource, management_group_name=management_group_name, top=_top, @@ -142,12 +134,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_query_results_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -168,18 +158,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -189,10 +177,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -205,10 +194,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_subscription( self, @@ -216,7 +201,7 @@ def list_query_results_for_subscription( subscription_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the resources under the subscription. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -226,7 +211,6 @@ def list_query_results_for_subscription( :type subscription_id: str :param query_options: Parameter group. Default value is None. :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 PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -234,10 +218,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,7 +249,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, top=_top, @@ -277,12 +261,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -303,18 +285,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -324,10 +304,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -340,10 +321,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource_group( self, @@ -352,7 +329,7 @@ def list_query_results_for_resource_group( resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the resources under the resource group. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -364,7 +341,6 @@ def list_query_results_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -372,10 +348,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,7 +379,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -416,12 +392,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -442,18 +416,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -463,10 +435,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -479,10 +452,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource( self, @@ -490,7 +459,7 @@ def list_query_results_for_resource( resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the resource. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -500,7 +469,6 @@ def list_query_results_for_resource( :type resource_id: str :param query_options: Parameter group. Default value is None. :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 PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -508,10 +476,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +509,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( policy_events_resource=policy_events_resource, resource_id=resource_id, top=_top, @@ -554,12 +522,10 @@ def prepare_request(next_link=None): expand=_expand, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -582,18 +548,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -603,10 +567,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -619,19 +584,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace - def list_query_results_for_policy_set_definition( + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long self, policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_set_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the subscription level policy set definition. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -643,11 +604,6 @@ def list_query_results_for_policy_set_definition( :type policy_set_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -658,10 +614,10 @@ def list_query_results_for_policy_set_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,7 +645,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_set_definition_request( + _request = build_list_query_results_for_policy_set_definition_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, policy_set_definition_name=policy_set_definition_name, @@ -703,12 +659,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_set_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -729,18 +683,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -750,10 +702,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -766,10 +719,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_policy_set_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_policy_definition( self, @@ -778,7 +727,7 @@ def list_query_results_for_policy_definition( policy_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the subscription level policy definition. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -790,11 +739,6 @@ def list_query_results_for_policy_definition( :type policy_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -805,10 +749,10 @@ def list_query_results_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +780,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_definition_request( + _request = build_list_query_results_for_policy_definition_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, policy_definition_name=policy_definition_name, @@ -850,12 +794,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -876,18 +818,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -897,10 +837,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -913,19 +854,15 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the subscription level policy assignment. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -937,11 +874,6 @@ def list_query_results_for_subscription_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -952,10 +884,10 @@ def list_query_results_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -983,7 +915,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_level_policy_assignment_request( + _request = build_list_query_results_for_subscription_level_policy_assignment_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, @@ -997,12 +929,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1023,18 +953,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1044,10 +972,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1060,12 +989,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, @@ -1073,7 +998,7 @@ def list_query_results_for_resource_group_level_policy_assignment( policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyEvent"]: + ) -> AsyncItemPaged["_models.PolicyEvent"]: """Queries policy events for the resource group level policy assignment. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1087,11 +1012,6 @@ def list_query_results_for_resource_group_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1102,10 +1022,10 @@ def list_query_results_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1133,7 +1053,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_level_policy_assignment_request( + _request = build_list_query_results_for_resource_group_level_policy_assignment_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -1148,12 +1068,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1174,18 +1092,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1195,10 +1111,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1210,7 +1127,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_query_results_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } 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 7815466c8bd8..43f364a65639 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,21 +19,17 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policy_metadata_operations import build_get_resource_request, build_list_request +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,10 +48,10 @@ class PolicyMetadataOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetadata: @@ -63,12 +59,11 @@ async def get_resource(self, resource_name: str, **kwargs: Any) -> _models.Polic :param resource_name: The name of the policy metadata resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyMetadata or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.PolicyMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,21 +74,20 @@ async def get_resource(self, resource_name: str, **kwargs: Any) -> _models.Polic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyMetadata] = kwargs.pop("cls", None) - request = build_get_resource_request( + _request = build_get_resource_request( resource_name=resource_name, api_version=api_version, - template_url=self.get_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -103,24 +97,21 @@ async def get_resource(self, resource_name: str, **kwargs: Any) -> _models.Polic error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyMetadata", pipeline_response) + deserialized = self._deserialize("PolicyMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_resource.metadata = {"url": "/providers/Microsoft.PolicyInsights/policyMetadata/{resourceName}"} + return deserialized # type: ignore @distributed_trace def list( self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.SlimPolicyMetadata"]: + ) -> AsyncItemPaged["_models.SlimPolicyMetadata"]: """Get a list of the policy metadata resources. :param query_options: Parameter group. Default value is None. :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 SlimPolicyMetadata or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] @@ -129,10 +120,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyMetadataCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -146,22 +137,19 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_request( + _request = build_list_request( top=_top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyMetadataCollection", pipeline_response) @@ -171,10 +159,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -186,5 +175,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.PolicyInsights/policyMetadata"} 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 513f60ca926c..450b169a7645 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,24 +19,20 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policy_restrictions_operations import ( build_check_at_management_group_scope_request, build_check_at_resource_group_scope_request, build_check_at_subscription_scope_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,10 +51,10 @@ class PolicyRestrictionsOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload async def check_at_subscription_scope( @@ -70,7 +67,6 @@ async def check_at_subscription_scope( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -78,16 +74,15 @@ async def check_at_subscription_scope( @overload async def check_at_subscription_scope( - self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on a resource within a subscription. :param parameters: The check policy restrictions parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -95,22 +90,18 @@ async def check_at_subscription_scope( @distributed_trace_async async def check_at_subscription_scope( - self, parameters: Union[_models.CheckRestrictionsRequest, IO], **kwargs: Any + self, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on a resource within a subscription. - :param parameters: The check policy restrictions parameters. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The check policy restrictions parameters. Is either a + CheckRestrictionsRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,33 +112,32 @@ async def check_at_subscription_scope( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckRestrictionsRequest") - request = build_check_at_subscription_scope_request( + _request = build_check_at_subscription_scope_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_at_subscription_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,16 +147,12 @@ async def check_at_subscription_scope( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response) + deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_at_subscription_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - } + return deserialized # type: ignore @overload async def check_at_resource_group_scope( @@ -188,7 +174,6 @@ async def check_at_resource_group_scope( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -196,7 +181,7 @@ async def check_at_resource_group_scope( @overload async def check_at_resource_group_scope( - self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **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. @@ -205,11 +190,10 @@ async def check_at_resource_group_scope( Required. :type resource_group_name: str :param parameters: The check policy restrictions parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -217,7 +201,7 @@ async def check_at_resource_group_scope( @distributed_trace_async async def check_at_resource_group_scope( - self, resource_group_name: str, parameters: Union[_models.CheckRestrictionsRequest, IO], **kwargs: Any + self, resource_group_name: str, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **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. @@ -225,18 +209,14 @@ async def check_at_resource_group_scope( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param parameters: The check policy restrictions parameters. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The check policy restrictions parameters. Is either a + CheckRestrictionsRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,34 +227,33 @@ async def check_at_resource_group_scope( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckRestrictionsRequest") - request = build_check_at_resource_group_scope_request( + _request = build_check_at_resource_group_scope_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_at_resource_group_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,16 +263,12 @@ async def check_at_resource_group_scope( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response) + deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_at_resource_group_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - } + return deserialized # type: ignore @overload async def check_at_management_group_scope( @@ -313,11 +288,6 @@ async def check_at_management_group_scope( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -325,22 +295,17 @@ async def check_at_management_group_scope( @overload async def check_at_management_group_scope( - self, management_group_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, management_group_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on resources within a management group. :param management_group_id: Management group ID. Required. :type management_group_id: str :param parameters: The check policy restrictions parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -350,30 +315,22 @@ async def check_at_management_group_scope( async def check_at_management_group_scope( self, management_group_id: str, - parameters: Union[_models.CheckManagementGroupRestrictionsRequest, IO], + parameters: Union[_models.CheckManagementGroupRestrictionsRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on resources within a management group. :param management_group_id: Management group ID. Required. :type management_group_id: str - :param parameters: The check policy restrictions parameters. Is either a model type or a IO - type. Required. + :param parameters: The check policy restrictions parameters. Is either a + CheckManagementGroupRestrictionsRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest or - IO - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,34 +344,33 @@ async def check_at_management_group_scope( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckManagementGroupRestrictionsRequest") - request = build_check_at_management_group_scope_request( + _request = build_check_at_management_group_scope_request( management_group_id=management_group_id, management_groups_namespace=management_groups_namespace, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_at_management_group_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -424,13 +380,9 @@ async def check_at_management_group_scope( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response) + deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_at_management_group_scope.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - } + return deserialized # type: ignore 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 4bcf5cfe0b96..f4a9aaa3856e 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 @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from collections.abc import MutableMapping +from typing import Any, AsyncIterator, Callable, Dict, Literal, Optional, TypeVar, Union, cast +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +17,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -29,7 +31,7 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policy_states_operations import ( build_list_query_results_for_management_group_request, build_list_query_results_for_policy_definition_request, @@ -51,11 +53,8 @@ build_trigger_resource_group_evaluation_request, build_trigger_subscription_evaluation_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,10 +73,10 @@ class PolicyStatesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_management_group( @@ -86,7 +85,7 @@ def list_query_results_for_management_group( management_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the resources under the management group. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -97,11 +96,6 @@ def list_query_results_for_management_group( :type management_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -112,10 +106,10 @@ def list_query_results_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -143,7 +137,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_management_group_request( + _request = build_list_query_results_for_management_group_request( policy_states_resource=policy_states_resource, management_group_name=management_group_name, top=_top, @@ -156,12 +150,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_query_results_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -182,18 +174,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -203,10 +193,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -219,10 +210,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async async def summarize_for_management_group( self, @@ -242,16 +229,11 @@ async def summarize_for_management_group( :type management_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,7 +247,7 @@ async def summarize_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -278,7 +260,7 @@ async def summarize_for_management_group( _to = query_options.to _top = query_options.top - request = build_summarize_for_management_group_request( + _request = build_summarize_for_management_group_request( policy_states_summary_resource=policy_states_summary_resource, management_group_name=management_group_name, top=_top, @@ -287,15 +269,14 @@ async def summarize_for_management_group( filter=_filter, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.summarize_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -305,16 +286,12 @@ async def summarize_for_management_group( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_subscription( @@ -323,7 +300,7 @@ def list_query_results_for_subscription( subscription_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the resources under the subscription. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -334,7 +311,6 @@ def list_query_results_for_subscription( :type subscription_id: str :param query_options: Parameter group. Default value is None. :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 PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -342,10 +318,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,7 +349,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, top=_top, @@ -385,12 +361,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -411,18 +385,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -432,10 +404,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -448,10 +421,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async async def summarize_for_subscription( self, @@ -471,12 +440,11 @@ async def summarize_for_subscription( :type subscription_id: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -487,7 +455,7 @@ async def summarize_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -500,7 +468,7 @@ async def summarize_for_subscription( _to = query_options.to _top = query_options.top - request = build_summarize_for_subscription_request( + _request = build_summarize_for_subscription_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, top=_top, @@ -508,15 +476,14 @@ async def summarize_for_subscription( to=_to, filter=_filter, api_version=api_version, - template_url=self.summarize_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -526,16 +493,12 @@ async def summarize_for_subscription( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - summarize_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_resource_group( @@ -545,7 +508,7 @@ def list_query_results_for_resource_group( resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the resources under the resource group. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -558,7 +521,6 @@ def list_query_results_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -566,10 +528,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -597,7 +559,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -610,12 +572,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -636,18 +596,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -657,10 +615,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -673,10 +632,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async async def summarize_for_resource_group( self, @@ -699,12 +654,11 @@ async def summarize_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +669,7 @@ async def summarize_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -728,7 +682,7 @@ async def summarize_for_resource_group( _to = query_options.to _top = query_options.top - request = build_summarize_for_resource_group_request( + _request = build_summarize_for_resource_group_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -737,15 +691,14 @@ async def summarize_for_resource_group( to=_to, filter=_filter, api_version=api_version, - template_url=self.summarize_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -755,16 +708,12 @@ async def summarize_for_resource_group( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_resource( @@ -773,7 +722,7 @@ def list_query_results_for_resource( resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the resource. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -784,7 +733,6 @@ def list_query_results_for_resource( :type resource_id: str :param query_options: Parameter group. Default value is None. :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 PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -792,10 +740,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -825,7 +773,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( policy_states_resource=policy_states_resource, resource_id=resource_id, top=_top, @@ -838,12 +786,10 @@ def prepare_request(next_link=None): expand=_expand, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -866,18 +812,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -887,10 +831,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -903,10 +848,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async async def summarize_for_resource( self, @@ -926,12 +867,11 @@ async def summarize_for_resource( :type resource_id: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -942,7 +882,7 @@ async def summarize_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -955,7 +895,7 @@ async def summarize_for_resource( _to = query_options.to _top = query_options.top - request = build_summarize_for_resource_request( + _request = build_summarize_for_resource_request( policy_states_summary_resource=policy_states_summary_resource, resource_id=resource_id, top=_top, @@ -963,15 +903,14 @@ async def summarize_for_resource( to=_to, filter=_filter, api_version=api_version, - template_url=self.summarize_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -981,21 +920,17 @@ async def summarize_for_resource( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore - async def _trigger_subscription_evaluation_initial( # pylint: disable=inconsistent-return-statements + async def _trigger_subscription_evaluation_initial( self, subscription_id: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1006,36 +941,40 @@ async def _trigger_subscription_evaluation_initial( # pylint: disable=inconsist _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_trigger_subscription_evaluation_request( + _request = build_trigger_subscription_evaluation_request( subscription_id=subscription_id, api_version=api_version, - template_url=self._trigger_subscription_evaluation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _trigger_subscription_evaluation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return deserialized # type: ignore @distributed_trace_async async def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1043,14 +982,6 @@ async def begin_trigger_subscription_evaluation(self, subscription_id: str, **kw :param subscription_id: Microsoft Azure subscription ID. Required. :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: 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) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1058,13 +989,13 @@ async def begin_trigger_subscription_evaluation(self, subscription_id: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._trigger_subscription_evaluation_initial( # type: ignore + raw_result = await self._trigger_subscription_evaluation_initial( subscription_id=subscription_id, api_version=api_version, cls=lambda x, y, z: x, @@ -1072,11 +1003,12 @@ async def begin_trigger_subscription_evaluation(self, subscription_id: str, **kw params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1087,22 +1019,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_trigger_subscription_evaluation.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - async def _trigger_resource_group_evaluation_initial( # pylint: disable=inconsistent-return-statements + async def _trigger_resource_group_evaluation_initial( # pylint: disable=name-too-long self, subscription_id: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1113,37 +1041,41 @@ async def _trigger_resource_group_evaluation_initial( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_trigger_resource_group_evaluation_request( + _request = build_trigger_resource_group_evaluation_request( subscription_id=subscription_id, resource_group_name=resource_group_name, api_version=api_version, - template_url=self._trigger_resource_group_evaluation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _trigger_resource_group_evaluation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return deserialized # type: ignore @distributed_trace_async async def begin_trigger_resource_group_evaluation( @@ -1155,14 +1087,6 @@ async def begin_trigger_resource_group_evaluation( :type subscription_id: str :param resource_group_name: Resource group name. Required. :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: 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) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1170,13 +1094,13 @@ async def begin_trigger_resource_group_evaluation( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._trigger_resource_group_evaluation_initial( # type: ignore + raw_result = await self._trigger_resource_group_evaluation_initial( subscription_id=subscription_id, resource_group_name=resource_group_name, api_version=api_version, @@ -1185,11 +1109,12 @@ async def begin_trigger_resource_group_evaluation( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1200,27 +1125,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_trigger_resource_group_evaluation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_query_results_for_policy_set_definition( + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long self, policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_set_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the subscription level policy set definition. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1233,11 +1154,6 @@ def list_query_results_for_policy_set_definition( :type policy_set_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1248,10 +1164,10 @@ def list_query_results_for_policy_set_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1279,7 +1195,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_set_definition_request( + _request = build_list_query_results_for_policy_set_definition_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, policy_set_definition_name=policy_set_definition_name, @@ -1293,12 +1209,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_set_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1319,18 +1233,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -1340,10 +1252,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1356,10 +1269,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_policy_set_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async async def summarize_for_policy_set_definition( self, @@ -1382,16 +1291,11 @@ async def summarize_for_policy_set_definition( :type policy_set_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1405,7 +1309,7 @@ async def summarize_for_policy_set_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -1418,7 +1322,7 @@ async def summarize_for_policy_set_definition( _to = query_options.to _top = query_options.top - request = build_summarize_for_policy_set_definition_request( + _request = build_summarize_for_policy_set_definition_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, policy_set_definition_name=policy_set_definition_name, @@ -1428,15 +1332,14 @@ async def summarize_for_policy_set_definition( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_policy_set_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1446,16 +1349,12 @@ async def summarize_for_policy_set_definition( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_policy_set_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_policy_definition( @@ -1465,7 +1364,7 @@ def list_query_results_for_policy_definition( policy_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the subscription level policy definition. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1478,11 +1377,6 @@ def list_query_results_for_policy_definition( :type policy_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1493,10 +1387,10 @@ def list_query_results_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1524,7 +1418,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_definition_request( + _request = build_list_query_results_for_policy_definition_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, policy_definition_name=policy_definition_name, @@ -1538,12 +1432,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1564,18 +1456,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -1585,10 +1475,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1601,10 +1492,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async async def summarize_for_policy_definition( self, @@ -1627,16 +1514,11 @@ async def summarize_for_policy_definition( :type policy_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1650,7 +1532,7 @@ async def summarize_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -1663,7 +1545,7 @@ async def summarize_for_policy_definition( _to = query_options.to _top = query_options.top - request = build_summarize_for_policy_definition_request( + _request = build_summarize_for_policy_definition_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, policy_definition_name=policy_definition_name, @@ -1673,15 +1555,14 @@ async def summarize_for_policy_definition( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1691,26 +1572,22 @@ async def summarize_for_policy_definition( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - summarize_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the subscription level policy assignment. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1723,11 +1600,6 @@ def list_query_results_for_subscription_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1738,10 +1610,10 @@ def list_query_results_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1769,7 +1641,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_level_policy_assignment_request( + _request = build_list_query_results_for_subscription_level_policy_assignment_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, @@ -1783,12 +1655,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1809,18 +1679,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -1830,10 +1698,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1846,12 +1715,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async - async def summarize_for_subscription_level_policy_assignment( + async def summarize_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, @@ -1872,16 +1737,11 @@ async def summarize_for_subscription_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1895,7 +1755,7 @@ async def summarize_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -1908,7 +1768,7 @@ async def summarize_for_subscription_level_policy_assignment( _to = query_options.to _top = query_options.top - request = build_summarize_for_subscription_level_policy_assignment_request( + _request = build_summarize_for_subscription_level_policy_assignment_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, @@ -1918,15 +1778,14 @@ async def summarize_for_subscription_level_policy_assignment( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1936,19 +1795,15 @@ async def summarize_for_subscription_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, @@ -1956,7 +1811,7 @@ def list_query_results_for_resource_group_level_policy_assignment( policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyState"]: + ) -> AsyncItemPaged["_models.PolicyState"]: """Queries policy states for the resource group level policy assignment. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1971,11 +1826,6 @@ def list_query_results_for_resource_group_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1986,10 +1836,10 @@ def list_query_results_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2017,7 +1867,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_level_policy_assignment_request( + _request = build_list_query_results_for_resource_group_level_policy_assignment_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -2032,12 +1882,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -2058,18 +1906,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -2079,10 +1925,11 @@ async def extract_data(pipeline_response): return deserialized.odata_next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2095,12 +1942,8 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace_async - async def summarize_for_resource_group_level_policy_assignment( + async def summarize_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, @@ -2124,16 +1967,11 @@ async def summarize_for_resource_group_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2147,7 +1985,7 @@ async def summarize_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -2160,7 +1998,7 @@ async def summarize_for_resource_group_level_policy_assignment( _to = query_options.to _top = query_options.top - request = build_summarize_for_resource_group_level_policy_assignment_request( + _request = build_summarize_for_resource_group_level_policy_assignment_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -2171,15 +2009,14 @@ async def summarize_for_resource_group_level_policy_assignment( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2189,13 +2026,9 @@ async def summarize_for_resource_group_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore 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 32e7309c298e..e0a5b6286d78 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,25 +19,21 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._policy_tracked_resources_operations import ( build_list_query_results_for_management_group_request, build_list_query_results_for_resource_group_request, build_list_query_results_for_resource_request, build_list_query_results_for_subscription_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -56,10 +52,10 @@ class PolicyTrackedResourcesOperations: def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_management_group( @@ -68,7 +64,7 @@ def list_query_results_for_management_group( policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyTrackedResource"]: + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the management group. :param management_group_name: Management group name. Required. @@ -79,11 +75,6 @@ def list_query_results_for_management_group( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyTrackedResource or the result of cls(response) :rtype: @@ -96,12 +87,10 @@ def list_query_results_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,26 +106,23 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_management_group_request( + _request = build_list_query_results_for_management_group_request( management_group_name=management_group_name, policy_tracked_resources_resource=policy_tracked_resources_resource, top=_top, filter=_filter, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_query_results_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -146,10 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,17 +149,13 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_subscription( self, policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyTrackedResource"]: + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the subscription. :param policy_tracked_resources_resource: The name of the virtual resource under @@ -181,7 +164,6 @@ def list_query_results_for_subscription( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :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 PolicyTrackedResource or the result of cls(response) :rtype: @@ -191,12 +173,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,25 +192,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( policy_tracked_resources_resource=policy_tracked_resources_resource, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -240,10 +217,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -256,10 +234,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource_group( self, @@ -267,7 +241,7 @@ def list_query_results_for_resource_group( policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyTrackedResource"]: + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the resource group. :param resource_group_name: Resource group name. Required. @@ -278,7 +252,6 @@ def list_query_results_for_resource_group( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :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 PolicyTrackedResource or the result of cls(response) :rtype: @@ -288,12 +261,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -309,26 +280,23 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( resource_group_name=resource_group_name, policy_tracked_resources_resource=policy_tracked_resources_resource, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -338,10 +306,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -354,10 +323,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource( self, @@ -365,7 +330,7 @@ def list_query_results_for_resource( policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.PolicyTrackedResource"]: + ) -> AsyncItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the resource. :param resource_id: Resource ID. Required. @@ -376,7 +341,6 @@ def list_query_results_for_resource( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :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 PolicyTrackedResource or the result of cls(response) :rtype: @@ -386,12 +350,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,25 +369,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( resource_id=resource_id, policy_tracked_resources_resource=policy_tracked_resources_resource, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -435,10 +394,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -450,7 +410,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } 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 5057a838e275..520cd55cda60 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 @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload +from azure.core import AsyncPipelineClient from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,15 +21,14 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request +from ..._utils.serialization import Deserializer, Serializer from ...operations._remediations_operations import ( build_cancel_at_management_group_request, build_cancel_at_resource_group_request, @@ -54,11 +55,8 @@ build_list_for_resource_request, build_list_for_subscription_request, ) +from .._configuration import PolicyInsightsClientConfiguration -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,10 +75,10 @@ class RemediationsOperations: # pylint: disable=too-many-public-methods def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_deployments_at_management_group( @@ -89,7 +87,7 @@ def list_deployments_at_management_group( remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.RemediationDeployment"]: + ) -> AsyncItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at management group scope. :param management_group_id: Management group ID. Required. @@ -98,11 +96,6 @@ def list_deployments_at_management_group( :type remediation_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RemediationDeployment or the result of cls(response) :rtype: @@ -115,10 +108,10 @@ def list_deployments_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,25 +125,22 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_management_group_request( + _request = build_list_deployments_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, top=_top, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_deployments_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -160,10 +150,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,10 +167,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deployments_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace_async async def cancel_at_management_group( self, management_group_id: str, remediation_name: str, **kwargs: Any @@ -190,16 +177,11 @@ async def cancel_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,23 +195,22 @@ async def cancel_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_management_group_request( + _request = build_cancel_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.cancel_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -239,32 +220,23 @@ async def cancel_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_management_group( self, management_group_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Remediation"]: + ) -> AsyncItemPaged["_models.Remediation"]: """Gets all remediations for the management group. :param management_group_id: Management group ID. Required. :type management_group_id: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Remediation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -275,10 +247,10 @@ def list_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,25 +266,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_management_group_request( + _request = build_list_for_management_group_request( management_group_id=management_group_id, top=_top, filter=_filter, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -322,10 +291,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -338,10 +308,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations" - } - @overload async def create_or_update_at_management_group( self, @@ -363,11 +329,6 @@ async def create_or_update_at_management_group( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -378,7 +339,7 @@ async def create_or_update_at_management_group( self, management_group_id: str, remediation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -390,15 +351,10 @@ async def create_or_update_at_management_group( :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -406,7 +362,11 @@ async def create_or_update_at_management_group( @distributed_trace_async async def create_or_update_at_management_group( - self, management_group_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, + management_group_id: str, + remediation_name: str, + parameters: Union[_models.Remediation, IO[bytes]], + **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at management group scope. @@ -414,21 +374,14 @@ async def create_or_update_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,19 +395,19 @@ async def create_or_update_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_management_group_request( + _request = build_create_or_update_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, @@ -462,15 +415,14 @@ async def create_or_update_at_management_group( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -480,21 +432,13 @@ async def create_or_update_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace_async async def get_at_management_group( self, management_group_id: str, remediation_name: str, **kwargs: Any @@ -505,16 +449,11 @@ async def get_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,23 +467,22 @@ async def get_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_management_group_request( + _request = build_get_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.get_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -554,16 +492,12 @@ async def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_at_management_group( @@ -575,16 +509,11 @@ async def delete_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,23 +527,22 @@ async def delete_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_management_group_request( + _request = build_delete_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.delete_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -626,28 +554,23 @@ async def delete_at_management_group( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def list_deployments_at_subscription( self, remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.RemediationDeployment"]: + ) -> AsyncItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param query_options: Parameter group. Default value is None. :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 RemediationDeployment or the result of cls(response) :rtype: @@ -657,10 +580,10 @@ def list_deployments_at_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -674,24 +597,21 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_subscription_request( + _request = build_list_deployments_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, top=_top, api_version=api_version, - template_url=self.list_deployments_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -701,10 +621,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -717,22 +638,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deployments_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace_async async def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Cancels a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -743,22 +659,21 @@ async def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_subscription_request( + _request = build_cancel_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -768,26 +683,21 @@ async def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_subscription( self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Remediation"]: + ) -> AsyncItemPaged["_models.Remediation"]: """Gets all remediations for the subscription. :param query_options: Parameter group. Default value is None. :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 Remediation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -795,10 +705,10 @@ def list_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -814,24 +724,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -841,10 +748,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -857,10 +765,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations" - } - @overload async def create_or_update_at_subscription( self, @@ -879,7 +783,6 @@ async def create_or_update_at_subscription( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -887,18 +790,17 @@ async def create_or_update_at_subscription( @overload async def create_or_update_at_subscription( - self, remediation_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, remediation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -906,23 +808,20 @@ async def create_or_update_at_subscription( @distributed_trace_async async def create_or_update_at_subscription( - self, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -933,34 +832,33 @@ async def create_or_update_at_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_subscription_request( + _request = build_create_or_update_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -970,33 +868,24 @@ async def create_or_update_at_subscription( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace_async async def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Gets an existing remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1007,22 +896,21 @@ async def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_subscription_request( + _request = build_get_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1032,16 +920,12 @@ async def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _mo error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Optional[_models.Remediation]: @@ -1049,12 +933,11 @@ async def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1065,22 +948,21 @@ async def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_subscription_request( + _request = build_delete_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1092,16 +974,12 @@ async def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def list_deployments_at_resource_group( @@ -1110,7 +988,7 @@ def list_deployments_at_resource_group( remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.RemediationDeployment"]: + ) -> AsyncItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at resource group scope. :param resource_group_name: Resource group name. Required. @@ -1119,7 +997,6 @@ def list_deployments_at_resource_group( :type remediation_name: str :param query_options: Parameter group. Default value is None. :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 RemediationDeployment or the result of cls(response) :rtype: @@ -1129,10 +1006,10 @@ def list_deployments_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1146,25 +1023,22 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_resource_group_request( + _request = build_list_deployments_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, top=_top, api_version=api_version, - template_url=self.list_deployments_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -1174,10 +1048,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1190,10 +1065,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deployments_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace_async async def cancel_at_resource_group( self, resource_group_name: str, remediation_name: str, **kwargs: Any @@ -1204,12 +1075,11 @@ async def cancel_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1220,23 +1090,22 @@ async def cancel_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_resource_group_request( + _request = build_cancel_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1246,28 +1115,23 @@ async def cancel_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_resource_group( self, resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Remediation"]: + ) -> AsyncItemPaged["_models.Remediation"]: """Gets all remediations for the subscription. :param resource_group_name: Resource group name. Required. :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 Remediation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -1275,10 +1139,10 @@ def list_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1294,25 +1158,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -1322,10 +1183,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1338,10 +1200,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations" - } - @overload async def create_or_update_at_resource_group( self, @@ -1363,7 +1221,6 @@ async def create_or_update_at_resource_group( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1374,7 +1231,7 @@ async def create_or_update_at_resource_group( self, resource_group_name: str, remediation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1386,11 +1243,10 @@ async def create_or_update_at_resource_group( :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1398,7 +1254,11 @@ async def create_or_update_at_resource_group( @distributed_trace_async async def create_or_update_at_resource_group( - self, resource_group_name: str, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, + resource_group_name: str, + remediation_name: str, + parameters: Union[_models.Remediation, IO[bytes]], + **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at resource group scope. @@ -1406,17 +1266,14 @@ async def create_or_update_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1427,19 +1284,19 @@ async def create_or_update_at_resource_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_resource_group_request( + _request = build_create_or_update_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, @@ -1447,15 +1304,14 @@ async def create_or_update_at_resource_group( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1465,21 +1321,13 @@ async def create_or_update_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace_async async def get_at_resource_group( self, resource_group_name: str, remediation_name: str, **kwargs: Any @@ -1490,12 +1338,11 @@ async def get_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1506,23 +1353,22 @@ async def get_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_resource_group_request( + _request = build_get_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1532,16 +1378,12 @@ async def get_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_at_resource_group( @@ -1553,12 +1395,11 @@ async def delete_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1569,23 +1410,22 @@ async def delete_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_resource_group_request( + _request = build_delete_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1597,16 +1437,12 @@ async def delete_at_resource_group( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def list_deployments_at_resource( @@ -1615,7 +1451,7 @@ def list_deployments_at_resource( remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.RemediationDeployment"]: + ) -> AsyncItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at resource scope. :param resource_id: Resource ID. Required. @@ -1624,7 +1460,6 @@ def list_deployments_at_resource( :type remediation_name: str :param query_options: Parameter group. Default value is None. :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 RemediationDeployment or the result of cls(response) :rtype: @@ -1634,10 +1469,10 @@ def list_deployments_at_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1651,24 +1486,21 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_resource_request( + _request = build_list_deployments_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, top=_top, api_version=api_version, - template_url=self.list_deployments_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -1678,10 +1510,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1694,10 +1527,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_deployments_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace_async async def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Cancel a remediation at resource scope. @@ -1706,12 +1535,11 @@ async def cancel_at_resource(self, resource_id: str, remediation_name: str, **kw :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1722,22 +1550,21 @@ async def cancel_at_resource(self, resource_id: str, remediation_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_resource_request( + _request = build_cancel_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, - template_url=self.cancel_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1747,28 +1574,23 @@ async def cancel_at_resource(self, resource_id: str, remediation_name: str, **kw error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_resource( self, resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> AsyncIterable["_models.Remediation"]: + ) -> AsyncItemPaged["_models.Remediation"]: """Gets all remediations for a resource. :param resource_id: Resource ID. Required. :type resource_id: str :param query_options: Parameter group. Default value is None. :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 Remediation or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -1776,10 +1598,10 @@ def list_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1795,24 +1617,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_id=resource_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -1822,10 +1641,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1838,8 +1658,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_for_resource.metadata = {"url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations"} - @overload async def create_or_update_at_resource( self, @@ -1861,7 +1679,6 @@ async def create_or_update_at_resource( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1872,7 +1689,7 @@ async def create_or_update_at_resource( self, resource_id: str, remediation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1884,11 +1701,10 @@ async def create_or_update_at_resource( :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1896,7 +1712,7 @@ async def create_or_update_at_resource( @distributed_trace_async async def create_or_update_at_resource( - self, resource_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, resource_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at resource scope. @@ -1904,17 +1720,14 @@ async def create_or_update_at_resource( :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1925,34 +1738,33 @@ async def create_or_update_at_resource( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_resource_request( + _request = build_create_or_update_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1962,21 +1774,13 @@ async def create_or_update_at_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace_async async def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Gets an existing remediation at resource scope. @@ -1985,12 +1789,11 @@ async def get_at_resource(self, resource_id: str, remediation_name: str, **kwarg :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2001,22 +1804,21 @@ async def get_at_resource(self, resource_id: str, remediation_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_resource_request( + _request = build_get_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, - template_url=self.get_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2026,16 +1828,12 @@ async def get_at_resource(self, resource_id: str, remediation_name: str, **kwarg error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete_at_resource( @@ -2047,12 +1845,11 @@ async def delete_at_resource( :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2063,22 +1860,21 @@ async def delete_at_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_resource_request( + _request = build_delete_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, - template_url=self.delete_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2090,13 +1886,9 @@ async def delete_at_resource( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore 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 00583df241b2..bb01291aaad3 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 @@ -5,83 +5,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._models_py3 import Attestation -from ._models_py3 import AttestationEvidence -from ._models_py3 import AttestationListResult -from ._models_py3 import CheckManagementGroupRestrictionsRequest -from ._models_py3 import CheckRestrictionsRequest -from ._models_py3 import CheckRestrictionsResourceDetails -from ._models_py3 import CheckRestrictionsResult -from ._models_py3 import CheckRestrictionsResultContentEvaluationResult -from ._models_py3 import ComplianceDetail -from ._models_py3 import ComponentEventDetails -from ._models_py3 import ComponentExpressionEvaluationDetails -from ._models_py3 import ComponentPolicyEvaluationDetails -from ._models_py3 import ComponentPolicyState -from ._models_py3 import ComponentPolicyStatesQueryResults -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 -from ._models_py3 import IfNotExistsEvaluationDetails -from ._models_py3 import Operation -from ._models_py3 import OperationDisplay -from ._models_py3 import OperationsListResults -from ._models_py3 import PendingField -from ._models_py3 import PolicyAssignmentSummary -from ._models_py3 import PolicyDefinitionSummary -from ._models_py3 import PolicyDetails -from ._models_py3 import PolicyEvaluationDetails -from ._models_py3 import PolicyEvaluationResult -from ._models_py3 import PolicyEvent -from ._models_py3 import PolicyEventsQueryResults -from ._models_py3 import PolicyGroupSummary -from ._models_py3 import PolicyMetadata -from ._models_py3 import PolicyMetadataCollection -from ._models_py3 import PolicyMetadataProperties -from ._models_py3 import PolicyMetadataSlimProperties -from ._models_py3 import PolicyReference -from ._models_py3 import PolicyState -from ._models_py3 import PolicyStatesQueryResults -from ._models_py3 import PolicyTrackedResource -from ._models_py3 import PolicyTrackedResourcesQueryResults -from ._models_py3 import QueryFailure -from ._models_py3 import QueryFailureError -from ._models_py3 import QueryOptions -from ._models_py3 import Remediation -from ._models_py3 import RemediationDeployment -from ._models_py3 import RemediationDeploymentSummary -from ._models_py3 import RemediationDeploymentsListResult -from ._models_py3 import RemediationFilters -from ._models_py3 import RemediationListResult -from ._models_py3 import RemediationPropertiesFailureThreshold -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 +from typing import TYPE_CHECKING -from ._policy_insights_client_enums import ComplianceState -from ._policy_insights_client_enums import ComponentPolicyStatesResource -from ._policy_insights_client_enums import CreatedByType -from ._policy_insights_client_enums import FieldRestrictionResult -from ._policy_insights_client_enums import PolicyEventsResourceType -from ._policy_insights_client_enums import PolicyStatesResource -from ._policy_insights_client_enums import PolicyStatesSummaryResourceType -from ._policy_insights_client_enums import PolicyTrackedResourcesResourceType -from ._policy_insights_client_enums import ResourceDiscoveryMode +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + + +from ._models_py3 import ( # type: ignore + Attestation, + AttestationEvidence, + AttestationListResult, + CheckManagementGroupRestrictionsRequest, + CheckRestrictionEvaluationDetails, + CheckRestrictionsRequest, + CheckRestrictionsResourceDetails, + CheckRestrictionsResult, + CheckRestrictionsResultContentEvaluationResult, + ComplianceDetail, + ComponentEventDetails, + ComponentExpressionEvaluationDetails, + ComponentPolicyEvaluationDetails, + ComponentPolicyState, + ComponentPolicyStatesQueryResults, + ComponentStateDetails, + ErrorDefinition, + ErrorDefinitionAutoGenerated, + ErrorDefinitionAutoGenerated2, + ErrorResponse, + ErrorResponseAutoGenerated, + ErrorResponseAutoGenerated2, + ExpressionEvaluationDetails, + FieldRestriction, + FieldRestrictions, + IfNotExistsEvaluationDetails, + Operation, + OperationDisplay, + OperationsListResults, + PendingField, + PolicyAssignmentSummary, + PolicyDefinitionSummary, + PolicyDetails, + PolicyEffectDetails, + PolicyEvaluationDetails, + PolicyEvaluationResult, + PolicyEvent, + PolicyEventsQueryResults, + PolicyGroupSummary, + PolicyMetadata, + PolicyMetadataCollection, + PolicyMetadataProperties, + PolicyMetadataSlimProperties, + PolicyReference, + PolicyState, + PolicyStatesQueryResults, + PolicyTrackedResource, + PolicyTrackedResourcesQueryResults, + QueryFailure, + QueryFailureError, + QueryOptions, + Remediation, + RemediationDeployment, + RemediationDeploymentSummary, + RemediationDeploymentsListResult, + RemediationFilters, + RemediationListResult, + RemediationPropertiesFailureThreshold, + Resource, + SlimPolicyMetadata, + SummarizeResults, + Summary, + SummaryResults, + SystemData, + TrackedResourceModificationDetails, + TypedErrorInfo, +) + +from ._policy_insights_client_enums import ( # type: ignore + ComplianceState, + ComponentPolicyStatesResource, + CreatedByType, + FieldRestrictionResult, + PolicyEventsResourceType, + PolicyStatesResource, + PolicyStatesSummaryResourceType, + PolicyTrackedResourcesResourceType, + ResourceDiscoveryMode, +) from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -89,6 +102,7 @@ "AttestationEvidence", "AttestationListResult", "CheckManagementGroupRestrictionsRequest", + "CheckRestrictionEvaluationDetails", "CheckRestrictionsRequest", "CheckRestrictionsResourceDetails", "CheckRestrictionsResult", @@ -117,6 +131,7 @@ "PolicyAssignmentSummary", "PolicyDefinitionSummary", "PolicyDetails", + "PolicyEffectDetails", "PolicyEvaluationDetails", "PolicyEvaluationResult", "PolicyEvent", @@ -159,5 +174,5 @@ "PolicyTrackedResourcesResourceType", "ResourceDiscoveryMode", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 4e688b25229a..def92d910c99 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 @@ -1,5 +1,5 @@ +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 -# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,21 +7,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime -import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from .. import _serialization - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +from .._utils import serialization as _serialization if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +JSON = MutableMapping[str, Any] class Resource(_serialization.Model): @@ -51,20 +45,20 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None + self.id: Optional[str] = None + self.name: Optional[str] = None + self.type: Optional[str] = None -class Attestation(Resource): # pylint: disable=too-many-instance-attributes +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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. @@ -148,8 +142,8 @@ def __init__( evidence: Optional[List["_models.AttestationEvidence"]] = None, assessment_date: Optional[datetime.datetime] = None, metadata: Optional[JSON] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword policy_assignment_id: The resource ID of the policy assignment that the attestation is setting the state for. Required. @@ -177,7 +171,7 @@ def __init__( :paramtype metadata: JSON """ super().__init__(**kwargs) - self.system_data = None + self.system_data: Optional["_models.SystemData"] = None self.policy_assignment_id = policy_assignment_id self.policy_definition_reference_id = policy_definition_reference_id self.compliance_state = compliance_state @@ -185,8 +179,8 @@ def __init__( self.owner = owner self.comments = comments self.evidence = evidence - self.provisioning_state = None - self.last_compliance_state_change_at = None + self.provisioning_state: Optional[str] = None + self.last_compliance_state_change_at: Optional[datetime.datetime] = None self.assessment_date = assessment_date self.metadata = metadata @@ -205,7 +199,7 @@ class AttestationEvidence(_serialization.Model): "source_uri": {"key": "sourceUri", "type": "str"}, } - def __init__(self, *, description: Optional[str] = None, source_uri: Optional[str] = None, **kwargs): + def __init__(self, *, description: Optional[str] = None, source_uri: Optional[str] = None, **kwargs: Any) -> None: """ :keyword description: The description for this piece of evidence. :paramtype description: str @@ -238,11 +232,11 @@ class AttestationListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[List["_models.Attestation"]] = None + self.next_link: Optional[str] = None class CheckManagementGroupRestrictionsRequest(_serialization.Model): @@ -265,8 +259,8 @@ def __init__( *, resource_details: Optional["_models.CheckRestrictionsResourceDetails"] = None, pending_fields: Optional[List["_models.PendingField"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_details: The information about the resource that will be evaluated. :paramtype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails @@ -279,16 +273,64 @@ def __init__( self.pending_fields = pending_fields +class CheckRestrictionEvaluationDetails(_serialization.Model): + """Policy evaluation details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar evaluated_expressions: Details of the evaluated expressions. + :vartype evaluated_expressions: + list[~azure.mgmt.policyinsights.models.ExpressionEvaluationDetails] + :ivar if_not_exists_details: Evaluation details of IfNotExists effect. + :vartype if_not_exists_details: ~azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails + :ivar reason: The reason for the evaluation result. + :vartype reason: str + """ + + _validation = { + "reason": {"readonly": True}, + } + + _attribute_map = { + "evaluated_expressions": {"key": "evaluatedExpressions", "type": "[ExpressionEvaluationDetails]"}, + "if_not_exists_details": {"key": "ifNotExistsDetails", "type": "IfNotExistsEvaluationDetails"}, + "reason": {"key": "reason", "type": "str"}, + } + + def __init__( + self, + *, + evaluated_expressions: Optional[List["_models.ExpressionEvaluationDetails"]] = None, + if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = None, + **kwargs: Any + ) -> None: + """ + :keyword evaluated_expressions: Details of the evaluated expressions. + :paramtype evaluated_expressions: + list[~azure.mgmt.policyinsights.models.ExpressionEvaluationDetails] + :keyword if_not_exists_details: Evaluation details of IfNotExists effect. + :paramtype if_not_exists_details: + ~azure.mgmt.policyinsights.models.IfNotExistsEvaluationDetails + """ + super().__init__(**kwargs) + self.evaluated_expressions = evaluated_expressions + self.if_not_exists_details = if_not_exists_details + self.reason: Optional[str] = None + + class CheckRestrictionsRequest(_serialization.Model): """The check policy restrictions parameters describing the resource that is being evaluated. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar resource_details: The information about the resource that will be evaluated. Required. :vartype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails :ivar pending_fields: The list of fields and values that should be evaluated for potential restrictions. :vartype pending_fields: list[~azure.mgmt.policyinsights.models.PendingField] + :ivar include_audit_effect: Whether to include policies with the 'audit' effect in the results. + Defaults to false. + :vartype include_audit_effect: bool """ _validation = { @@ -298,6 +340,7 @@ class CheckRestrictionsRequest(_serialization.Model): _attribute_map = { "resource_details": {"key": "resourceDetails", "type": "CheckRestrictionsResourceDetails"}, "pending_fields": {"key": "pendingFields", "type": "[PendingField]"}, + "include_audit_effect": {"key": "includeAuditEffect", "type": "bool"}, } def __init__( @@ -305,24 +348,29 @@ def __init__( *, resource_details: "_models.CheckRestrictionsResourceDetails", pending_fields: Optional[List["_models.PendingField"]] = None, - **kwargs - ): + include_audit_effect: bool = False, + **kwargs: Any + ) -> None: """ :keyword resource_details: The information about the resource that will be evaluated. Required. :paramtype resource_details: ~azure.mgmt.policyinsights.models.CheckRestrictionsResourceDetails :keyword pending_fields: The list of fields and values that should be evaluated for potential restrictions. :paramtype pending_fields: list[~azure.mgmt.policyinsights.models.PendingField] + :keyword include_audit_effect: Whether to include policies with the 'audit' effect in the + results. Defaults to false. + :paramtype include_audit_effect: bool """ super().__init__(**kwargs) self.resource_details = resource_details self.pending_fields = pending_fields + self.include_audit_effect = include_audit_effect class CheckRestrictionsResourceDetails(_serialization.Model): """The information about the resource that will be evaluated. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar resource_content: The resource content. This should include whatever properties are already known and can be a partial set of all resource properties. Required. @@ -345,8 +393,8 @@ class CheckRestrictionsResourceDetails(_serialization.Model): } def __init__( - self, *, resource_content: JSON, api_version: Optional[str] = None, scope: Optional[str] = None, **kwargs - ): + self, *, resource_content: JSON, api_version: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword resource_content: The resource content. This should include whatever properties are already known and can be a partial set of all resource properties. Required. @@ -389,14 +437,14 @@ class CheckRestrictionsResult(_serialization.Model): }, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.field_restrictions = None - self.content_evaluation_result = None + self.field_restrictions: Optional[List["_models.FieldRestrictions"]] = None + self.content_evaluation_result: Optional["_models.CheckRestrictionsResultContentEvaluationResult"] = None -class CheckRestrictionsResultContentEvaluationResult(_serialization.Model): +class CheckRestrictionsResultContentEvaluationResult(_serialization.Model): # pylint: disable=name-too-long """Evaluation results for the provided partial resource content. :ivar policy_evaluations: Policy evaluation results against the given resource content. This @@ -408,7 +456,9 @@ class CheckRestrictionsResultContentEvaluationResult(_serialization.Model): "policy_evaluations": {"key": "policyEvaluations", "type": "[PolicyEvaluationResult]"}, } - def __init__(self, *, policy_evaluations: Optional[List["_models.PolicyEvaluationResult"]] = None, **kwargs): + def __init__( + self, *, policy_evaluations: Optional[List["_models.PolicyEvaluationResult"]] = None, **kwargs: Any + ) -> None: """ :keyword policy_evaluations: Policy evaluation results against the given resource content. This will indicate if the partial content that was provided will be denied as-is. @@ -432,7 +482,7 @@ class ComplianceDetail(_serialization.Model): "count": {"key": "count", "type": "int"}, } - def __init__(self, *, compliance_state: Optional[str] = None, count: Optional[int] = None, **kwargs): + def __init__(self, *, compliance_state: Optional[str] = None, count: Optional[int] = None, **kwargs: Any) -> None: """ :keyword compliance_state: The compliance state. :paramtype compliance_state: str @@ -489,8 +539,8 @@ def __init__( tenant_id: Optional[str] = None, principal_oid: Optional[str] = None, policy_definition_action: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -562,19 +612,19 @@ class ComponentExpressionEvaluationDetails(_serialization.Model): "operator": {"key": "operator", "type": "str"}, } - def __init__(self, *, result: Optional[str] = None, **kwargs): + def __init__(self, *, result: Optional[str] = None, **kwargs: Any) -> None: """ :keyword result: Evaluation result. :paramtype result: str """ super().__init__(**kwargs) self.result = result - self.expression = None - self.expression_kind = None - self.path = None - self.expression_value = None - self.target_value = None - self.operator = None + self.expression: Optional[str] = None + self.expression_kind: Optional[str] = None + self.path: Optional[str] = None + self.expression_value: Optional[JSON] = None + self.target_value: Optional[JSON] = None + self.operator: Optional[str] = None class ComponentPolicyEvaluationDetails(_serialization.Model): @@ -598,17 +648,17 @@ class ComponentPolicyEvaluationDetails(_serialization.Model): "reason": {"key": "reason", "type": "str"}, } - def __init__(self, *, reason: Optional[str] = None, **kwargs): + def __init__(self, *, reason: Optional[str] = None, **kwargs: Any) -> None: """ :keyword reason: Additional textual reason for the evaluation outcome. :paramtype reason: str """ super().__init__(**kwargs) - self.evaluated_expressions = None + self.evaluated_expressions: Optional[List["_models.ComponentExpressionEvaluationDetails"]] = None self.reason = reason -class ComponentPolicyState(_serialization.Model): # pylint: disable=too-many-instance-attributes +class ComponentPolicyState(_serialization.Model): """Component Policy State record. Variables are only populated by the server, and will be ignored when sending a request. @@ -767,8 +817,8 @@ def __init__( # pylint: disable=too-many-locals *, additional_properties: Optional[Dict[str, Any]] = None, policy_evaluation_details: Optional["_models.ComponentPolicyEvaluationDetails"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -780,38 +830,38 @@ def __init__( # pylint: disable=too-many-locals """ super().__init__(**kwargs) self.additional_properties = additional_properties - self.odata_id = None - self.odata_context = None - self.timestamp = None - self.component_id = None - self.component_type = None - self.component_name = None - self.resource_id = None - self.policy_assignment_id = None - self.policy_definition_id = None - self.subscription_id = None - self.resource_type = None - self.resource_location = None - self.resource_group = None - self.policy_assignment_name = None - self.policy_assignment_owner = None - self.policy_assignment_parameters = None - self.policy_assignment_scope = None - self.policy_definition_name = None - self.policy_definition_action = None - self.policy_definition_category = None - self.policy_set_definition_id = None - self.policy_set_definition_name = None - self.policy_set_definition_owner = None - self.policy_set_definition_category = None - self.policy_set_definition_parameters = None - self.policy_definition_reference_id = None - self.compliance_state = None + self.odata_id: Optional[str] = None + self.odata_context: Optional[str] = None + self.timestamp: Optional[datetime.datetime] = None + self.component_id: Optional[str] = None + self.component_type: Optional[str] = None + self.component_name: Optional[str] = None + self.resource_id: Optional[str] = None + self.policy_assignment_id: Optional[str] = None + self.policy_definition_id: Optional[str] = None + self.subscription_id: Optional[str] = None + self.resource_type: Optional[str] = None + self.resource_location: Optional[str] = None + self.resource_group: Optional[str] = None + self.policy_assignment_name: Optional[str] = None + self.policy_assignment_owner: Optional[str] = None + self.policy_assignment_parameters: Optional[str] = None + self.policy_assignment_scope: Optional[str] = None + self.policy_definition_name: Optional[str] = None + self.policy_definition_action: Optional[str] = None + self.policy_definition_category: Optional[str] = None + self.policy_set_definition_id: Optional[str] = None + self.policy_set_definition_name: Optional[str] = None + self.policy_set_definition_owner: Optional[str] = None + self.policy_set_definition_category: Optional[str] = None + self.policy_set_definition_parameters: Optional[str] = None + self.policy_definition_reference_id: Optional[str] = None + self.compliance_state: Optional[str] = None self.policy_evaluation_details = policy_evaluation_details - self.policy_definition_group_names = None - self.policy_definition_version = None - self.policy_set_definition_version = None - self.policy_assignment_version = None + self.policy_definition_group_names: Optional[List[str]] = None + self.policy_definition_version: Optional[str] = None + self.policy_set_definition_version: Optional[str] = None + self.policy_assignment_version: Optional[str] = None class ComponentPolicyStatesQueryResults(_serialization.Model): @@ -842,8 +892,8 @@ def __init__( odata_context: Optional[str] = None, odata_count: Optional[int] = None, value: Optional[List["_models.ComponentPolicyState"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword odata_context: OData context string; used by OData clients to resolve type information based on metadata. @@ -896,8 +946,8 @@ def __init__( name: Optional[str] = None, timestamp: Optional[datetime.datetime] = None, compliance_state: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -955,14 +1005,14 @@ class ErrorDefinition(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[TypedErrorInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[List["_models.ErrorDefinition"]] = None + self.additional_info: Optional[List["_models.TypedErrorInfo"]] = None class ErrorDefinitionAutoGenerated(_serialization.Model): @@ -998,14 +1048,14 @@ class ErrorDefinitionAutoGenerated(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[TypedErrorInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[List["_models.ErrorDefinitionAutoGenerated"]] = None + self.additional_info: Optional[List["_models.TypedErrorInfo"]] = None class ErrorDefinitionAutoGenerated2(_serialization.Model): @@ -1041,14 +1091,14 @@ class ErrorDefinitionAutoGenerated2(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[TypedErrorInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.code: Optional[str] = None + self.message: Optional[str] = None + self.target: Optional[str] = None + self.details: Optional[List["_models.ErrorDefinitionAutoGenerated2"]] = None + self.additional_info: Optional[List["_models.TypedErrorInfo"]] = None class ErrorResponse(_serialization.Model): @@ -1062,7 +1112,7 @@ class ErrorResponse(_serialization.Model): "error": {"key": "error", "type": "ErrorDefinition"}, } - def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDefinition"] = None, **kwargs: Any) -> None: """ :keyword error: The error details. :paramtype error: ~azure.mgmt.policyinsights.models.ErrorDefinition @@ -1082,7 +1132,7 @@ class ErrorResponseAutoGenerated(_serialization.Model): "error": {"key": "error", "type": "ErrorDefinitionAutoGenerated"}, } - def __init__(self, *, error: Optional["_models.ErrorDefinitionAutoGenerated"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDefinitionAutoGenerated"] = None, **kwargs: Any) -> None: """ :keyword error: The error details. :paramtype error: ~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated @@ -1102,7 +1152,7 @@ class ErrorResponseAutoGenerated2(_serialization.Model): "error": {"key": "error", "type": "ErrorDefinitionAutoGenerated2"}, } - def __init__(self, *, error: Optional["_models.ErrorDefinitionAutoGenerated2"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDefinitionAutoGenerated2"] = None, **kwargs: Any) -> None: """ :keyword error: The error details. :paramtype error: ~azure.mgmt.policyinsights.models.ErrorDefinitionAutoGenerated2 @@ -1155,8 +1205,8 @@ def __init__( expression_value: Optional[JSON] = None, target_value: Optional[JSON] = None, operator: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword result: Evaluation result. :paramtype result: str @@ -1174,7 +1224,7 @@ def __init__( super().__init__(**kwargs) self.result = result self.expression = expression - self.expression_kind = None + self.expression_kind: Optional[str] = None self.path = path self.expression_value = expression_value self.target_value = target_value @@ -1187,7 +1237,7 @@ class FieldRestriction(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar result: The type of restriction that is imposed on the field. Known values are: - "Required", "Removed", and "Deny". + "Required", "Removed", "Deny", and "Audit". :vartype result: str or ~azure.mgmt.policyinsights.models.FieldRestrictionResult :ivar default_value: The value that policy will set for the field if the user does not provide a value. @@ -1196,6 +1246,11 @@ class FieldRestriction(_serialization.Model): :vartype values: list[str] :ivar policy: The details of the policy that is causing the field restriction. :vartype policy: ~azure.mgmt.policyinsights.models.PolicyReference + :ivar policy_effect: The effect of the policy that is causing the field restriction. + http://aka.ms/policyeffects. + :vartype policy_effect: str + :ivar reason: The reason for the restriction. + :vartype reason: str """ _validation = { @@ -1203,6 +1258,8 @@ class FieldRestriction(_serialization.Model): "default_value": {"readonly": True}, "values": {"readonly": True}, "policy": {"readonly": True}, + "policy_effect": {"readonly": True}, + "reason": {"readonly": True}, } _attribute_map = { @@ -1210,15 +1267,19 @@ class FieldRestriction(_serialization.Model): "default_value": {"key": "defaultValue", "type": "str"}, "values": {"key": "values", "type": "[str]"}, "policy": {"key": "policy", "type": "PolicyReference"}, + "policy_effect": {"key": "policyEffect", "type": "str"}, + "reason": {"key": "reason", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.result = None - self.default_value = None - self.values = None - self.policy = None + self.result: Optional[Union[str, "_models.FieldRestrictionResult"]] = None + self.default_value: Optional[str] = None + self.values: Optional[List[str]] = None + self.policy: Optional["_models.PolicyReference"] = None + self.policy_effect: Optional[str] = None + self.reason: Optional[str] = None class FieldRestrictions(_serialization.Model): @@ -1242,13 +1303,13 @@ class FieldRestrictions(_serialization.Model): "restrictions": {"key": "restrictions", "type": "[FieldRestriction]"}, } - def __init__(self, *, restrictions: Optional[List["_models.FieldRestriction"]] = None, **kwargs): + def __init__(self, *, restrictions: Optional[List["_models.FieldRestriction"]] = None, **kwargs: Any) -> None: """ :keyword restrictions: The restrictions placed on that field by policy. :paramtype restrictions: list[~azure.mgmt.policyinsights.models.FieldRestriction] """ super().__init__(**kwargs) - self.field = None + self.field: Optional[str] = None self.restrictions = restrictions @@ -1267,7 +1328,9 @@ class IfNotExistsEvaluationDetails(_serialization.Model): "total_resources": {"key": "totalResources", "type": "int"}, } - def __init__(self, *, resource_id: Optional[str] = None, total_resources: Optional[int] = None, **kwargs): + def __init__( + self, *, resource_id: Optional[str] = None, total_resources: Optional[int] = None, **kwargs: Any + ) -> None: """ :keyword resource_id: ID of the last evaluated resource for IfNotExists effect. :paramtype resource_id: str @@ -1303,8 +1366,8 @@ def __init__( name: Optional[str] = None, is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Operation name. :paramtype name: str @@ -1346,8 +1409,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Resource provider name. :paramtype provider: str @@ -1384,8 +1447,8 @@ class OperationsListResults(_serialization.Model): } def __init__( - self, *, odata_count: Optional[int] = None, value: Optional[List["_models.Operation"]] = None, **kwargs - ): + self, *, odata_count: Optional[int] = None, value: Optional[List["_models.Operation"]] = None, **kwargs: Any + ) -> None: """ :keyword odata_count: OData entity count; represents the number of operations returned. :paramtype odata_count: int @@ -1400,7 +1463,7 @@ def __init__( class PendingField(_serialization.Model): """A field that should be evaluated against Azure Policy to determine restrictions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar field: The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias. Required. @@ -1419,7 +1482,7 @@ class PendingField(_serialization.Model): "values": {"key": "values", "type": "[str]"}, } - def __init__(self, *, field: str, values: Optional[List[str]] = None, **kwargs): + def __init__(self, *, field: str, values: Optional[List[str]] = None, **kwargs: Any) -> None: """ :keyword field: The name of the field. This can be a top-level property like 'name' or 'type' or an Azure Policy field alias. Required. @@ -1465,8 +1528,8 @@ def __init__( results: Optional["_models.SummaryResults"] = None, policy_definitions: Optional[List["_models.PolicyDefinitionSummary"]] = None, policy_groups: Optional[List["_models.PolicyGroupSummary"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword policy_assignment_id: Policy assignment ID. :paramtype policy_assignment_id: str @@ -1519,8 +1582,8 @@ def __init__( policy_definition_group_names: Optional[List[str]] = None, effect: Optional[str] = None, results: Optional["_models.SummaryResults"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword policy_definition_id: Policy definition ID. :paramtype policy_definition_id: str @@ -1579,15 +1642,38 @@ class PolicyDetails(_serialization.Model): "policy_definition_reference_id": {"key": "policyDefinitionReferenceId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.policy_definition_id = None - self.policy_assignment_id = None - self.policy_assignment_display_name = None - self.policy_assignment_scope = None - self.policy_set_definition_id = None - self.policy_definition_reference_id = None + self.policy_definition_id: Optional[str] = None + self.policy_assignment_id: Optional[str] = None + self.policy_assignment_display_name: Optional[str] = None + self.policy_assignment_scope: Optional[str] = None + self.policy_set_definition_id: Optional[str] = None + self.policy_definition_reference_id: Optional[str] = None + + +class PolicyEffectDetails(_serialization.Model): + """The details of the effect that was applied to the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar policy_effect: The effect that was applied to the resource. http://aka.ms/policyeffects. + :vartype policy_effect: str + """ + + _validation = { + "policy_effect": {"readonly": True}, + } + + _attribute_map = { + "policy_effect": {"key": "policyEffect", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.policy_effect: Optional[str] = None class PolicyEvaluationDetails(_serialization.Model): @@ -1610,8 +1696,8 @@ def __init__( *, evaluated_expressions: Optional[List["_models.ExpressionEvaluationDetails"]] = None, if_not_exists_details: Optional["_models.IfNotExistsEvaluationDetails"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword evaluated_expressions: Details of the evaluated expressions. :paramtype evaluated_expressions: @@ -1637,30 +1723,36 @@ class PolicyEvaluationResult(_serialization.Model): :vartype evaluation_result: str :ivar evaluation_details: The detailed results of the policy expressions and values that were evaluated. - :vartype evaluation_details: ~azure.mgmt.policyinsights.models.PolicyEvaluationDetails + :vartype evaluation_details: + ~azure.mgmt.policyinsights.models.CheckRestrictionEvaluationDetails + :ivar effect_details: The details of the effect that was applied to the resource. + :vartype effect_details: ~azure.mgmt.policyinsights.models.PolicyEffectDetails """ _validation = { "policy_info": {"readonly": True}, "evaluation_result": {"readonly": True}, "evaluation_details": {"readonly": True}, + "effect_details": {"readonly": True}, } _attribute_map = { "policy_info": {"key": "policyInfo", "type": "PolicyReference"}, "evaluation_result": {"key": "evaluationResult", "type": "str"}, - "evaluation_details": {"key": "evaluationDetails", "type": "PolicyEvaluationDetails"}, + "evaluation_details": {"key": "evaluationDetails", "type": "CheckRestrictionEvaluationDetails"}, + "effect_details": {"key": "effectDetails", "type": "PolicyEffectDetails"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.policy_info = None - self.evaluation_result = None - self.evaluation_details = None + self.policy_info: Optional["_models.PolicyReference"] = None + self.evaluation_result: Optional[str] = None + self.evaluation_details: Optional["_models.CheckRestrictionEvaluationDetails"] = None + self.effect_details: Optional["_models.PolicyEffectDetails"] = None -class PolicyEvent(_serialization.Model): # pylint: disable=too-many-instance-attributes +class PolicyEvent(_serialization.Model): """Policy event record. :ivar additional_properties: Unmatched properties from the message are deserialized to this @@ -1812,8 +1904,8 @@ def __init__( # pylint: disable=too-many-locals tenant_id: Optional[str] = None, principal_oid: Optional[str] = None, components: Optional[List["_models.ComponentEventDetails"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -1960,8 +2052,8 @@ def __init__( odata_count: Optional[int] = None, odata_next_link: Optional[str] = None, value: Optional[List["_models.PolicyEvent"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword odata_context: OData context string; used by OData clients to resolve type information based on metadata. @@ -1996,8 +2088,12 @@ class PolicyGroupSummary(_serialization.Model): } def __init__( - self, *, policy_group_name: Optional[str] = None, results: Optional["_models.SummaryResults"] = None, **kwargs - ): + self, + *, + policy_group_name: Optional[str] = None, + results: Optional["_models.SummaryResults"] = None, + **kwargs: Any + ) -> None: """ :keyword policy_group_name: Policy group name. :paramtype policy_group_name: str @@ -2009,7 +2105,7 @@ def __init__( self.results = results -class PolicyMetadata(_serialization.Model): # pylint: disable=too-many-instance-attributes +class PolicyMetadata(_serialization.Model): """Policy metadata resource definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -2066,20 +2162,20 @@ class PolicyMetadata(_serialization.Model): # pylint: disable=too-many-instance "requirements": {"key": "properties.requirements", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.metadata_id = None - self.category = None - self.title = None - self.owner = None - self.additional_content_url = None - self.metadata = None - self.description = None - self.requirements = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None + self.metadata_id: Optional[str] = None + self.category: Optional[str] = None + self.title: Optional[str] = None + self.owner: Optional[str] = None + self.additional_content_url: Optional[str] = None + self.metadata: Optional[JSON] = None + self.description: Optional[str] = None + self.requirements: Optional[str] = None class PolicyMetadataCollection(_serialization.Model): @@ -2103,11 +2199,11 @@ class PolicyMetadataCollection(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[List["_models.SlimPolicyMetadata"]] = None + self.next_link: Optional[str] = None class PolicyMetadataSlimProperties(_serialization.Model): @@ -2147,15 +2243,15 @@ class PolicyMetadataSlimProperties(_serialization.Model): "metadata": {"key": "metadata", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.metadata_id = None - self.category = None - self.title = None - self.owner = None - self.additional_content_url = None - self.metadata = None + self.metadata_id: Optional[str] = None + self.category: Optional[str] = None + self.title: Optional[str] = None + self.owner: Optional[str] = None + self.additional_content_url: Optional[str] = None + self.metadata: Optional[JSON] = None class PolicyMetadataProperties(PolicyMetadataSlimProperties): @@ -2203,11 +2299,11 @@ class PolicyMetadataProperties(PolicyMetadataSlimProperties): "requirements": {"key": "requirements", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.description = None - self.requirements = None + self.description: Optional[str] = None + self.requirements: Optional[str] = None class PolicyReference(_serialization.Model): @@ -2240,16 +2336,16 @@ class PolicyReference(_serialization.Model): "policy_assignment_id": {"key": "policyAssignmentId", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.policy_definition_id = None - self.policy_set_definition_id = None - self.policy_definition_reference_id = None - self.policy_assignment_id = None + self.policy_definition_id: Optional[str] = None + self.policy_set_definition_id: Optional[str] = None + self.policy_definition_reference_id: Optional[str] = None + self.policy_assignment_id: Optional[str] = None -class PolicyState(_serialization.Model): # pylint: disable=too-many-instance-attributes +class PolicyState(_serialization.Model): """Policy state record. Variables are only populated by the server, and will be ignored when sending a request. @@ -2418,8 +2514,8 @@ def __init__( # pylint: disable=too-many-locals policy_evaluation_details: Optional["_models.PolicyEvaluationDetails"] = None, policy_definition_group_names: Optional[List[str]] = None, components: Optional[List["_models.ComponentStateDetails"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -2532,9 +2628,9 @@ def __init__( # pylint: disable=too-many-locals self.policy_evaluation_details = policy_evaluation_details self.policy_definition_group_names = policy_definition_group_names self.components = components - self.policy_definition_version = None - self.policy_set_definition_version = None - self.policy_assignment_version = None + self.policy_definition_version: Optional[str] = None + self.policy_set_definition_version: Optional[str] = None + self.policy_assignment_version: Optional[str] = None class PolicyStatesQueryResults(_serialization.Model): @@ -2569,8 +2665,8 @@ def __init__( odata_count: Optional[int] = None, odata_next_link: Optional[str] = None, value: Optional[List["_models.PolicyState"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword odata_context: OData context string; used by OData clients to resolve type information based on metadata. @@ -2625,14 +2721,14 @@ class PolicyTrackedResource(_serialization.Model): "last_update_utc": {"key": "lastUpdateUtc", "type": "iso-8601"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.tracked_resource_id = None - self.policy_details = None - self.created_by = None - self.last_modified_by = None - self.last_update_utc = None + self.tracked_resource_id: Optional[str] = None + self.policy_details: Optional["_models.PolicyDetails"] = None + self.created_by: Optional["_models.TrackedResourceModificationDetails"] = None + self.last_modified_by: Optional["_models.TrackedResourceModificationDetails"] = None + self.last_update_utc: Optional[datetime.datetime] = None class PolicyTrackedResourcesQueryResults(_serialization.Model): @@ -2656,11 +2752,11 @@ class PolicyTrackedResourcesQueryResults(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[List["_models.PolicyTrackedResource"]] = None + self.next_link: Optional[str] = None class QueryFailure(_serialization.Model): @@ -2674,7 +2770,7 @@ class QueryFailure(_serialization.Model): "error": {"key": "error", "type": "QueryFailureError"}, } - def __init__(self, *, error: Optional["_models.QueryFailureError"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.QueryFailureError"] = None, **kwargs: Any) -> None: """ :keyword error: Error definition. :paramtype error: ~azure.mgmt.policyinsights.models.QueryFailureError @@ -2704,11 +2800,11 @@ class QueryFailureError(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.code = None - self.message = None + self.code: Optional[str] = None + self.message: Optional[str] = None class QueryOptions(_serialization.Model): @@ -2769,8 +2865,8 @@ def __init__( apply: Optional[str] = None, skip_token: Optional[str] = None, expand: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword top: Maximum number of records to return. :paramtype top: int @@ -2810,7 +2906,7 @@ def __init__( self.expand = expand -class Remediation(_serialization.Model): # pylint: disable=too-many-instance-attributes +class Remediation(_serialization.Model): """The remediation definition. Variables are only populated by the server, and will be ignored when sending a request. @@ -2835,7 +2931,9 @@ class Remediation(_serialization.Model): # pylint: disable=too-many-instance-at "ReEvaluateCompliance". :vartype resource_discovery_mode: str or ~azure.mgmt.policyinsights.models.ResourceDiscoveryMode - :ivar provisioning_state: The status of the remediation. + :ivar provisioning_state: The status of the remediation. This refers to the entire remediation + task, not individual deployments. Allowed values are Evaluating, Canceled, Cancelling, Failed, + Complete, or Succeeded. :vartype provisioning_state: str :ivar created_on: The time at which the remediation was created. :vartype created_on: ~datetime.datetime @@ -2907,8 +3005,8 @@ def __init__( resource_count: Optional[int] = None, parallel_deployments: Optional[int] = None, failure_threshold: Optional["_models.RemediationPropertiesFailureThreshold"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword policy_assignment_id: The resource ID of the policy assignment that should be remediated. @@ -2936,20 +3034,20 @@ def __init__( ~azure.mgmt.policyinsights.models.RemediationPropertiesFailureThreshold """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.system_data = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None + self.system_data: Optional["_models.SystemData"] = None self.policy_assignment_id = policy_assignment_id self.policy_definition_reference_id = policy_definition_reference_id self.resource_discovery_mode = resource_discovery_mode - self.provisioning_state = None - self.created_on = None - self.last_updated_on = None + self.provisioning_state: Optional[str] = None + self.created_on: Optional[datetime.datetime] = None + self.last_updated_on: Optional[datetime.datetime] = None self.filters = filters - self.deployment_status = None - self.status_message = None - self.correlation_id = None + self.deployment_status: Optional["_models.RemediationDeploymentSummary"] = None + self.status_message: Optional[str] = None + self.correlation_id: Optional[str] = None self.resource_count = resource_count self.parallel_deployments = parallel_deployments self.failure_threshold = failure_threshold @@ -2997,16 +3095,16 @@ class RemediationDeployment(_serialization.Model): "last_updated_on": {"key": "lastUpdatedOn", "type": "iso-8601"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.remediated_resource_id = None - self.deployment_id = None - self.status = None - self.resource_location = None - self.error = None - self.created_on = None - self.last_updated_on = None + self.remediated_resource_id: Optional[str] = None + self.deployment_id: Optional[str] = None + self.status: Optional[str] = None + self.resource_location: Optional[str] = None + self.error: Optional["_models.ErrorDefinition"] = None + self.created_on: Optional[datetime.datetime] = None + self.last_updated_on: Optional[datetime.datetime] = None class RemediationDeploymentsListResult(_serialization.Model): @@ -3030,11 +3128,11 @@ class RemediationDeploymentsListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[List["_models.RemediationDeployment"]] = None + self.next_link: Optional[str] = None class RemediationDeploymentSummary(_serialization.Model): @@ -3064,12 +3162,12 @@ class RemediationDeploymentSummary(_serialization.Model): "failed_deployments": {"key": "failedDeployments", "type": "int"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.total_deployments = None - self.successful_deployments = None - self.failed_deployments = None + self.total_deployments: Optional[int] = None + self.successful_deployments: Optional[int] = None + self.failed_deployments: Optional[int] = None class RemediationFilters(_serialization.Model): @@ -3077,19 +3175,31 @@ class RemediationFilters(_serialization.Model): :ivar locations: The resource locations that will be remediated. :vartype locations: list[str] + :ivar resource_ids: The IDs of the resources that will be remediated. Can specify at most 100 + IDs. This filter cannot be used when ReEvaluateCompliance is set to ReEvaluateCompliance, and + cannot be empty if provided. + :vartype resource_ids: list[str] """ _attribute_map = { "locations": {"key": "locations", "type": "[str]"}, + "resource_ids": {"key": "resourceIds", "type": "[str]"}, } - def __init__(self, *, locations: Optional[List[str]] = None, **kwargs): + def __init__( + self, *, locations: Optional[List[str]] = None, resource_ids: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword locations: The resource locations that will be remediated. :paramtype locations: list[str] + :keyword resource_ids: The IDs of the resources that will be remediated. Can specify at most + 100 IDs. This filter cannot be used when ReEvaluateCompliance is set to ReEvaluateCompliance, + and cannot be empty if provided. + :paramtype resource_ids: list[str] """ super().__init__(**kwargs) self.locations = locations + self.resource_ids = resource_ids class RemediationListResult(_serialization.Model): @@ -3113,11 +3223,11 @@ class RemediationListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.value: Optional[List["_models.Remediation"]] = None + self.next_link: Optional[str] = None class RemediationPropertiesFailureThreshold(_serialization.Model): @@ -3133,7 +3243,7 @@ class RemediationPropertiesFailureThreshold(_serialization.Model): "percentage": {"key": "percentage", "type": "float"}, } - def __init__(self, *, percentage: Optional[float] = None, **kwargs): + def __init__(self, *, percentage: Optional[float] = None, **kwargs: Any) -> None: """ :keyword percentage: A number between 0.0 to 1.0 representing the percentage failure threshold. The remediation will fail if the percentage of failed remediation operations (i.e. failed @@ -3193,18 +3303,18 @@ class SlimPolicyMetadata(_serialization.Model): "metadata": {"key": "properties.metadata", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.metadata_id = None - self.category = None - self.title = None - self.owner = None - self.additional_content_url = None - self.metadata = None + self.id: Optional[str] = None + self.type: Optional[str] = None + self.name: Optional[str] = None + self.metadata_id: Optional[str] = None + self.category: Optional[str] = None + self.title: Optional[str] = None + self.owner: Optional[str] = None + self.additional_content_url: Optional[str] = None + self.metadata: Optional[JSON] = None class SummarizeResults(_serialization.Model): @@ -3236,8 +3346,8 @@ def __init__( odata_context: Optional[str] = None, odata_count: Optional[int] = None, value: Optional[List["_models.Summary"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword odata_context: OData context string; used by OData clients to resolve type information based on metadata. @@ -3282,8 +3392,8 @@ def __init__( odata_context: Optional[str] = None, results: Optional["_models.SummaryResults"] = None, policy_assignments: Optional[List["_models.PolicyAssignmentSummary"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword odata_id: OData entity ID; always set to null since summaries do not have an entity ID. @@ -3347,8 +3457,8 @@ def __init__( resource_details: Optional[List["_models.ComplianceDetail"]] = None, policy_details: Optional[List["_models.ComplianceDetail"]] = None, policy_group_details: Optional[List["_models.ComplianceDetail"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword query_results_uri: HTTP POST URI for queryResults action on Microsoft.PolicyInsights to retrieve raw results for the compliance summary. This property will not be available by @@ -3413,8 +3523,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -3466,12 +3576,12 @@ class TrackedResourceModificationDetails(_serialization.Model): "deployment_time": {"key": "deploymentTime", "type": "iso-8601"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.policy_details = None - self.deployment_id = None - self.deployment_time = None + self.policy_details: Optional["_models.PolicyDetails"] = None + self.deployment_id: Optional[str] = None + self.deployment_time: Optional[datetime.datetime] = None class TypedErrorInfo(_serialization.Model): @@ -3495,8 +3605,8 @@ class TypedErrorInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.type = None - self.info = None + self.type: Optional[str] = None + self.info: Optional[Any] = None 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 c327e4726fe2..2cad8c4247c5 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 @@ -13,12 +13,12 @@ class ComplianceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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. + """The resource is in compliance with the policy.""" NON_COMPLIANT = "NonCompliant" - #: The compliance state of the resource is not known. + """The resource is not in compliance with the policy.""" UNKNOWN = "Unknown" + """The compliance state of the resource is not known.""" class ComponentPolicyStatesResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -39,12 +39,14 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): class FieldRestrictionResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of restriction that is imposed on the field.""" - #: The field and/or values are required by policy. REQUIRED = "Required" - #: The field will be removed by policy. + """The field and/or values are required by policy.""" REMOVED = "Removed" - #: The field and/or values will be denied by policy. + """The field will be removed by policy.""" DENY = "Deny" + """The field and/or values will be denied by policy.""" + AUDIT = "Audit" + """The field and/or values will be audited by policy.""" class PolicyEventsResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -77,8 +79,8 @@ class ResourceDiscoveryMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): specified. """ - #: 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. + """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. The resourceIds filter cannot be used in this mode.""" 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 0471b79db988..4ff80dcf0f86 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 @@ -5,19 +5,25 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position -from ._policy_tracked_resources_operations import PolicyTrackedResourcesOperations -from ._remediations_operations import RemediationsOperations -from ._policy_events_operations import PolicyEventsOperations -from ._policy_states_operations import PolicyStatesOperations -from ._policy_metadata_operations import PolicyMetadataOperations -from ._policy_restrictions_operations import PolicyRestrictionsOperations -from ._component_policy_states_operations import ComponentPolicyStatesOperations -from ._operations import Operations -from ._attestations_operations import AttestationsOperations +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._policy_tracked_resources_operations import PolicyTrackedResourcesOperations # type: ignore +from ._remediations_operations import RemediationsOperations # type: ignore +from ._policy_events_operations import PolicyEventsOperations # type: ignore +from ._policy_states_operations import PolicyStatesOperations # type: ignore +from ._policy_metadata_operations import PolicyMetadataOperations # type: ignore +from ._policy_restrictions_operations import PolicyRestrictionsOperations # type: ignore +from ._component_policy_states_operations import ComponentPolicyStatesOperations # type: ignore +from ._operations import Operations # type: ignore +from ._attestations_operations import AttestationsOperations # type: ignore from ._patch import __all__ as _patch_all -from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ @@ -31,5 +37,5 @@ "Operations", "AttestationsOperations", ] -__all__.extend([p for p in _patch_all if p not in __all__]) +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 index dec1033e723e..a26e5b329cae 100644 --- 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,35 +6,34 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +47,7 @@ def build_list_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,7 +56,7 @@ def build_list_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -72,13 +71,13 @@ def build_list_for_subscription_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_subscription_request( +def build_create_or_update_at_subscription_request( # pylint: disable=name-too-long attestation_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -86,13 +85,13 @@ def build_create_or_update_at_subscription_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -109,20 +108,20 @@ def build_get_at_subscription_request(attestation_name: str, subscription_id: st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,20 +136,20 @@ def build_delete_at_subscription_request(attestation_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,14 +171,14 @@ def build_list_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -187,7 +186,7 @@ def build_list_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -202,13 +201,13 @@ def build_list_for_resource_group_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_resource_group_request( +def build_create_or_update_at_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, attestation_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -216,7 +215,7 @@ def build_create_or_update_at_resource_group_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -225,7 +224,7 @@ def build_create_or_update_at_resource_group_request( "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -244,14 +243,14 @@ def build_get_at_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -260,7 +259,7 @@ def build_get_at_resource_group_request( "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -277,14 +276,14 @@ def build_delete_at_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -293,7 +292,7 @@ def build_delete_at_resource_group_request( "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -310,7 +309,7 @@ def build_list_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -319,7 +318,7 @@ def build_list_for_resource_request( "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -334,11 +333,13 @@ def build_list_for_resource_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_resource_request(resource_id: str, attestation_name: str, **kwargs: Any) -> HttpRequest: +def build_create_or_update_at_resource_request( # pylint: disable=name-too-long + resource_id: str, attestation_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -349,7 +350,7 @@ def build_create_or_update_at_resource_request(resource_id: str, attestation_nam "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -366,7 +367,7 @@ def build_get_at_resource_request(resource_id: str, attestation_name: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -376,7 +377,7 @@ def build_get_at_resource_request(resource_id: str, attestation_name: str, **kwa "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -391,7 +392,7 @@ def build_delete_at_resource_request(resource_id: str, attestation_name: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -401,7 +402,7 @@ def build_delete_at_resource_request(resource_id: str, attestation_name: str, ** "attestationName": _SERIALIZER.url("attestation_name", attestation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -424,22 +425,21 @@ class AttestationsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_for_subscription( self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Attestation"]: + ) -> ItemPaged["_models.Attestation"]: """Gets all attestations for the subscription. :param query_options: Parameter group. Default value is None. :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 Attestation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -447,10 +447,10 @@ def list_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.AttestationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,24 +466,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AttestationListResult", pipeline_response) @@ -493,10 +490,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -509,14 +507,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations" - } - - def _create_or_update_at_subscription_initial( - self, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any - ) -> _models.Attestation: - error_map = { + def _create_or_update_at_subscription_initial( # pylint: disable=name-too-long + self, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,58 +521,54 @@ def _create_or_update_at_subscription_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Attestation") - request = build_create_or_update_at_subscription_request( + _request = build_create_or_update_at_subscription_request( attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_at_subscription_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_at_subscription_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } - @overload def begin_create_or_update_at_subscription( self, @@ -597,14 +587,6 @@ def begin_create_or_update_at_subscription( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -613,25 +595,17 @@ def begin_create_or_update_at_subscription( @overload def begin_create_or_update_at_subscription( - self, attestation_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, attestation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.Attestation]: """Creates or updates an attestation at subscription scope. :param attestation_name: The name of the attestation. Required. :type attestation_name: str :param parameters: The attestation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -640,25 +614,15 @@ def begin_create_or_update_at_subscription( @distributed_trace def begin_create_or_update_at_subscription( - self, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any + self, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Attestation]: """Creates or updates an attestation at subscription scope. :param attestation_name: The name of the attestation. Required. :type attestation_name: str - :param parameters: The attestation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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: 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. + :param parameters: The attestation parameters. Is either a Attestation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO[bytes] :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] @@ -667,7 +631,7 @@ def begin_create_or_update_at_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -684,12 +648,13 @@ def begin_create_or_update_at_subscription( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -699,17 +664,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Attestation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return LROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.Attestation: @@ -717,12 +680,11 @@ def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.A :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -733,22 +695,21 @@ def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) - request = build_get_at_subscription_request( + _request = build_get_at_subscription_request( attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -758,16 +719,12 @@ def get_at_subscription(self, attestation_name: str, **kwargs: Any) -> _models.A error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_subscription( # pylint: disable=inconsistent-return-statements @@ -777,12 +734,11 @@ def delete_at_subscription( # pylint: disable=inconsistent-return-statements :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -793,22 +749,21 @@ def delete_at_subscription( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_at_subscription_request( + _request = build_delete_at_subscription_request( attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -819,16 +774,12 @@ def delete_at_subscription( # pylint: disable=inconsistent-return-statements 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}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_resource_group( self, resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Attestation"]: + ) -> ItemPaged["_models.Attestation"]: """Gets all attestations for the resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -836,7 +787,6 @@ def list_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 Attestation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -844,10 +794,10 @@ def list_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.AttestationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,25 +813,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AttestationListResult", pipeline_response) @@ -891,10 +838,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -907,14 +855,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations" - } - - def _create_or_update_at_resource_group_initial( - self, resource_group_name: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any - ) -> _models.Attestation: - error_map = { + def _create_or_update_at_resource_group_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -925,19 +873,19 @@ def _create_or_update_at_resource_group_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Attestation") - request = build_create_or_update_at_resource_group_request( + _request = build_create_or_update_at_resource_group_request( resource_group_name=resource_group_name, attestation_name=attestation_name, subscription_id=self._config.subscription_id, @@ -945,39 +893,35 @@ def _create_or_update_at_resource_group_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_at_resource_group_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_at_resource_group_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } - @overload def begin_create_or_update_at_resource_group( self, @@ -1000,14 +944,6 @@ def begin_create_or_update_at_resource_group( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -1019,7 +955,7 @@ def begin_create_or_update_at_resource_group( self, resource_group_name: str, attestation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1032,18 +968,10 @@ def begin_create_or_update_at_resource_group( :param attestation_name: The name of the attestation. Required. :type attestation_name: str :param parameters: The attestation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -1052,7 +980,11 @@ def begin_create_or_update_at_resource_group( @distributed_trace def begin_create_or_update_at_resource_group( - self, resource_group_name: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any + self, + resource_group_name: str, + attestation_name: str, + parameters: Union[_models.Attestation, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.Attestation]: """Creates or updates an attestation at resource group scope. @@ -1061,19 +993,9 @@ def begin_create_or_update_at_resource_group( :type resource_group_name: str :param attestation_name: The name of the attestation. Required. :type attestation_name: str - :param parameters: The attestation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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: 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. + :param parameters: The attestation parameters. Is either a Attestation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO[bytes] :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] @@ -1082,7 +1004,7 @@ def begin_create_or_update_at_resource_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1100,12 +1022,13 @@ def begin_create_or_update_at_resource_group( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1115,17 +1038,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Attestation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return LROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get_at_resource_group( @@ -1138,12 +1059,11 @@ def get_at_resource_group( :type resource_group_name: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1154,23 +1074,22 @@ def get_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) - request = build_get_at_resource_group_request( + _request = build_get_at_resource_group_request( resource_group_name=resource_group_name, attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1180,16 +1099,12 @@ def get_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_resource_group( # pylint: disable=inconsistent-return-statements @@ -1202,12 +1117,11 @@ def delete_at_resource_group( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1218,23 +1132,22 @@ def delete_at_resource_group( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_at_resource_group_request( + _request = build_delete_at_resource_group_request( resource_group_name=resource_group_name, attestation_name=attestation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1245,23 +1158,18 @@ def delete_at_resource_group( # pylint: disable=inconsistent-return-statements 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}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_for_resource( self, resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Attestation"]: + ) -> ItemPaged["_models.Attestation"]: """Gets all attestations for a resource. :param resource_id: Resource ID. Required. :type resource_id: str :param query_options: Parameter group. Default value is None. :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 Attestation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -1269,10 +1177,10 @@ def list_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.AttestationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1288,24 +1196,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_id=resource_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("AttestationListResult", pipeline_response) @@ -1315,10 +1220,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1331,12 +1237,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = {"url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations"} - def _create_or_update_at_resource_initial( - self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any - ) -> _models.Attestation: - error_map = { + self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1347,58 +1251,54 @@ def _create_or_update_at_resource_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Attestation") - request = build_create_or_update_at_resource_request( + _request = build_create_or_update_at_resource_request( resource_id=resource_id, attestation_name=attestation_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_at_resource_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_at_resource_initial.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } - @overload def begin_create_or_update_at_resource( self, @@ -1420,14 +1320,6 @@ def begin_create_or_update_at_resource( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -1439,7 +1331,7 @@ def begin_create_or_update_at_resource( self, resource_id: str, attestation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1451,18 +1343,10 @@ def begin_create_or_update_at_resource( :param attestation_name: The name of the attestation. Required. :type attestation_name: str :param parameters: The attestation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: 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: 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] @@ -1471,7 +1355,7 @@ def begin_create_or_update_at_resource( @distributed_trace def begin_create_or_update_at_resource( - self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO], **kwargs: Any + self, resource_id: str, attestation_name: str, parameters: Union[_models.Attestation, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Attestation]: """Creates or updates an attestation at resource scope. @@ -1479,19 +1363,9 @@ def begin_create_or_update_at_resource( :type resource_id: str :param attestation_name: The name of the attestation. Required. :type attestation_name: str - :param parameters: The attestation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: 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: 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. + :param parameters: The attestation parameters. Is either a Attestation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Attestation or IO[bytes] :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] @@ -1500,7 +1374,7 @@ def begin_create_or_update_at_resource( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -1518,12 +1392,13 @@ def begin_create_or_update_at_resource( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1533,17 +1408,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Attestation].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return LROPoller[_models.Attestation]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any) -> _models.Attestation: @@ -1553,12 +1426,11 @@ def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any :type resource_id: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1569,22 +1441,21 @@ def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Attestation] = kwargs.pop("cls", None) - request = build_get_at_resource_request( + _request = build_get_at_resource_request( resource_id=resource_id, attestation_name=attestation_name, api_version=api_version, - template_url=self.get_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1594,16 +1465,12 @@ def get_at_resource(self, resource_id: str, attestation_name: str, **kwargs: Any error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Attestation", pipeline_response) + deserialized = self._deserialize("Attestation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/attestations/{attestationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_resource( # pylint: disable=inconsistent-return-statements @@ -1615,12 +1482,11 @@ def delete_at_resource( # pylint: disable=inconsistent-return-statements :type resource_id: str :param attestation_name: The name of the attestation. Required. :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: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1631,22 +1497,21 @@ def delete_at_resource( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_at_resource_request( + _request = build_delete_at_resource_request( resource_id=resource_id, attestation_name=attestation_name, api_version=api_version, - template_url=self.delete_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1657,8 +1522,4 @@ def delete_at_resource( # pylint: disable=inconsistent-return-statements 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}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_component_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_component_policy_states_operations.py index f3c51adf7680..0e106ad9e179 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_component_policy_states_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_component_policy_states_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime -import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,20 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +36,7 @@ _SERIALIZER.client_side_validation = False -def build_list_query_results_for_subscription_request( +def build_list_query_results_for_subscription_request( # pylint: disable=name-too-long subscription_id: str, component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], *, @@ -56,14 +52,14 @@ def build_list_query_results_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "componentPolicyStatesResource": _SERIALIZER.url( @@ -71,7 +67,7 @@ def build_list_query_results_for_subscription_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +92,7 @@ def build_list_query_results_for_subscription_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_request( +def build_list_query_results_for_resource_group_request( # pylint: disable=name-too-long subscription_id: str, resource_group_name: str, component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], @@ -113,14 +109,14 @@ def build_list_query_results_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -129,7 +125,7 @@ def build_list_query_results_for_resource_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +150,7 @@ def build_list_query_results_for_resource_group_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_request( +def build_list_query_results_for_resource_request( # pylint: disable=name-too-long resource_id: str, component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], *, @@ -171,14 +167,14 @@ def build_list_query_results_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), "componentPolicyStatesResource": _SERIALIZER.url( @@ -186,7 +182,7 @@ def build_list_query_results_for_resource_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -213,7 +209,7 @@ def build_list_query_results_for_resource_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_policy_definition_request( +def build_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long subscription_id: str, policy_definition_name: str, component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], @@ -233,14 +229,14 @@ def build_list_query_results_for_policy_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), @@ -257,7 +253,7 @@ def build_list_query_results_for_policy_definition_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -282,7 +278,7 @@ def build_list_query_results_for_policy_definition_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_subscription_level_policy_assignment_request( +def build_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long subscription_id: str, policy_assignment_name: str, component_policy_states_resource: Union[str, _models.ComponentPolicyStatesResource], @@ -302,14 +298,14 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "authorizationNamespace": _SERIALIZER.url("authorization_namespace", authorization_namespace, "str"), @@ -326,7 +322,7 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -351,7 +347,7 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_level_policy_assignment_request( +def build_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long subscription_id: str, resource_group_name: str, policy_assignment_name: str, @@ -372,14 +368,14 @@ def build_list_query_results_for_resource_group_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), @@ -397,7 +393,7 @@ def build_list_query_results_for_resource_group_level_policy_assignment_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -434,12 +430,12 @@ class ComponentPolicyStatesOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_subscription( @@ -483,12 +479,11 @@ def list_query_results_for_subscription( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,10 +494,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( subscription_id=subscription_id, component_policy_states_resource=component_policy_states_resource, top=top, @@ -513,15 +508,14 @@ def list_query_results_for_subscription( filter=filter, apply=apply, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -531,16 +525,12 @@ def list_query_results_for_subscription( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_resource_group( @@ -587,12 +577,11 @@ def list_query_results_for_resource_group( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -603,10 +592,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( subscription_id=subscription_id, resource_group_name=resource_group_name, component_policy_states_resource=component_policy_states_resource, @@ -618,15 +607,14 @@ def list_query_results_for_resource_group( filter=filter, apply=apply, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -636,16 +624,12 @@ def list_query_results_for_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_resource( @@ -692,12 +676,11 @@ def list_query_results_for_resource( :type apply: str :param expand: The $expand query parameter. Default value is None. :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -708,10 +691,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( resource_id=resource_id, component_policy_states_resource=component_policy_states_resource, top=top, @@ -723,15 +706,14 @@ def list_query_results_for_resource( apply=apply, expand=expand, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -741,16 +723,12 @@ def list_query_results_for_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_policy_definition( @@ -797,16 +775,11 @@ def list_query_results_for_policy_definition( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -820,10 +793,10 @@ def list_query_results_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_policy_definition_request( + _request = build_list_query_results_for_policy_definition_request( subscription_id=subscription_id, policy_definition_name=policy_definition_name, component_policy_states_resource=component_policy_states_resource, @@ -836,15 +809,14 @@ def list_query_results_for_policy_definition( apply=apply, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -854,19 +826,15 @@ def list_query_results_for_policy_definition( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_query_results_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, subscription_id: str, policy_assignment_name: str, @@ -910,16 +878,11 @@ def list_query_results_for_subscription_level_policy_assignment( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -933,10 +896,10 @@ def list_query_results_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_subscription_level_policy_assignment_request( + _request = build_list_query_results_for_subscription_level_policy_assignment_request( subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, component_policy_states_resource=component_policy_states_resource, @@ -949,15 +912,14 @@ def list_query_results_for_subscription_level_policy_assignment( apply=apply, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -967,19 +929,15 @@ def list_query_results_for_subscription_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_query_results_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # type: ignore @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, subscription_id: str, resource_group_name: str, @@ -1026,16 +984,11 @@ def list_query_results_for_resource_group_level_policy_assignment( :type filter: str :param apply: OData apply expression for aggregations. Default value is None. :type apply: str - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ComponentPolicyStatesQueryResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.ComponentPolicyStatesQueryResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1049,10 +1002,10 @@ def list_query_results_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.ComponentPolicyStatesQueryResults] = kwargs.pop("cls", None) - request = build_list_query_results_for_resource_group_level_policy_assignment_request( + _request = build_list_query_results_for_resource_group_level_policy_assignment_request( subscription_id=subscription_id, resource_group_name=resource_group_name, policy_assignment_name=policy_assignment_name, @@ -1066,15 +1019,14 @@ def list_query_results_for_resource_group_level_policy_assignment( apply=apply, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1084,13 +1036,9 @@ def list_query_results_for_resource_group_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response) + deserialized = self._deserialize("ComponentPolicyStatesQueryResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_query_results_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/componentPolicyStates/{componentPolicyStatesResource}/queryResults" - } + return deserialized # 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 3c8442baf3f1..46d6aa3f01f5 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from collections.abc import MutableMapping from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,20 +18,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +38,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,23 +65,22 @@ class Operations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list(self, **kwargs: Any) -> _models.OperationsListResults: """Lists available operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationsListResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.OperationsListResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,20 +91,19 @@ def list(self, **kwargs: Any) -> _models.OperationsListResults: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.OperationsListResults] = kwargs.pop("cls", None) - request = build_list_request( + _request = build_list_request( api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,11 +113,9 @@ def list(self, **kwargs: Any) -> _models.OperationsListResults: error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("OperationsListResults", pipeline_response) + deserialized = self._deserialize("OperationsListResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.PolicyInsights/operations"} + return deserialized # type: ignore 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 4543dcf2d14b..a7252135c4c7 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -20,20 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +37,7 @@ _SERIALIZER.client_side_validation = False -def build_list_query_results_for_management_group_request( +def build_list_query_results_for_management_group_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], management_group_name: str, *, @@ -61,21 +57,21 @@ def build_list_query_results_for_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,7 +102,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +111,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,7 +124,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_subscription_request( +def build_list_query_results_for_subscription_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, *, @@ -145,20 +141,20 @@ def build_list_query_results_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,7 +185,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -198,7 +194,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,7 +207,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_request( +def build_list_query_results_for_resource_group_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, resource_group_name: str, @@ -229,21 +225,21 @@ def build_list_query_results_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -274,7 +270,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -283,7 +279,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -296,7 +292,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_request( +def build_list_query_results_for_resource_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], resource_id: str, *, @@ -314,20 +310,20 @@ def build_list_query_results_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -360,7 +356,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -369,7 +365,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -382,7 +378,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_policy_set_definition_request( +def build_list_query_results_for_policy_set_definition_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_set_definition_name: str, @@ -403,14 +399,14 @@ def build_list_query_results_for_policy_set_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -418,7 +414,7 @@ def build_list_query_results_for_policy_set_definition_request( "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -449,7 +445,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -458,7 +454,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -471,7 +467,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_policy_definition_request( +def build_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_definition_name: str, @@ -492,14 +488,14 @@ def build_list_query_results_for_policy_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -507,7 +503,7 @@ def build_list_query_results_for_policy_definition_request( "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -538,7 +534,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -547,7 +543,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -560,7 +556,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_subscription_level_policy_assignment_request( +def build_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_assignment_name: str, @@ -581,14 +577,14 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -596,7 +592,7 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -627,7 +623,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -636,7 +632,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -649,7 +645,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_level_policy_assignment_request( +def build_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, resource_group_name: str, @@ -671,14 +667,14 @@ def build_list_query_results_for_resource_group_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyEventsResource": _SERIALIZER.url("policy_events_resource", policy_events_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -687,7 +683,7 @@ def build_list_query_results_for_resource_group_level_policy_assignment_request( "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -718,7 +714,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -727,7 +723,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -752,12 +748,12 @@ class PolicyEventsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_management_group( @@ -766,7 +762,7 @@ def list_query_results_for_management_group( management_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the resources under the management group. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -776,11 +772,6 @@ def list_query_results_for_management_group( :type management_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -791,10 +782,10 @@ def list_query_results_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -822,7 +813,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_management_group_request( + _request = build_list_query_results_for_management_group_request( policy_events_resource=policy_events_resource, management_group_name=management_group_name, top=_top, @@ -835,12 +826,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_query_results_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -861,18 +850,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -882,10 +869,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -898,10 +886,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_subscription( self, @@ -909,7 +893,7 @@ def list_query_results_for_subscription( subscription_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the resources under the subscription. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -919,7 +903,6 @@ def list_query_results_for_subscription( :type subscription_id: str :param query_options: Parameter group. Default value is None. :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 PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -927,10 +910,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +941,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, top=_top, @@ -970,12 +953,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -996,18 +977,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1017,10 +996,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1033,10 +1013,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource_group( self, @@ -1045,7 +1021,7 @@ def list_query_results_for_resource_group( resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the resources under the resource group. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1057,7 +1033,6 @@ def list_query_results_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1065,10 +1040,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1096,7 +1071,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -1109,12 +1084,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1135,18 +1108,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1156,10 +1127,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1172,10 +1144,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource( self, @@ -1183,7 +1151,7 @@ def list_query_results_for_resource( resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the resource. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1193,7 +1161,6 @@ def list_query_results_for_resource( :type resource_id: str :param query_options: Parameter group. Default value is None. :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 PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1201,10 +1168,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1234,7 +1201,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( policy_events_resource=policy_events_resource, resource_id=resource_id, top=_top, @@ -1247,12 +1214,10 @@ def prepare_request(next_link=None): expand=_expand, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1275,18 +1240,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1296,10 +1259,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1312,19 +1276,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace - def list_query_results_for_policy_set_definition( + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long self, policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_set_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the subscription level policy set definition. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1336,11 +1296,6 @@ def list_query_results_for_policy_set_definition( :type policy_set_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1351,10 +1306,10 @@ def list_query_results_for_policy_set_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1382,7 +1337,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_set_definition_request( + _request = build_list_query_results_for_policy_set_definition_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, policy_set_definition_name=policy_set_definition_name, @@ -1396,12 +1351,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_set_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1422,18 +1375,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1443,10 +1394,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1459,10 +1411,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_policy_set_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace def list_query_results_for_policy_definition( self, @@ -1471,7 +1419,7 @@ def list_query_results_for_policy_definition( policy_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the subscription level policy definition. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1483,11 +1431,6 @@ def list_query_results_for_policy_definition( :type policy_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1498,10 +1441,10 @@ def list_query_results_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1529,7 +1472,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_definition_request( + _request = build_list_query_results_for_policy_definition_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, policy_definition_name=policy_definition_name, @@ -1543,12 +1486,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1569,18 +1510,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1590,10 +1529,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1606,19 +1546,15 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the subscription level policy assignment. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1630,11 +1566,6 @@ def list_query_results_for_subscription_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1645,10 +1576,10 @@ def list_query_results_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1676,7 +1607,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_level_policy_assignment_request( + _request = build_list_query_results_for_subscription_level_policy_assignment_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, @@ -1690,12 +1621,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1716,18 +1645,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1737,10 +1664,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1753,12 +1681,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } - @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, policy_events_resource: Union[str, _models.PolicyEventsResourceType], subscription_id: str, @@ -1766,7 +1690,7 @@ def list_query_results_for_resource_group_level_policy_assignment( policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyEvent"]: + ) -> ItemPaged["_models.PolicyEvent"]: """Queries policy events for the resource group level policy assignment. :param policy_events_resource: The name of the virtual resource under PolicyEvents resource @@ -1780,11 +1704,6 @@ def list_query_results_for_resource_group_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyEvent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyEvent] :raises ~azure.core.exceptions.HttpResponseError: @@ -1795,10 +1714,10 @@ def list_query_results_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyEventsQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,7 +1745,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_level_policy_assignment_request( + _request = build_list_query_results_for_resource_group_level_policy_assignment_request( policy_events_resource=policy_events_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -1841,12 +1760,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1867,18 +1784,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyEventsQueryResults", pipeline_response) @@ -1888,10 +1803,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1903,7 +1819,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_query_results_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults" - } 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 d90da636026f..8e9db59eb497 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 @@ -1,4 +1,3 @@ -# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +5,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Optional, TypeVar +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,20 +19,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +39,7 @@ def build_get_resource_request(resource_name: str, **kwargs: Any) -> HttpRequest _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +48,7 @@ def build_get_resource_request(resource_name: str, **kwargs: Any) -> HttpRequest "resourceName": _SERIALIZER.url("resource_name", resource_name, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,7 +63,7 @@ def build_list_request(*, top: Optional[int] = None, **kwargs: Any) -> HttpReque _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,12 +92,12 @@ class PolicyMetadataOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetadata: @@ -110,12 +105,11 @@ def get_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetad :param resource_name: The name of the policy metadata resource. Required. :type resource_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PolicyMetadata or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.PolicyMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,21 +120,20 @@ def get_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetad _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyMetadata] = kwargs.pop("cls", None) - request = build_get_resource_request( + _request = build_get_resource_request( resource_name=resource_name, api_version=api_version, - template_url=self.get_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,24 +143,21 @@ def get_resource(self, resource_name: str, **kwargs: Any) -> _models.PolicyMetad error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("PolicyMetadata", pipeline_response) + deserialized = self._deserialize("PolicyMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_resource.metadata = {"url": "/providers/Microsoft.PolicyInsights/policyMetadata/{resourceName}"} + return deserialized # type: ignore @distributed_trace def list( self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.SlimPolicyMetadata"]: + ) -> ItemPaged["_models.SlimPolicyMetadata"]: """Get a list of the policy metadata resources. :param query_options: Parameter group. Default value is None. :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 SlimPolicyMetadata or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.SlimPolicyMetadata] :raises ~azure.core.exceptions.HttpResponseError: @@ -175,10 +165,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyMetadataCollection] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,22 +182,19 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_request( + _request = build_list_request( top=_top, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyMetadataCollection", pipeline_response) @@ -217,10 +204,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,5 +220,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.PolicyInsights/policyMetadata"} 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 c362a36a53ff..b9ebd2b44da6 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -18,20 +20,15 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,23 +36,25 @@ _SERIALIZER.client_side_validation = False -def build_check_at_subscription_scope_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_check_at_subscription_scope_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,13 +67,13 @@ def build_check_at_subscription_scope_request(subscription_id: str, **kwargs: An return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_at_resource_group_scope_request( +def build_check_at_resource_group_scope_request( # pylint: disable=name-too-long resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -82,7 +81,7 @@ def build_check_at_resource_group_scope_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url( @@ -90,7 +89,7 @@ def build_check_at_resource_group_scope_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,14 +102,16 @@ def build_check_at_resource_group_scope_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_at_management_group_scope_request(management_group_id: str, **kwargs: Any) -> HttpRequest: +def build_check_at_management_group_scope_request( # pylint: disable=name-too-long + management_group_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -118,13 +119,13 @@ def build_check_at_management_group_scope_request(management_group_id: str, **kw _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -149,12 +150,12 @@ class PolicyRestrictionsOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @overload def check_at_subscription_scope( @@ -167,7 +168,6 @@ def check_at_subscription_scope( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -175,16 +175,15 @@ def check_at_subscription_scope( @overload def check_at_subscription_scope( - self, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on a resource within a subscription. :param parameters: The check policy restrictions parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -192,22 +191,18 @@ def check_at_subscription_scope( @distributed_trace def check_at_subscription_scope( - self, parameters: Union[_models.CheckRestrictionsRequest, IO], **kwargs: Any + self, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on a resource within a subscription. - :param parameters: The check policy restrictions parameters. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The check policy restrictions parameters. Is either a + CheckRestrictionsRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,33 +213,32 @@ def check_at_subscription_scope( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckRestrictionsRequest") - request = build_check_at_subscription_scope_request( + _request = build_check_at_subscription_scope_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_at_subscription_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,16 +248,12 @@ def check_at_subscription_scope( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response) + deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_at_subscription_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - } + return deserialized # type: ignore @overload def check_at_resource_group_scope( @@ -285,7 +275,6 @@ def check_at_resource_group_scope( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -293,7 +282,7 @@ def check_at_resource_group_scope( @overload def check_at_resource_group_scope( - self, resource_group_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, resource_group_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **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. @@ -302,11 +291,10 @@ def check_at_resource_group_scope( Required. :type resource_group_name: str :param parameters: The check policy restrictions parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -314,7 +302,7 @@ def check_at_resource_group_scope( @distributed_trace def check_at_resource_group_scope( - self, resource_group_name: str, parameters: Union[_models.CheckRestrictionsRequest, IO], **kwargs: Any + self, resource_group_name: str, parameters: Union[_models.CheckRestrictionsRequest, IO[bytes]], **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. @@ -322,18 +310,14 @@ def check_at_resource_group_scope( :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :param parameters: The check policy restrictions parameters. Is either a model type or a IO - type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The check policy restrictions parameters. Is either a + CheckRestrictionsRequest type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.CheckRestrictionsRequest or IO[bytes] :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,34 +328,33 @@ def check_at_resource_group_scope( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckRestrictionsRequest") - request = build_check_at_resource_group_scope_request( + _request = build_check_at_resource_group_scope_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_at_resource_group_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,16 +364,12 @@ def check_at_resource_group_scope( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response) + deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check_at_resource_group_scope.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - } + return deserialized # type: ignore @overload def check_at_management_group_scope( @@ -410,11 +389,6 @@ def check_at_management_group_scope( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -422,22 +396,17 @@ def check_at_management_group_scope( @overload def check_at_management_group_scope( - self, management_group_id: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, management_group_id: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on resources within a management group. :param management_group_id: Management group ID. Required. :type management_group_id: str :param parameters: The check policy restrictions parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: @@ -447,30 +416,22 @@ def check_at_management_group_scope( def check_at_management_group_scope( self, management_group_id: str, - parameters: Union[_models.CheckManagementGroupRestrictionsRequest, IO], + parameters: Union[_models.CheckManagementGroupRestrictionsRequest, IO[bytes]], **kwargs: Any ) -> _models.CheckRestrictionsResult: """Checks what restrictions Azure Policy will place on resources within a management group. :param management_group_id: Management group ID. Required. :type management_group_id: str - :param parameters: The check policy restrictions parameters. Is either a model type or a IO - type. Required. + :param parameters: The check policy restrictions parameters. Is either a + CheckManagementGroupRestrictionsRequest type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.policyinsights.models.CheckManagementGroupRestrictionsRequest or - IO - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + IO[bytes] :return: CheckRestrictionsResult or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.CheckRestrictionsResult :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,34 +445,33 @@ def check_at_management_group_scope( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2022-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.CheckRestrictionsResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckManagementGroupRestrictionsRequest") - request = build_check_at_management_group_scope_request( + _request = build_check_at_management_group_scope_request( management_group_id=management_group_id, management_groups_namespace=management_groups_namespace, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_at_management_group_scope.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -521,13 +481,9 @@ def check_at_management_group_scope( error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response) + deserialized = self._deserialize("CheckRestrictionsResult", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_at_management_group_scope.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/checkPolicyRestrictions" - } + return deserialized # type: ignore 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 4fd4449053ba..b95b72efb66d 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,36 +6,34 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from collections.abc import MutableMapping import datetime -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +from typing import Any, Callable, Dict, Iterator, Literal, Optional, TypeVar, Union, cast +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +41,7 @@ _SERIALIZER.client_side_validation = False -def build_list_query_results_for_management_group_request( +def build_list_query_results_for_management_group_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], management_group_name: str, *, @@ -63,21 +61,21 @@ def build_list_query_results_for_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +106,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +115,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +128,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_summarize_for_management_group_request( +def build_summarize_for_management_group_request( # pylint: disable=name-too-long policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], management_group_name: str, *, @@ -146,14 +144,14 @@ def build_summarize_for_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -162,7 +160,7 @@ def build_summarize_for_management_group_request( "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -181,7 +179,7 @@ def build_summarize_for_management_group_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_subscription_request( +def build_list_query_results_for_subscription_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, *, @@ -198,20 +196,20 @@ def build_list_query_results_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -242,7 +240,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +249,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -277,14 +275,14 @@ def build_summarize_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -292,7 +290,7 @@ def build_summarize_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -311,7 +309,7 @@ def build_summarize_for_subscription_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_request( +def build_list_query_results_for_resource_group_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, resource_group_name: str, @@ -329,21 +327,21 @@ def build_list_query_results_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -374,7 +372,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -383,7 +381,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -396,7 +394,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_summarize_for_resource_group_request( +def build_summarize_for_resource_group_request( # pylint: disable=name-too-long policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, resource_group_name: str, @@ -410,14 +408,14 @@ def build_summarize_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -426,7 +424,7 @@ def build_summarize_for_resource_group_request( "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -445,7 +443,7 @@ def build_summarize_for_resource_group_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_request( +def build_list_query_results_for_resource_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], resource_id: str, *, @@ -463,20 +461,20 @@ def build_list_query_results_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -509,7 +507,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -518,7 +516,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -544,14 +542,14 @@ def build_summarize_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -559,7 +557,7 @@ def build_summarize_for_resource_request( "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -578,23 +576,25 @@ def build_summarize_for_resource_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_trigger_subscription_evaluation_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_trigger_subscription_evaluation_request( # pylint: disable=name-too-long + subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -605,26 +605,26 @@ def build_trigger_subscription_evaluation_request(subscription_id: str, **kwargs return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_trigger_resource_group_evaluation_request( +def build_trigger_resource_group_evaluation_request( # pylint: disable=name-too-long subscription_id: str, resource_group_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -635,7 +635,7 @@ def build_trigger_resource_group_evaluation_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_policy_set_definition_request( +def build_list_query_results_for_policy_set_definition_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_set_definition_name: str, @@ -656,14 +656,14 @@ def build_list_query_results_for_policy_set_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -671,7 +671,7 @@ def build_list_query_results_for_policy_set_definition_request( "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -702,7 +702,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -711,7 +711,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -724,7 +724,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_summarize_for_policy_set_definition_request( +def build_summarize_for_policy_set_definition_request( # pylint: disable=name-too-long policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, policy_set_definition_name: str, @@ -741,14 +741,14 @@ def build_summarize_for_policy_set_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -758,7 +758,7 @@ def build_summarize_for_policy_set_definition_request( "policySetDefinitionName": _SERIALIZER.url("policy_set_definition_name", policy_set_definition_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -777,7 +777,7 @@ def build_summarize_for_policy_set_definition_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_policy_definition_request( +def build_list_query_results_for_policy_definition_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_definition_name: str, @@ -798,14 +798,14 @@ def build_list_query_results_for_policy_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -813,7 +813,7 @@ def build_list_query_results_for_policy_definition_request( "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -844,7 +844,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -853,7 +853,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -866,7 +866,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_summarize_for_policy_definition_request( +def build_summarize_for_policy_definition_request( # pylint: disable=name-too-long policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, policy_definition_name: str, @@ -883,14 +883,14 @@ def build_summarize_for_policy_definition_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -900,7 +900,7 @@ def build_summarize_for_policy_definition_request( "policyDefinitionName": _SERIALIZER.url("policy_definition_name", policy_definition_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -919,7 +919,7 @@ def build_summarize_for_policy_definition_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_subscription_level_policy_assignment_request( +def build_list_query_results_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_assignment_name: str, @@ -940,14 +940,14 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -955,7 +955,7 @@ def build_list_query_results_for_subscription_level_policy_assignment_request( "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -986,7 +986,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -995,7 +995,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1008,7 +1008,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_summarize_for_subscription_level_policy_assignment_request( +def build_summarize_for_subscription_level_policy_assignment_request( # pylint: disable=name-too-long policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, policy_assignment_name: str, @@ -1025,14 +1025,14 @@ def build_summarize_for_subscription_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -1042,7 +1042,7 @@ def build_summarize_for_subscription_level_policy_assignment_request( "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1061,7 +1061,7 @@ def build_summarize_for_subscription_level_policy_assignment_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_level_policy_assignment_request( +def build_list_query_results_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, resource_group_name: str, @@ -1083,14 +1083,14 @@ def build_list_query_results_for_resource_group_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesResource": _SERIALIZER.url("policy_states_resource", policy_states_resource, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), @@ -1099,7 +1099,7 @@ def build_list_query_results_for_resource_group_level_policy_assignment_request( "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1130,7 +1130,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1139,7 +1139,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, "nextLink": _SERIALIZER.url("next_link", next_link, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1152,7 +1152,7 @@ def build_next_link_request(next_link: str, *, skip_token: Optional[str] = None, return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_summarize_for_resource_group_level_policy_assignment_request( +def build_summarize_for_resource_group_level_policy_assignment_request( # pylint: disable=name-too-long policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, resource_group_name: str, @@ -1170,14 +1170,14 @@ def build_summarize_for_resource_group_level_policy_assignment_request( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyStatesSummaryResource": _SERIALIZER.url( "policy_states_summary_resource", policy_states_summary_resource, "str" @@ -1188,7 +1188,7 @@ def build_summarize_for_resource_group_level_policy_assignment_request( "policyAssignmentName": _SERIALIZER.url("policy_assignment_name", policy_assignment_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1219,12 +1219,12 @@ class PolicyStatesOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_management_group( @@ -1233,7 +1233,7 @@ def list_query_results_for_management_group( management_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the resources under the management group. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1244,11 +1244,6 @@ def list_query_results_for_management_group( :type management_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1259,10 +1254,10 @@ def list_query_results_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1290,7 +1285,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_management_group_request( + _request = build_list_query_results_for_management_group_request( policy_states_resource=policy_states_resource, management_group_name=management_group_name, top=_top, @@ -1303,12 +1298,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_query_results_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1329,18 +1322,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -1350,10 +1341,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1366,10 +1358,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace def summarize_for_management_group( self, @@ -1389,16 +1377,11 @@ def summarize_for_management_group( :type management_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1412,7 +1395,7 @@ def summarize_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -1425,7 +1408,7 @@ def summarize_for_management_group( _to = query_options.to _top = query_options.top - request = build_summarize_for_management_group_request( + _request = build_summarize_for_management_group_request( policy_states_summary_resource=policy_states_summary_resource, management_group_name=management_group_name, top=_top, @@ -1434,15 +1417,14 @@ def summarize_for_management_group( filter=_filter, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.summarize_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1452,16 +1434,12 @@ def summarize_for_management_group( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_subscription( @@ -1470,7 +1448,7 @@ def list_query_results_for_subscription( subscription_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the resources under the subscription. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1481,7 +1459,6 @@ def list_query_results_for_subscription( :type subscription_id: str :param query_options: Parameter group. Default value is None. :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 PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1489,10 +1466,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1520,7 +1497,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, top=_top, @@ -1532,12 +1509,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1558,18 +1533,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -1579,10 +1552,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1595,10 +1569,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace def summarize_for_subscription( self, @@ -1618,12 +1588,11 @@ def summarize_for_subscription( :type subscription_id: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1634,7 +1603,7 @@ def summarize_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -1647,7 +1616,7 @@ def summarize_for_subscription( _to = query_options.to _top = query_options.top - request = build_summarize_for_subscription_request( + _request = build_summarize_for_subscription_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, top=_top, @@ -1655,15 +1624,14 @@ def summarize_for_subscription( to=_to, filter=_filter, api_version=api_version, - template_url=self.summarize_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1673,16 +1641,12 @@ def summarize_for_subscription( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_resource_group( @@ -1692,7 +1656,7 @@ def list_query_results_for_resource_group( resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the resources under the resource group. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1705,7 +1669,6 @@ def list_query_results_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1713,10 +1676,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1744,7 +1707,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -1757,12 +1720,10 @@ def prepare_request(next_link=None): apply=_apply, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -1783,18 +1744,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -1804,10 +1763,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1820,10 +1780,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace def summarize_for_resource_group( self, @@ -1846,12 +1802,11 @@ def summarize_for_resource_group( :type resource_group_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1862,7 +1817,7 @@ def summarize_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -1875,7 +1830,7 @@ def summarize_for_resource_group( _to = query_options.to _top = query_options.top - request = build_summarize_for_resource_group_request( + _request = build_summarize_for_resource_group_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -1884,15 +1839,14 @@ def summarize_for_resource_group( to=_to, filter=_filter, api_version=api_version, - template_url=self.summarize_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1902,16 +1856,12 @@ def summarize_for_resource_group( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_resource( @@ -1920,7 +1870,7 @@ def list_query_results_for_resource( resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the resource. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -1931,7 +1881,6 @@ def list_query_results_for_resource( :type resource_id: str :param query_options: Parameter group. Default value is None. :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 PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -1939,10 +1888,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1972,7 +1921,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( policy_states_resource=policy_states_resource, resource_id=resource_id, top=_top, @@ -1985,12 +1934,10 @@ def prepare_request(next_link=None): expand=_expand, skip_token=_skip_token, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -2013,18 +1960,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -2034,10 +1979,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2050,10 +1996,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace def summarize_for_resource( self, @@ -2073,12 +2015,11 @@ def summarize_for_resource( :type resource_id: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2089,7 +2030,7 @@ def summarize_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -2102,7 +2043,7 @@ def summarize_for_resource( _to = query_options.to _top = query_options.top - request = build_summarize_for_resource_request( + _request = build_summarize_for_resource_request( policy_states_summary_resource=policy_states_summary_resource, resource_id=resource_id, top=_top, @@ -2110,15 +2051,14 @@ def summarize_for_resource( to=_to, filter=_filter, api_version=api_version, - template_url=self.summarize_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2128,21 +2068,15 @@ def summarize_for_resource( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - summarize_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore - def _trigger_subscription_evaluation_initial( # pylint: disable=inconsistent-return-statements - self, subscription_id: str, **kwargs: Any - ) -> None: - error_map = { + def _trigger_subscription_evaluation_initial(self, subscription_id: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2153,36 +2087,40 @@ def _trigger_subscription_evaluation_initial( # pylint: disable=inconsistent-re _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_trigger_subscription_evaluation_request( + _request = build_trigger_subscription_evaluation_request( subscription_id=subscription_id, api_version=api_version, - template_url=self._trigger_subscription_evaluation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _trigger_subscription_evaluation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return deserialized # type: ignore @distributed_trace def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: Any) -> LROPoller[None]: @@ -2190,14 +2128,6 @@ def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: :param subscription_id: Microsoft Azure subscription ID. Required. :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: 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) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2205,13 +2135,13 @@ def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._trigger_subscription_evaluation_initial( # type: ignore + raw_result = self._trigger_subscription_evaluation_initial( subscription_id=subscription_id, api_version=api_version, cls=lambda x, y, z: x, @@ -2219,11 +2149,12 @@ def begin_trigger_subscription_evaluation(self, subscription_id: str, **kwargs: params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -2234,22 +2165,18 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_trigger_subscription_evaluation.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } - - def _trigger_resource_group_evaluation_initial( # pylint: disable=inconsistent-return-statements + def _trigger_resource_group_evaluation_initial( # pylint: disable=name-too-long self, subscription_id: str, resource_group_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2260,37 +2187,41 @@ def _trigger_resource_group_evaluation_initial( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) - cls: ClsType[None] = kwargs.pop("cls", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_trigger_resource_group_evaluation_request( + _request = build_trigger_resource_group_evaluation_request( subscription_id=subscription_id, resource_group_name=resource_group_name, api_version=api_version, - template_url=self._trigger_resource_group_evaluation_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - _trigger_resource_group_evaluation_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return deserialized # type: ignore @distributed_trace def begin_trigger_resource_group_evaluation( @@ -2302,14 +2233,6 @@ def begin_trigger_resource_group_evaluation( :type subscription_id: str :param resource_group_name: Resource group name. Required. :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: 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) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -2317,13 +2240,13 @@ def begin_trigger_resource_group_evaluation( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._trigger_resource_group_evaluation_initial( # type: ignore + raw_result = self._trigger_resource_group_evaluation_initial( subscription_id=subscription_id, resource_group_name=resource_group_name, api_version=api_version, @@ -2332,11 +2255,12 @@ def begin_trigger_resource_group_evaluation( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -2347,27 +2271,23 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_trigger_resource_group_evaluation.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def list_query_results_for_policy_set_definition( + def list_query_results_for_policy_set_definition( # pylint: disable=name-too-long self, policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_set_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the subscription level policy set definition. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -2380,11 +2300,6 @@ def list_query_results_for_policy_set_definition( :type policy_set_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -2395,10 +2310,10 @@ def list_query_results_for_policy_set_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2426,7 +2341,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_set_definition_request( + _request = build_list_query_results_for_policy_set_definition_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, policy_set_definition_name=policy_set_definition_name, @@ -2440,12 +2355,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_set_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -2466,18 +2379,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -2487,10 +2398,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2503,10 +2415,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_policy_set_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace def summarize_for_policy_set_definition( self, @@ -2529,16 +2437,11 @@ def summarize_for_policy_set_definition( :type policy_set_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2552,7 +2455,7 @@ def summarize_for_policy_set_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -2565,7 +2468,7 @@ def summarize_for_policy_set_definition( _to = query_options.to _top = query_options.top - request = build_summarize_for_policy_set_definition_request( + _request = build_summarize_for_policy_set_definition_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, policy_set_definition_name=policy_set_definition_name, @@ -2575,15 +2478,14 @@ def summarize_for_policy_set_definition( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_policy_set_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2593,16 +2495,12 @@ def summarize_for_policy_set_definition( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_policy_set_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace def list_query_results_for_policy_definition( @@ -2612,7 +2510,7 @@ def list_query_results_for_policy_definition( policy_definition_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the subscription level policy definition. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -2625,11 +2523,6 @@ def list_query_results_for_policy_definition( :type policy_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -2640,10 +2533,10 @@ def list_query_results_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2671,7 +2564,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_policy_definition_request( + _request = build_list_query_results_for_policy_definition_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, policy_definition_name=policy_definition_name, @@ -2685,12 +2578,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -2711,18 +2602,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -2732,10 +2621,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2748,10 +2638,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace def summarize_for_policy_definition( self, @@ -2774,16 +2660,11 @@ def summarize_for_policy_definition( :type policy_definition_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2797,7 +2678,7 @@ def summarize_for_policy_definition( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -2810,7 +2691,7 @@ def summarize_for_policy_definition( _to = query_options.to _top = query_options.top - request = build_summarize_for_policy_definition_request( + _request = build_summarize_for_policy_definition_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, policy_definition_name=policy_definition_name, @@ -2820,15 +2701,14 @@ def summarize_for_policy_definition( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_policy_definition.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2838,26 +2718,22 @@ def summarize_for_policy_definition( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_policy_definition.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace - def list_query_results_for_subscription_level_policy_assignment( + def list_query_results_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the subscription level policy assignment. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -2870,11 +2746,6 @@ def list_query_results_for_subscription_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -2885,10 +2756,10 @@ def list_query_results_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2916,7 +2787,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_subscription_level_policy_assignment_request( + _request = build_list_query_results_for_subscription_level_policy_assignment_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, @@ -2930,12 +2801,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -2956,18 +2825,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -2977,10 +2844,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2993,12 +2861,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace - def summarize_for_subscription_level_policy_assignment( + def summarize_for_subscription_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, @@ -3019,16 +2883,11 @@ def summarize_for_subscription_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3042,7 +2901,7 @@ def summarize_for_subscription_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -3055,7 +2914,7 @@ def summarize_for_subscription_level_policy_assignment( _to = query_options.to _top = query_options.top - request = build_summarize_for_subscription_level_policy_assignment_request( + _request = build_summarize_for_subscription_level_policy_assignment_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, policy_assignment_name=policy_assignment_name, @@ -3065,15 +2924,14 @@ def summarize_for_subscription_level_policy_assignment( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_subscription_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3083,19 +2941,15 @@ def summarize_for_subscription_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_subscription_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore @distributed_trace - def list_query_results_for_resource_group_level_policy_assignment( + def list_query_results_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_resource: Union[str, _models.PolicyStatesResource], subscription_id: str, @@ -3103,7 +2957,7 @@ def list_query_results_for_resource_group_level_policy_assignment( policy_assignment_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyState"]: + ) -> ItemPaged["_models.PolicyState"]: """Queries policy states for the resource group level policy assignment. :param policy_states_resource: The virtual resource under PolicyStates resource type. In a @@ -3118,11 +2972,6 @@ def list_query_results_for_resource_group_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyState or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyState] :raises ~azure.core.exceptions.HttpResponseError: @@ -3133,10 +2982,10 @@ def list_query_results_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.PolicyStatesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3164,7 +3013,7 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_list_query_results_for_resource_group_level_policy_assignment_request( + _request = build_list_query_results_for_resource_group_level_policy_assignment_request( policy_states_resource=policy_states_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -3179,12 +3028,10 @@ def prepare_request(next_link=None): skip_token=_skip_token, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.list_query_results_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: _top = None @@ -3205,18 +3052,16 @@ def prepare_request(next_link=None): _to = query_options.to _top = query_options.top - request = build_next_link_request( + _request = build_next_link_request( next_link=next_link, skip_token=_skip_token, api_version=api_version, - template_url="{nextLink}", headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - return request + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyStatesQueryResults", pipeline_response) @@ -3226,10 +3071,11 @@ def extract_data(pipeline_response): return deserialized.odata_next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3242,12 +3088,8 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults" - } - @distributed_trace - def summarize_for_resource_group_level_policy_assignment( + def summarize_for_resource_group_level_policy_assignment( # pylint: disable=name-too-long self, policy_states_summary_resource: Union[str, _models.PolicyStatesSummaryResourceType], subscription_id: str, @@ -3271,16 +3113,11 @@ def summarize_for_resource_group_level_policy_assignment( :type policy_assignment_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword authorization_namespace: The namespace for Microsoft Authorization resource provider; - only "Microsoft.Authorization" is allowed. Default value is "Microsoft.Authorization". Note - that overriding this default value may result in unsupported behavior. - :paramtype authorization_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SummarizeResults or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.SummarizeResults :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3294,7 +3131,7 @@ def summarize_for_resource_group_level_policy_assignment( authorization_namespace: Literal["Microsoft.Authorization"] = kwargs.pop( "authorization_namespace", "Microsoft.Authorization" ) - api_version: Literal["2019-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.SummarizeResults] = kwargs.pop("cls", None) _top = None @@ -3307,7 +3144,7 @@ def summarize_for_resource_group_level_policy_assignment( _to = query_options.to _top = query_options.top - request = build_summarize_for_resource_group_level_policy_assignment_request( + _request = build_summarize_for_resource_group_level_policy_assignment_request( policy_states_summary_resource=policy_states_summary_resource, subscription_id=subscription_id, resource_group_name=resource_group_name, @@ -3318,15 +3155,14 @@ def summarize_for_resource_group_level_policy_assignment( filter=_filter, authorization_namespace=authorization_namespace, api_version=api_version, - template_url=self.summarize_for_resource_group_level_policy_assignment.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -3336,13 +3172,9 @@ def summarize_for_resource_group_level_policy_assignment( error = self._deserialize.failsafe_deserialize(_models.QueryFailure, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SummarizeResults", pipeline_response) + deserialized = self._deserialize("SummarizeResults", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - summarize_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + return deserialized # type: ignore 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 e59da858511c..77f8b714c9ca 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,10 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from collections.abc import MutableMapping +from typing import Any, Callable, Dict, Literal, Optional, TypeVar, Union +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,20 +20,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +36,7 @@ _SERIALIZER.client_side_validation = False -def build_list_query_results_for_management_group_request( +def build_list_query_results_for_management_group_request( # pylint: disable=name-too-long management_group_name: str, policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], *, @@ -54,16 +50,14 @@ def build_list_query_results_for_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupName": _SERIALIZER.url("management_group_name", management_group_name, "str"), @@ -72,7 +66,7 @@ def build_list_query_results_for_management_group_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -87,7 +81,7 @@ def build_list_query_results_for_management_group_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_subscription_request( +def build_list_query_results_for_subscription_request( # pylint: disable=name-too-long policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], subscription_id: str, *, @@ -98,16 +92,14 @@ def build_list_query_results_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "policyTrackedResourcesResource": _SERIALIZER.url( "policy_tracked_resources_resource", policy_tracked_resources_resource, "str" @@ -115,7 +107,7 @@ def build_list_query_results_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -130,7 +122,7 @@ def build_list_query_results_for_subscription_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_group_request( +def build_list_query_results_for_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], subscription_id: str, @@ -142,16 +134,14 @@ def build_list_query_results_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "policyTrackedResourcesResource": _SERIALIZER.url( @@ -160,7 +150,7 @@ def build_list_query_results_for_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -175,7 +165,7 @@ def build_list_query_results_for_resource_group_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_query_results_for_resource_request( +def build_list_query_results_for_resource_request( # pylint: disable=name-too-long resource_id: str, policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], *, @@ -186,16 +176,14 @@ def build_list_query_results_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), "policyTrackedResourcesResource": _SERIALIZER.url( @@ -203,7 +191,7 @@ def build_list_query_results_for_resource_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -230,12 +218,12 @@ class PolicyTrackedResourcesOperations: models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_query_results_for_management_group( @@ -244,7 +232,7 @@ def list_query_results_for_management_group( policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyTrackedResource"]: + ) -> ItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the management group. :param management_group_name: Management group name. Required. @@ -255,11 +243,6 @@ def list_query_results_for_management_group( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PolicyTrackedResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] @@ -271,12 +254,10 @@ def list_query_results_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,26 +273,23 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_management_group_request( + _request = build_list_query_results_for_management_group_request( management_group_name=management_group_name, policy_tracked_resources_resource=policy_tracked_resources_resource, top=_top, filter=_filter, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_query_results_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -321,10 +299,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -337,17 +316,13 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_subscription( self, policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyTrackedResource"]: + ) -> ItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the subscription. :param policy_tracked_resources_resource: The name of the virtual resource under @@ -356,7 +331,6 @@ def list_query_results_for_subscription( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :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 PolicyTrackedResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] @@ -365,12 +339,10 @@ def list_query_results_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,25 +358,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_subscription_request( + _request = build_list_query_results_for_subscription_request( policy_tracked_resources_resource=policy_tracked_resources_resource, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_query_results_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -414,10 +383,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -430,10 +400,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource_group( self, @@ -441,7 +407,7 @@ def list_query_results_for_resource_group( policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyTrackedResource"]: + ) -> ItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the resource group. :param resource_group_name: Resource group name. Required. @@ -452,7 +418,6 @@ def list_query_results_for_resource_group( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :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 PolicyTrackedResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] @@ -461,12 +426,10 @@ def list_query_results_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,26 +445,23 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_resource_group_request( + _request = build_list_query_results_for_resource_group_request( resource_group_name=resource_group_name, policy_tracked_resources_resource=policy_tracked_resources_resource, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_query_results_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -511,10 +471,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -527,10 +488,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_query_results_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_resource( self, @@ -538,7 +495,7 @@ def list_query_results_for_resource( policy_tracked_resources_resource: Union[str, _models.PolicyTrackedResourcesResourceType], query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.PolicyTrackedResource"]: + ) -> ItemPaged["_models.PolicyTrackedResource"]: """Queries policy tracked resources under the resource. :param resource_id: Resource ID. Required. @@ -549,7 +506,6 @@ def list_query_results_for_resource( ~azure.mgmt.policyinsights.models.PolicyTrackedResourcesResourceType :param query_options: Parameter group. Default value is None. :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 PolicyTrackedResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.PolicyTrackedResource] @@ -558,12 +514,10 @@ def list_query_results_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2018-07-01-preview"] = kwargs.pop( - "api_version", _params.pop("api-version", "2018-07-01-preview") - ) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01-preview")) cls: ClsType[_models.PolicyTrackedResourcesQueryResults] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -579,25 +533,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_query_results_for_resource_request( + _request = build_list_query_results_for_resource_request( resource_id=resource_id, policy_tracked_resources_resource=policy_tracked_resources_resource, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_query_results_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("PolicyTrackedResourcesQueryResults", pipeline_response) @@ -607,10 +558,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -622,7 +574,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_query_results_for_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } 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 2f56a35ecd62..f7e889216741 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=line-too-long,useless-suppression,too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,9 +6,11 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from collections.abc import MutableMapping +from io import IOBase +from typing import Any, Callable, Dict, IO, Literal, Optional, TypeVar, Union, overload +from azure.core import PipelineClient from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,20 +21,15 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._configuration import PolicyInsightsClientConfiguration +from .._utils.serialization import Deserializer, Serializer -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +37,7 @@ _SERIALIZER.client_side_validation = False -def build_list_deployments_at_management_group_request( +def build_list_deployments_at_management_group_request( # pylint: disable=name-too-long management_group_id: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -49,21 +46,21 @@ def build_list_deployments_at_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -85,21 +82,21 @@ def build_cancel_at_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -119,20 +116,20 @@ def build_list_for_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -147,7 +144,7 @@ def build_list_for_management_group_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_management_group_request( +def build_create_or_update_at_management_group_request( # pylint: disable=name-too-long management_group_id: str, remediation_name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -156,7 +153,7 @@ def build_create_or_update_at_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -164,14 +161,14 @@ def build_create_or_update_at_management_group_request( _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -193,21 +190,21 @@ def build_get_at_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -227,21 +224,21 @@ def build_delete_at_management_group_request( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "managementGroupsNamespace": _SERIALIZER.url("management_groups_namespace", management_groups_namespace, "str"), "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -252,26 +249,26 @@ def build_delete_at_management_group_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_deployments_at_subscription_request( +def build_list_deployments_at_subscription_request( # pylint: disable=name-too-long remediation_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -288,20 +285,20 @@ def build_cancel_at_subscription_request(remediation_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -318,7 +315,7 @@ def build_list_for_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -327,7 +324,7 @@ def build_list_for_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -342,13 +339,13 @@ def build_list_for_subscription_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_subscription_request( +def build_create_or_update_at_subscription_request( # pylint: disable=name-too-long remediation_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -356,13 +353,13 @@ def build_create_or_update_at_subscription_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -379,20 +376,20 @@ def build_get_at_subscription_request(remediation_name: str, subscription_id: st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -407,20 +404,20 @@ def build_delete_at_subscription_request(remediation_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,27 +428,27 @@ def build_delete_at_subscription_request(remediation_name: str, subscription_id: return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_deployments_at_resource_group_request( +def build_list_deployments_at_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, remediation_name: str, subscription_id: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -470,21 +467,21 @@ def build_cancel_at_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -506,20 +503,20 @@ def build_list_for_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -534,13 +531,13 @@ def build_list_for_resource_group_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_resource_group_request( +def build_create_or_update_at_resource_group_request( # pylint: disable=name-too-long resource_group_name: str, remediation_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -548,14 +545,14 @@ def build_create_or_update_at_resource_group_request( _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -574,21 +571,21 @@ def build_get_at_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -605,21 +602,21 @@ def build_delete_at_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -630,26 +627,26 @@ def build_delete_at_resource_group_request( return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_deployments_at_resource_request( +def build_list_deployments_at_resource_request( # pylint: disable=name-too-long resource_id: str, remediation_name: str, *, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments", - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -666,19 +663,19 @@ def build_cancel_at_resource_request(resource_id: str, remediation_name: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - ) # pylint: disable=line-too-long + ) path_format_arguments = { "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -695,7 +692,7 @@ def build_list_for_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -704,7 +701,7 @@ def build_list_for_resource_request( "resourceId": _SERIALIZER.url("resource_id", resource_id, "str", skip_quote=True), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters if top is not None: @@ -719,11 +716,13 @@ def build_list_for_resource_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_at_resource_request(resource_id: str, remediation_name: str, **kwargs: Any) -> HttpRequest: +def build_create_or_update_at_resource_request( # pylint: disable=name-too-long + resource_id: str, remediation_name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -734,7 +733,7 @@ def build_create_or_update_at_resource_request(resource_id: str, remediation_nam "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -751,7 +750,7 @@ def build_get_at_resource_request(resource_id: str, remediation_name: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -761,7 +760,7 @@ def build_get_at_resource_request(resource_id: str, remediation_name: str, **kwa "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -776,7 +775,7 @@ def build_delete_at_resource_request(resource_id: str, remediation_name: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -786,7 +785,7 @@ def build_delete_at_resource_request(resource_id: str, remediation_name: str, ** "remediationName": _SERIALIZER.url("remediation_name", remediation_name, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -809,12 +808,12 @@ class RemediationsOperations: # pylint: disable=too-many-public-methods models = _models - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PolicyInsightsClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_deployments_at_management_group( @@ -823,7 +822,7 @@ def list_deployments_at_management_group( remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.RemediationDeployment"]: + ) -> ItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at management group scope. :param management_group_id: Management group ID. Required. @@ -832,11 +831,6 @@ def list_deployments_at_management_group( :type remediation_name: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RemediationDeployment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] @@ -848,10 +842,10 @@ def list_deployments_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,25 +859,22 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_management_group_request( + _request = build_list_deployments_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, top=_top, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_deployments_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -893,10 +884,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -909,10 +901,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deployments_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace def cancel_at_management_group( self, management_group_id: str, remediation_name: str, **kwargs: Any @@ -923,16 +911,11 @@ def cancel_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -946,23 +929,22 @@ def cancel_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_management_group_request( + _request = build_cancel_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.cancel_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -972,32 +954,23 @@ def cancel_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_management_group( self, management_group_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Remediation"]: + ) -> ItemPaged["_models.Remediation"]: """Gets all remediations for the management group. :param management_group_id: Management group ID. Required. :type management_group_id: str :param query_options: Parameter group. Default value is None. :type query_options: ~azure.mgmt.policyinsights.models.QueryOptions - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Remediation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -1008,10 +981,10 @@ def list_for_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1027,25 +1000,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_management_group_request( + _request = build_list_for_management_group_request( management_group_id=management_group_id, top=_top, filter=_filter, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.list_for_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -1055,10 +1025,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1071,10 +1042,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations" - } - @overload def create_or_update_at_management_group( self, @@ -1096,11 +1063,6 @@ def create_or_update_at_management_group( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1111,7 +1073,7 @@ def create_or_update_at_management_group( self, management_group_id: str, remediation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1123,15 +1085,10 @@ def create_or_update_at_management_group( :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1139,7 +1096,11 @@ def create_or_update_at_management_group( @distributed_trace def create_or_update_at_management_group( - self, management_group_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, + management_group_id: str, + remediation_name: str, + parameters: Union[_models.Remediation, IO[bytes]], + **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at management group scope. @@ -1147,21 +1108,14 @@ def create_or_update_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1175,19 +1129,19 @@ def create_or_update_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_management_group_request( + _request = build_create_or_update_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, @@ -1195,15 +1149,14 @@ def create_or_update_at_management_group( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1213,21 +1166,13 @@ def create_or_update_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace def get_at_management_group( self, management_group_id: str, remediation_name: str, **kwargs: Any @@ -1238,16 +1183,11 @@ def get_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1261,23 +1201,22 @@ def get_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_management_group_request( + _request = build_get_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.get_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1287,16 +1226,12 @@ def get_at_management_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_management_group( @@ -1308,16 +1243,11 @@ def delete_at_management_group( :type management_group_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword management_groups_namespace: The namespace for Microsoft Management RP; only - "Microsoft.Management" is allowed. Default value is "Microsoft.Management". Note that - overriding this default value may result in unsupported behavior. - :paramtype management_groups_namespace: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1331,23 +1261,22 @@ def delete_at_management_group( management_groups_namespace: Literal["Microsoft.Management"] = kwargs.pop( "management_groups_namespace", "Microsoft.Management" ) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_management_group_request( + _request = build_delete_at_management_group_request( management_group_id=management_group_id, remediation_name=remediation_name, management_groups_namespace=management_groups_namespace, api_version=api_version, - template_url=self.delete_at_management_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1359,28 +1288,23 @@ def delete_at_management_group( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_management_group.metadata = { - "url": "/providers/{managementGroupsNamespace}/managementGroups/{managementGroupId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def list_deployments_at_subscription( self, remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.RemediationDeployment"]: + ) -> ItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param query_options: Parameter group. Default value is None. :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 RemediationDeployment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] @@ -1389,10 +1313,10 @@ def list_deployments_at_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,24 +1330,21 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_subscription_request( + _request = build_list_deployments_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, top=_top, api_version=api_version, - template_url=self.list_deployments_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -1433,10 +1354,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1449,22 +1371,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deployments_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Cancels a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1475,22 +1392,21 @@ def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_subscription_request( + _request = build_cancel_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1500,26 +1416,21 @@ def cancel_at_subscription(self, remediation_name: str, **kwargs: Any) -> _model error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_subscription( self, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Remediation"]: + ) -> ItemPaged["_models.Remediation"]: """Gets all remediations for the subscription. :param query_options: Parameter group. Default value is None. :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 Remediation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -1527,10 +1438,10 @@ def list_for_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1546,24 +1457,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_subscription_request( + _request = build_list_for_subscription_request( subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -1573,10 +1481,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1589,10 +1498,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations" - } - @overload def create_or_update_at_subscription( self, @@ -1611,7 +1516,6 @@ def create_or_update_at_subscription( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1619,18 +1523,17 @@ def create_or_update_at_subscription( @overload def create_or_update_at_subscription( - self, remediation_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, remediation_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -1638,23 +1541,20 @@ def create_or_update_at_subscription( @distributed_trace def create_or_update_at_subscription( - self, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1665,34 +1565,33 @@ def create_or_update_at_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_subscription_request( + _request = build_create_or_update_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1702,33 +1601,24 @@ def create_or_update_at_subscription( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Gets an existing remediation at subscription scope. :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1739,22 +1629,21 @@ def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.R _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_subscription_request( + _request = build_get_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1764,16 +1653,12 @@ def get_at_subscription(self, remediation_name: str, **kwargs: Any) -> _models.R error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Optional[_models.Remediation]: @@ -1781,12 +1666,11 @@ def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Option :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1797,22 +1681,21 @@ def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Option _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_subscription_request( + _request = build_delete_at_subscription_request( remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1824,16 +1707,12 @@ def delete_at_subscription(self, remediation_name: str, **kwargs: Any) -> Option deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def list_deployments_at_resource_group( @@ -1842,7 +1721,7 @@ def list_deployments_at_resource_group( remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.RemediationDeployment"]: + ) -> ItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at resource group scope. :param resource_group_name: Resource group name. Required. @@ -1851,7 +1730,6 @@ def list_deployments_at_resource_group( :type remediation_name: str :param query_options: Parameter group. Default value is None. :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 RemediationDeployment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] @@ -1860,10 +1738,10 @@ def list_deployments_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,25 +1755,22 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_resource_group_request( + _request = build_list_deployments_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, top=_top, api_version=api_version, - template_url=self.list_deployments_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -1905,10 +1780,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1921,10 +1797,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deployments_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace def cancel_at_resource_group( self, resource_group_name: str, remediation_name: str, **kwargs: Any @@ -1935,12 +1807,11 @@ def cancel_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1951,23 +1822,22 @@ def cancel_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_resource_group_request( + _request = build_cancel_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.cancel_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1977,28 +1847,23 @@ def cancel_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_resource_group( self, resource_group_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Remediation"]: + ) -> ItemPaged["_models.Remediation"]: """Gets all remediations for the subscription. :param resource_group_name: Resource group name. Required. :type resource_group_name: str :param query_options: Parameter group. Default value is None. :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 Remediation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -2006,10 +1871,10 @@ def list_for_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2025,25 +1890,22 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_group_request( + _request = build_list_for_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -2053,10 +1915,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2069,10 +1932,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations" - } - @overload def create_or_update_at_resource_group( self, @@ -2094,7 +1953,6 @@ def create_or_update_at_resource_group( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -2105,7 +1963,7 @@ def create_or_update_at_resource_group( self, resource_group_name: str, remediation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2117,11 +1975,10 @@ def create_or_update_at_resource_group( :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -2129,7 +1986,11 @@ def create_or_update_at_resource_group( @distributed_trace def create_or_update_at_resource_group( - self, resource_group_name: str, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, + resource_group_name: str, + remediation_name: str, + parameters: Union[_models.Remediation, IO[bytes]], + **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at resource group scope. @@ -2137,17 +1998,14 @@ def create_or_update_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2158,19 +2016,19 @@ def create_or_update_at_resource_group( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_resource_group_request( + _request = build_create_or_update_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, @@ -2178,15 +2036,14 @@ def create_or_update_at_resource_group( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2196,21 +2053,13 @@ def create_or_update_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace def get_at_resource_group( self, resource_group_name: str, remediation_name: str, **kwargs: Any @@ -2221,12 +2070,11 @@ def get_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2237,23 +2085,22 @@ def get_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_resource_group_request( + _request = build_get_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2263,16 +2110,12 @@ def get_at_resource_group( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_resource_group( @@ -2284,12 +2127,11 @@ def delete_at_resource_group( :type resource_group_name: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2300,23 +2142,22 @@ def delete_at_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_resource_group_request( + _request = build_delete_at_resource_group_request( resource_group_name=resource_group_name, remediation_name=remediation_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_at_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2328,16 +2169,12 @@ def delete_at_resource_group( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def list_deployments_at_resource( @@ -2346,7 +2183,7 @@ def list_deployments_at_resource( remediation_name: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.RemediationDeployment"]: + ) -> ItemPaged["_models.RemediationDeployment"]: """Gets all deployments for a remediation at resource scope. :param resource_id: Resource ID. Required. @@ -2355,7 +2192,6 @@ def list_deployments_at_resource( :type remediation_name: str :param query_options: Parameter group. Default value is None. :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 RemediationDeployment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.RemediationDeployment] @@ -2364,10 +2200,10 @@ def list_deployments_at_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationDeploymentsListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2381,24 +2217,21 @@ def prepare_request(next_link=None): if query_options is not None: _top = query_options.top - request = build_list_deployments_at_resource_request( + _request = build_list_deployments_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, top=_top, api_version=api_version, - template_url=self.list_deployments_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationDeploymentsListResult", pipeline_response) @@ -2408,10 +2241,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2424,10 +2258,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_deployments_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/listDeployments" - } - @distributed_trace def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Cancel a remediation at resource scope. @@ -2436,12 +2266,11 @@ def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2452,22 +2281,21 @@ def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_cancel_at_resource_request( + _request = build_cancel_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, - template_url=self.cancel_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2477,28 +2305,23 @@ def cancel_at_resource(self, resource_id: str, remediation_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - cancel_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}/cancel" - } + return deserialized # type: ignore @distributed_trace def list_for_resource( self, resource_id: str, query_options: Optional[_models.QueryOptions] = None, **kwargs: Any - ) -> Iterable["_models.Remediation"]: + ) -> ItemPaged["_models.Remediation"]: """Gets all remediations for a resource. :param resource_id: Resource ID. Required. :type resource_id: str :param query_options: Parameter group. Default value is None. :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 Remediation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -2506,10 +2329,10 @@ def list_for_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.RemediationListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2525,24 +2348,21 @@ def prepare_request(next_link=None): _filter = query_options.filter _top = query_options.top - request = build_list_for_resource_request( + _request = build_list_for_resource_request( resource_id=resource_id, top=_top, filter=_filter, api_version=api_version, - template_url=self.list_for_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("RemediationListResult", pipeline_response) @@ -2552,10 +2372,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2568,8 +2389,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_for_resource.metadata = {"url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations"} - @overload def create_or_update_at_resource( self, @@ -2591,7 +2410,6 @@ def create_or_update_at_resource( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -2602,7 +2420,7 @@ def create_or_update_at_resource( self, resource_id: str, remediation_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2614,11 +2432,10 @@ def create_or_update_at_resource( :param remediation_name: The name of the remediation. Required. :type remediation_name: str :param parameters: The remediation parameters. Required. - :type parameters: IO + :type parameters: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: @@ -2626,7 +2443,7 @@ def create_or_update_at_resource( @distributed_trace def create_or_update_at_resource( - self, resource_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO], **kwargs: Any + self, resource_id: str, remediation_name: str, parameters: Union[_models.Remediation, IO[bytes]], **kwargs: Any ) -> _models.Remediation: """Creates or updates a remediation at resource scope. @@ -2634,17 +2451,14 @@ def create_or_update_at_resource( :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :param parameters: The remediation parameters. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response + :param parameters: The remediation parameters. Is either a Remediation type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.policyinsights.models.Remediation or IO[bytes] :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2655,34 +2469,33 @@ def create_or_update_at_resource( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "Remediation") - request = build_create_or_update_at_resource_request( + _request = build_create_or_update_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2692,21 +2505,13 @@ def create_or_update_at_resource( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - create_or_update_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } - @distributed_trace def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any) -> _models.Remediation: """Gets an existing remediation at resource scope. @@ -2715,12 +2520,11 @@ def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2731,22 +2535,21 @@ def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[_models.Remediation] = kwargs.pop("cls", None) - request = build_get_at_resource_request( + _request = build_get_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, - template_url=self.get_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2756,16 +2559,12 @@ def get_at_resource(self, resource_id: str, remediation_name: str, **kwargs: Any error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore @distributed_trace def delete_at_resource( @@ -2777,12 +2576,11 @@ def delete_at_resource( :type resource_id: str :param remediation_name: The name of the remediation. Required. :type remediation_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Remediation or None or the result of cls(response) :rtype: ~azure.mgmt.policyinsights.models.Remediation or None :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2793,22 +2591,21 @@ def delete_at_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: Literal["2021-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-10-01")) cls: ClsType[Optional[_models.Remediation]] = kwargs.pop("cls", None) - request = build_delete_at_resource_request( + _request = build_delete_at_resource_request( resource_id=resource_id, remediation_name=remediation_name, api_version=api_version, - template_url=self.delete_at_resource.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=False, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2820,13 +2617,9 @@ def delete_at_resource( deserialized = None if response.status_code == 200: - deserialized = self._deserialize("Remediation", pipeline_response) + deserialized = self._deserialize("Remediation", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - delete_at_resource.metadata = { - "url": "/{resourceId}/providers/Microsoft.PolicyInsights/remediations/{remediationName}" - } + return deserialized # type: ignore diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py index e698d9530fae..942f25cc86ce 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -54,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_CreateResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py index 70e4c84838e5..ca21c1a1e50e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -54,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_CreateResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py index 07689d0c2cd8..10483ca52236 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_CreateSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py index a1190ce5cfd9..f51bc8620cc3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_create_subscription_scope_all_properties.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -53,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateSubscriptionScope_AllProperties.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_CreateSubscriptionScope_AllProperties.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py index 91f0f4d61eef..394872644764 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,13 +31,12 @@ def main(): subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", ) - response = client.attestations.delete_at_resource_group( + client.attestations.delete_at_resource_group( resource_group_name="myRg", attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", ) - print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_DeleteResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py index 8c7368c75226..15be32dd43c4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,13 +31,12 @@ def main(): subscription_id="SUBSCRIPTION_ID", ) - response = client.attestations.delete_at_resource( + client.attestations.delete_at_resource( resource_id="subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM", attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", ) - print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_DeleteResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py index 7df5e6856676..41cbe3b43f16 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_delete_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,12 +31,11 @@ def main(): subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", ) - response = client.attestations.delete_at_subscription( + client.attestations.delete_at_subscription( attestation_name="790996e6-9871-4b1f-9cd9-ec42cd6ced1e", ) - print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_DeleteSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py index e0e2ff986c17..064be56f43d8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_GetResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py index 93802ec34f84..fa06b6c0b254 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_GetResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py index 2dacfb44566e..de7bf731c457 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_get_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_GetSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py index 6d23792b0a00..bf217b7de208 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_ListResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py index 1589ebe6130f..af0d457309ae 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_group_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceGroupScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_ListResourceGroupScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py index 4318dd8e5336..83b694954b81 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_ListResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py index c9c292f3a795..f617d42df06f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_resource_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_ListResourceScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py index 9234ba355e52..ac3f07802f31 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_ListSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py index 5d9073875679..275f3b1da635 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/attestations_list_subscription_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListSubscriptionScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Attestations_ListSubscriptionScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py index 9b961d03447b..2404e02411ac 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_nested_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryNestedResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py index 7d9cfccff73d..aeee3adef5f6 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py index 3f72ecbe832e..8a902a1aec24 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py index 18bea6f49b19..3ef3c4aac3bb 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_group_scope_group_by_component_type_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceGroupScopeGroupByComponentTypeWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceGroupScopeGroupByComponentTypeWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py index 50153c73c88b..6e3e18fb5bd4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py index 03ce5400cca3..d265813b8db8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_expand_policy_evaluation_details.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py index 991a0311ec01..e8e1da9b9e8c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_filter_by_component_id.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceScopeFilterByComponentId.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceScopeFilterByComponentId.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py index 9d048daa7765..b1d7e44f6b32 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_resource_scope_group_by_component_type_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QueryResourceScopeGroupByComponentTypeWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QueryResourceScopeGroupByComponentTypeWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py index ef8098d554a6..1d4fb505a531 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py index faed7f017c30..2cda09e983e2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_level_policy_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py index de7276502e9a..1a2b94f5e255 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QuerySubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py index 0246b568ff0d..f97f41e381db 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/component_policy_states_query_subscription_scope_group_by_component_type_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/ComponentPolicyStates_QuerySubscriptionScopeGroupByComponentTypeWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/ComponentPolicyStates_QuerySubscriptionScopeGroupByComponentTypeWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py index e3f122abfb30..103c10f725ed 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/operations_list_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -33,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-04-01/examples/Operations_ListOperations.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Operations_ListOperations.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py index 5d2b03e1d31b..cac87c0966a8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_aggregate_only.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndAggregateOnly.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_FilterAndAggregateOnly.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py index b830f021b2bc..2fdebea9dc39 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndGroupByWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_FilterAndGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py index 298d5acdb0ca..1bf064ca423a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_group_by_without_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndGroupByWithoutAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_FilterAndGroupByWithoutAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py index bda0174665e4..5d044c4d3dda 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_filter_and_multiple_groups.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_FilterAndMultipleGroups.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_FilterAndMultipleGroups.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py index 3f6deef50f53..86824f27246b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py index 6d963378c5f1..8781816ae07d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_management_group_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryManagementGroupScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryManagementGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py index 06c7ad042f1a..d0693e8d78c3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_nested_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryNestedResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py index a7cda83259ab..def3bbc02e18 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py index e1698b0b3524..efecabab7fa2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_level_policy_assignment_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py index 7953ba7f355e..01012db15793 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py index 8d8293328b47..054afeeeb894 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_group_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceGroupScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py index 389e5300de99..ec991186870f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py index 0eb45a9cf8ad..16936ac261fd 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponents.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponents.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py index 2c85e00845a0..3291071cc09a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_expand_components_group_by_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponentsGroupByWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceScopeExpandComponentsGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py index 40f243e50ee5..fbe77432db49 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_resource_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QueryResourceScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QueryResourceScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py index 7fd6dddf8c41..72d13ca910a5 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_nested_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelNestedResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py index d5c702cc39f4..27679744ed84 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py index f0cf27fea457..4b0c00ea7fa0 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_assignment_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py index f7938c4c0636..ee08d017f67c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py index 39502e27e121..4c8992ee4415 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_definition_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py index 27dab613cf79..55206d0cd5e5 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py index a002a332cbb9..7590579a2888 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_policy_set_definition_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py index b7c6f6725b62..8331a5a86389 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_level_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionLevelResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionLevelResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py index cff4f093fbb5..d6ad5bafe050 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py index efbfce3ccd6d..fefdf2d62cf2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_query_subscription_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_QuerySubscriptionScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_QuerySubscriptionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py index 57456c58481c..d2bcb847e78a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_events_time_range_sort_select_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyEvents_TimeRangeSortSelectTop.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyEvents_TimeRangeSortSelectTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py index 472eac97aebd..4aa27919e6f1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_get_resource.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyMetadata_GetResource.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py index d522daa94c39..3781822aa3c6 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyMetadata_List.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py index 5607bd0de74e..2e3e9bcd5a2c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_metadata_list_with_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyMetadata_List_WithTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py index f6dfccaa2af6..ab07cc322f95 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-03-01/examples/PolicyRestrictions_CheckAtManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyRestrictions_CheckAtManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py index e941240fe97d..85caaf3cfd4d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -46,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-03-01/examples/PolicyRestrictions_CheckAtResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyRestrictions_CheckAtResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py new file mode 100644 index 000000000000..709e0ec27543 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py @@ -0,0 +1,54 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python policy_restrictions_check_at_resource_group_scope_include_audit_effect.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + ) + + response = client.policy_restrictions.check_at_resource_group_scope( + resource_group_name="vmRg", + parameters={ + "includeAuditEffect": True, + "pendingFields": [ + {"field": "name", "values": ["myVMName"]}, + {"field": "location", "values": ["eastus", "westus", "westus2", "westeurope"]}, + {"field": "tags"}, + ], + "resourceDetails": { + "apiVersion": "2019-12-01", + "resourceContent": {"properties": {"priority": "Spot"}, "type": "Microsoft.Compute/virtualMachines"}, + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyRestrictions_CheckAtResourceGroupScopeIncludeAuditEffect.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py index 1a5168c00e25..2a5604d2a01b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -45,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-03-01/examples/PolicyRestrictions_CheckAtSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyRestrictions_CheckAtSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py new file mode 100644 index 000000000000..e64c94675ca9 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py @@ -0,0 +1,53 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python policy_restrictions_check_at_subscription_scope_include_audit_effect.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + ) + + response = client.policy_restrictions.check_at_subscription_scope( + parameters={ + "includeAuditEffect": True, + "pendingFields": [ + {"field": "name", "values": ["myVMName"]}, + {"field": "location", "values": ["eastus", "westus", "westus2", "westeurope"]}, + {"field": "tags"}, + ], + "resourceDetails": { + "apiVersion": "2019-12-01", + "resourceContent": {"properties": {"priority": "Spot"}, "type": "Microsoft.Compute/virtualMachines"}, + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyRestrictions_CheckAtSubscriptionScopeIncludeAuditEffect.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py index 5b3f517be0c1..adfd505ad384 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_aggregate_only.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndAggregateOnly.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_FilterAndAggregateOnly.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py index 5f601c373ad8..064ac27d83fc 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndGroupByWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_FilterAndGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py index cff170f30716..b0942c2f73df 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_group_by_without_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndGroupByWithoutAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_FilterAndGroupByWithoutAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py index 78f0b0b389dd..f18d49d323b3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_filter_and_multiple_groups.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_FilterAndMultipleGroups.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_FilterAndMultipleGroups.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py index 9834e1f11e39..39fb12370d04 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py index 3bfa2c56d6e7..e28617e18f39 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_management_group_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryManagementGroupScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryManagementGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py index 3eca9c0547b8..9ffb9e170850 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_nested_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryNestedResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py index 74949555fec7..6d790abac39c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py index 34b4ffb118ed..3160b4c4fd57 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_level_policy_assignment_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +41,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceGroupLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py index 478439e029aa..05b406af7cf5 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py index 93c01079f34c..a5121ec869bb 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_group_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceGroupScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceGroupScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py index 35191a691f59..1d32c8a15e91 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py index 7a80ea38d878..359631c70300 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandComponents.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceScopeExpandComponents.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py index f18c553539fb..ca628d12299c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_components_group_by_with_aggregate.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandComponentsGroupByWithAggregate.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceScopeExpandComponentsGroupByWithAggregate.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py index 3133027b42c2..f5c0063668d2 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_expand_policy_evaluation_details.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceScopeExpandPolicyEvaluationDetails.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py index 3cf496b366c6..0256caedf63d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_resource_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QueryResourceScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QueryResourceScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py index 2ac24a0987b2..484cb2d4e6c9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_nested_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelNestedResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelNestedResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py index fd64c89b4333..4dce5b713362 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py index 555d085300d0..3ab59a255b8c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_assignment_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyAssignmentScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py index 38fc80715053..c436946f4848 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py index f0665a097aa2..3a54c441b231 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_definition_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicyDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py index 3a4bcd867873..52acdecc4d2d 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py index 7a625c22f86e..a1dcf98e7d83 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_policy_set_definition_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelPolicySetDefinitionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py index 697bd3203e18..01a3d1a889f9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_level_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionLevelResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionLevelResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py index cde1f7e5d15a..32b33a20ea11 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py index 9f3f5db2a05c..2addd3093c6e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_query_subscription_scope_next_link.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_QuerySubscriptionScopeNextLink.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_QuerySubscriptionScopeNextLink.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py index 77aea4a925a0..840161e78815 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py index c19666ff1131..2e7a99dcfcf9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeResourceGroupLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py index 5372f4cfbc96..d4d3319e15cf 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py index 234ab5ca72ac..ae4f7e17fa64 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py index 232aeb69eb1a..a14af5fc66bf 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_assignment_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyAssignmentScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyAssignmentScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py index cdf6deb175b6..d53ba49275d1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicyDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py index ad138c15f298..02bdd53dcbec 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_level_policy_set_definition_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicySetDefinitionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeSubscriptionLevelPolicySetDefinitionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py index ece4af494e30..ee366a0b4d43 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py index a9f09f35b72e..e00ba4f1ba10 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_summarize_subscription_scope_for_policy_group.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_SummarizeSubscriptionScopeForPolicyGroup.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_SummarizeSubscriptionScopeForPolicyGroup.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py index 876c56682c52..cab88d8fdad4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_time_range_sort_select_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TimeRangeSortSelectTop.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_TimeRangeSortSelectTop.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py index 8fab901cf95d..8ad41d10cde7 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_resource_group_evaluation.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,13 +31,12 @@ def main(): subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", ) - response = client.policy_states.begin_trigger_resource_group_evaluation( + client.policy_states.begin_trigger_resource_group_evaluation( subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", resource_group_name="myResourceGroup", ).result() - print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerResourceGroupEvaluation.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_TriggerResourceGroupEvaluation.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py index ea852eae5b7b..cf7f204d07c9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_states_trigger_subscription_evaluation.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,12 +31,11 @@ def main(): subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", ) - response = client.policy_states.begin_trigger_subscription_evaluation( + client.policy_states.begin_trigger_subscription_evaluation( subscription_id="fffedd8f-ffff-fffd-fffd-fffed2f84852", ).result() - print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyStates_TriggerSubscriptionEvaluation.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/PolicyStates_TriggerSubscriptionEvaluation.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py index f41a71ecd0af..9dc6330d8ef4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py index 96b8833a865b..600cccd6acb6 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_management_group_scope_with_filter_and_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py index 9c872292b971..c578a7eb341e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py index d3f692ee8141..c06724b01c1f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_group_scope_with_filter_and_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py index 79476d38b08d..a41244ae495e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py index 2339342d4802..db665ca1f4b6 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_resource_scope_with_filter_and_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py index 92807331122b..e2072ff368b3 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py index b53c8f28c49c..5d5e039f6df1 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_tracked_resources_query_subscription_scope_with_filter_and_top.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py index d2f1088dda37..31f81fa0e0f4 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CancelManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py index aceec54a3e4a..d663162bba0b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CancelResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py index 1ce099052620..d743cf61b5fb 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CancelResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py index bc2deee453c6..4ef80b491cd9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_cancel_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CancelSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py index aeaf231bf443..0b96f5d30edb 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CreateManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py index e91c9006b120..00b7b7b7ca73 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CreateResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py index 86a72fbcaa99..5648a784e8bc 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CreateResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py index 9853ccd5f4f9..52a50f4a440a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -40,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CreateSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py index 140abf4e51e0..a219195da8d7 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_all_properties.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -46,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateSubscriptionScope_AllProperties.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CreateSubscriptionScope_AllProperties.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py new file mode 100644 index 000000000000..51f674d5e800 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py @@ -0,0 +1,63 @@ +# pylint: disable=line-too-long,useless-suppression +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.policyinsights import PolicyInsightsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-policyinsights +# USAGE + python remediations_create_subscription_scope_resource_ids_filter.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = PolicyInsightsClient( + credential=DefaultAzureCredential(), + subscription_id="35ee058e-5fa0-414c-8145-3ebb8d09b6e2", + ) + + response = client.remediations.create_or_update_at_subscription( + remediation_name="storageRemediation", + parameters={ + "properties": { + "failureThreshold": {"percentage": 0.1}, + "filters": { + "locations": ["eastus", "westus"], + "resourceIds": [ + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/res2627/providers/Microsoft.Storage/storageAccounts/sto1125", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/testcmk3/providers/Microsoft.Storage/storageAccounts/sto3699", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/res9407/providers/Microsoft.Storage/storageAccounts/sto8596", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/testcmk3/providers/Microsoft.Storage/storageAccounts/sto6637", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/res8186/providers/Microsoft.Storage/storageAccounts/sto834", + "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/testcmk3/providers/Microsoft.Storage/storageAccounts/sto9174", + ], + }, + "parallelDeployments": 6, + "policyAssignmentId": "/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5", + "policyDefinitionReferenceId": "8c8fa9e4", + "resourceCount": 42, + "resourceDiscoveryMode": "ExistingNonCompliant", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_CreateSubscriptionScope_ResourceIdsFilter.json +if __name__ == "__main__": + main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py index 967b33980538..5561c0f67f97 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_DeleteManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py index ef8d88209427..eb86ea24ac4e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_DeleteResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py index e81e3f475544..02b3e4aadcc8 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_DeleteResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py index 97291acabc33..0886e6c0cc93 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_delete_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_DeleteSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py index 88b0ad8b6202..ff5f96d1ffee 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_GetManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py index 86ee657dfd07..a22e7bb6d2de 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_GetResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py index 2fdbd669c251..630f074ed294 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_GetResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py index 3e9ae013f9f4..78148b59cb7e 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_get_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_GetSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py index 4c6ea118ab85..379561560a66 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListDeploymentsManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py index 25597875632b..b1ede6f826bb 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListDeploymentsResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py index 3a9f6e51f241..284303d080bf 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListDeploymentsResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py index fafa3ef41b54..de75c1626669 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_deployments_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListDeploymentsSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py index 4c4fec267eec..a5480b82c91f 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListManagementGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListManagementGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py index 3d4ac96de019..74f3b1eccf05 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_management_group_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListManagementGroupScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListManagementGroupScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py index 39b50dce33c8..682edc63aa88 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceGroupScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListResourceGroupScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py index 39f48bdb9b6b..242f35aa734b 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_group_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceGroupScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListResourceGroupScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py index 7991d968470b..cce76b5e9d1c 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListResourceScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py index 8a732b24f122..a1321f4f33a9 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_resource_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListResourceScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py index 532950739c03..a6aea1498c43 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListSubscriptionScope.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py index 7aaa446c34ad..aab629ab9b37 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_list_subscription_scope_with_query.py @@ -1,3 +1,4 @@ +# pylint: disable=line-too-long,useless-suppression # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,6 +8,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json +# x-ms-original-file: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2024-10-01/examples/Remediations_ListSubscriptionScope_WithQuery.json if __name__ == "__main__": main() diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py new file mode 100644 index 000000000000..3ca9a4ea2524 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# For security, please avoid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + policyinsights_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + policyinsights_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + policyinsights_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + policyinsights_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=policyinsights_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=policyinsights_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=policyinsights_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=policyinsights_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py new file mode 100644 index 000000000000..3d28281e9d55 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations.py @@ -0,0 +1,228 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsAttestationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_list_for_subscription(self, resource_group): + response = self.client.attestations.list_for_subscription( + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_begin_create_or_update_at_subscription(self, resource_group): + response = self.client.attestations.begin_create_or_update_at_subscription( + attestation_name="str", + parameters={ + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "name": "str", + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_get_at_subscription(self, resource_group): + response = self.client.attestations.get_at_subscription( + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_delete_at_subscription(self, resource_group): + response = self.client.attestations.delete_at_subscription( + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_list_for_resource_group(self, resource_group): + response = self.client.attestations.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_begin_create_or_update_at_resource_group(self, resource_group): + response = self.client.attestations.begin_create_or_update_at_resource_group( + resource_group_name=resource_group.name, + attestation_name="str", + parameters={ + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "name": "str", + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_get_at_resource_group(self, resource_group): + response = self.client.attestations.get_at_resource_group( + resource_group_name=resource_group.name, + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_delete_at_resource_group(self, resource_group): + response = self.client.attestations.delete_at_resource_group( + resource_group_name=resource_group.name, + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_list_for_resource(self, resource_group): + response = self.client.attestations.list_for_resource( + resource_id="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_begin_create_or_update_at_resource(self, resource_group): + response = self.client.attestations.begin_create_or_update_at_resource( + resource_id="str", + attestation_name="str", + parameters={ + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "name": "str", + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_get_at_resource(self, resource_group): + response = self.client.attestations.get_at_resource( + resource_id="str", + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_attestations_delete_at_resource(self, resource_group): + response = self.client.attestations.delete_at_resource( + resource_id="str", + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py new file mode 100644 index 000000000000..2e6579bd0d3c --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_attestations_operations_async.py @@ -0,0 +1,235 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsAttestationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_list_for_subscription(self, resource_group): + response = self.client.attestations.list_for_subscription( + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_begin_create_or_update_at_subscription(self, resource_group): + response = await ( + await self.client.attestations.begin_create_or_update_at_subscription( + attestation_name="str", + parameters={ + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "name": "str", + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_get_at_subscription(self, resource_group): + response = await self.client.attestations.get_at_subscription( + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_delete_at_subscription(self, resource_group): + response = await self.client.attestations.delete_at_subscription( + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_list_for_resource_group(self, resource_group): + response = self.client.attestations.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_begin_create_or_update_at_resource_group(self, resource_group): + response = await ( + await self.client.attestations.begin_create_or_update_at_resource_group( + resource_group_name=resource_group.name, + attestation_name="str", + parameters={ + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "name": "str", + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_get_at_resource_group(self, resource_group): + response = await self.client.attestations.get_at_resource_group( + resource_group_name=resource_group.name, + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_delete_at_resource_group(self, resource_group): + response = await self.client.attestations.delete_at_resource_group( + resource_group_name=resource_group.name, + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_list_for_resource(self, resource_group): + response = self.client.attestations.list_for_resource( + resource_id="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_begin_create_or_update_at_resource(self, resource_group): + response = await ( + await self.client.attestations.begin_create_or_update_at_resource( + resource_id="str", + attestation_name="str", + parameters={ + "policyAssignmentId": "str", + "assessmentDate": "2020-02-20 00:00:00", + "comments": "str", + "complianceState": "str", + "evidence": [{"description": "str", "sourceUri": "str"}], + "expiresOn": "2020-02-20 00:00:00", + "id": "str", + "lastComplianceStateChangeAt": "2020-02-20 00:00:00", + "metadata": {}, + "name": "str", + "owner": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_get_at_resource(self, resource_group): + response = await self.client.attestations.get_at_resource( + resource_id="str", + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_attestations_delete_at_resource(self, resource_group): + response = await self.client.attestations.delete_at_resource( + resource_id="str", + attestation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py new file mode 100644 index 000000000000..7a4ef0dfb8bd --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py @@ -0,0 +1,101 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsComponentPolicyStatesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_component_policy_states_list_query_results_for_subscription(self, resource_group): + response = self.client.component_policy_states.list_query_results_for_subscription( + subscription_id="str", + component_policy_states_resource="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_component_policy_states_list_query_results_for_resource_group(self, resource_group): + response = self.client.component_policy_states.list_query_results_for_resource_group( + subscription_id="str", + resource_group_name=resource_group.name, + component_policy_states_resource="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_component_policy_states_list_query_results_for_resource(self, resource_group): + response = self.client.component_policy_states.list_query_results_for_resource( + resource_id="str", + component_policy_states_resource="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_component_policy_states_list_query_results_for_policy_definition(self, resource_group): + response = self.client.component_policy_states.list_query_results_for_policy_definition( + subscription_id="str", + policy_definition_name="str", + component_policy_states_resource="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_component_policy_states_list_query_results_for_subscription_level_policy_assignment(self, resource_group): + response = self.client.component_policy_states.list_query_results_for_subscription_level_policy_assignment( + subscription_id="str", + policy_assignment_name="str", + component_policy_states_resource="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_component_policy_states_list_query_results_for_resource_group_level_policy_assignment( + self, resource_group + ): + response = self.client.component_policy_states.list_query_results_for_resource_group_level_policy_assignment( + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + component_policy_states_resource="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py new file mode 100644 index 000000000000..b6365488243f --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsComponentPolicyStatesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_component_policy_states_list_query_results_for_subscription(self, resource_group): + response = await self.client.component_policy_states.list_query_results_for_subscription( + subscription_id="str", + component_policy_states_resource="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_component_policy_states_list_query_results_for_resource_group(self, resource_group): + response = await self.client.component_policy_states.list_query_results_for_resource_group( + subscription_id="str", + resource_group_name=resource_group.name, + component_policy_states_resource="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_component_policy_states_list_query_results_for_resource(self, resource_group): + response = await self.client.component_policy_states.list_query_results_for_resource( + resource_id="str", + component_policy_states_resource="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_component_policy_states_list_query_results_for_policy_definition(self, resource_group): + response = await self.client.component_policy_states.list_query_results_for_policy_definition( + subscription_id="str", + policy_definition_name="str", + component_policy_states_resource="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_component_policy_states_list_query_results_for_subscription_level_policy_assignment( + self, resource_group + ): + response = ( + await self.client.component_policy_states.list_query_results_for_subscription_level_policy_assignment( + subscription_id="str", + policy_assignment_name="str", + component_policy_states_resource="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_component_policy_states_list_query_results_for_resource_group_level_policy_assignment( + self, resource_group + ): + response = ( + await self.client.component_policy_states.list_query_results_for_resource_group_level_policy_assignment( + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + component_policy_states_resource="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py new file mode 100644 index 000000000000..2baf50570931 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_operations_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py new file mode 100644 index 000000000000..a4e3feee7028 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_operations_list(self, resource_group): + response = await self.client.operations.list( + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py new file mode 100644 index 000000000000..df07c4b9fe93 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyEventsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_management_group(self, resource_group): + response = self.client.policy_events.list_query_results_for_management_group( + policy_events_resource="str", + management_group_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_subscription(self, resource_group): + response = self.client.policy_events.list_query_results_for_subscription( + policy_events_resource="str", + subscription_id="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_resource_group(self, resource_group): + response = self.client.policy_events.list_query_results_for_resource_group( + policy_events_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_resource(self, resource_group): + response = self.client.policy_events.list_query_results_for_resource( + policy_events_resource="str", + resource_id="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_policy_set_definition(self, resource_group): + response = self.client.policy_events.list_query_results_for_policy_set_definition( + policy_events_resource="str", + subscription_id="str", + policy_set_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_policy_definition(self, resource_group): + response = self.client.policy_events.list_query_results_for_policy_definition( + policy_events_resource="str", + subscription_id="str", + policy_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_subscription_level_policy_assignment(self, resource_group): + response = self.client.policy_events.list_query_results_for_subscription_level_policy_assignment( + policy_events_resource="str", + subscription_id="str", + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_events_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): + response = self.client.policy_events.list_query_results_for_resource_group_level_policy_assignment( + policy_events_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py new file mode 100644 index 000000000000..488f0d149769 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_events_operations_async.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyEventsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_management_group(self, resource_group): + response = self.client.policy_events.list_query_results_for_management_group( + policy_events_resource="str", + management_group_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_subscription(self, resource_group): + response = self.client.policy_events.list_query_results_for_subscription( + policy_events_resource="str", + subscription_id="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_resource_group(self, resource_group): + response = self.client.policy_events.list_query_results_for_resource_group( + policy_events_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_resource(self, resource_group): + response = self.client.policy_events.list_query_results_for_resource( + policy_events_resource="str", + resource_id="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_policy_set_definition(self, resource_group): + response = self.client.policy_events.list_query_results_for_policy_set_definition( + policy_events_resource="str", + subscription_id="str", + policy_set_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_policy_definition(self, resource_group): + response = self.client.policy_events.list_query_results_for_policy_definition( + policy_events_resource="str", + subscription_id="str", + policy_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_subscription_level_policy_assignment(self, resource_group): + response = self.client.policy_events.list_query_results_for_subscription_level_policy_assignment( + policy_events_resource="str", + subscription_id="str", + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_events_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): + response = self.client.policy_events.list_query_results_for_resource_group_level_policy_assignment( + policy_events_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py new file mode 100644 index 000000000000..22bae92cfd15 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyMetadataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_metadata_get_resource(self, resource_group): + response = self.client.policy_metadata.get_resource( + resource_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_metadata_list(self, resource_group): + response = self.client.policy_metadata.list( + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py new file mode 100644 index 000000000000..c65064b22e10 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_metadata_operations_async.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyMetadataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_metadata_get_resource(self, resource_group): + response = await self.client.policy_metadata.get_resource( + resource_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_metadata_list(self, resource_group): + response = self.client.policy_metadata.list( + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py new file mode 100644 index 000000000000..95f27b69c8dc --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations.py @@ -0,0 +1,66 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyRestrictionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_restrictions_check_at_subscription_scope(self, resource_group): + response = self.client.policy_restrictions.check_at_subscription_scope( + parameters={ + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": False, + "pendingFields": [{"field": "str", "values": ["str"]}], + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_restrictions_check_at_resource_group_scope(self, resource_group): + response = self.client.policy_restrictions.check_at_resource_group_scope( + resource_group_name=resource_group.name, + parameters={ + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": False, + "pendingFields": [{"field": "str", "values": ["str"]}], + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_restrictions_check_at_management_group_scope(self, resource_group): + response = self.client.policy_restrictions.check_at_management_group_scope( + management_group_id="str", + parameters={ + "pendingFields": [{"field": "str", "values": ["str"]}], + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + }, + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py new file mode 100644 index 000000000000..f0c09a9a6bd1 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_restrictions_operations_async.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyRestrictionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_restrictions_check_at_subscription_scope(self, resource_group): + response = await self.client.policy_restrictions.check_at_subscription_scope( + parameters={ + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": False, + "pendingFields": [{"field": "str", "values": ["str"]}], + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_restrictions_check_at_resource_group_scope(self, resource_group): + response = await self.client.policy_restrictions.check_at_resource_group_scope( + resource_group_name=resource_group.name, + parameters={ + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + "includeAuditEffect": False, + "pendingFields": [{"field": "str", "values": ["str"]}], + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_restrictions_check_at_management_group_scope(self, resource_group): + response = await self.client.policy_restrictions.check_at_management_group_scope( + management_group_id="str", + parameters={ + "pendingFields": [{"field": "str", "values": ["str"]}], + "resourceDetails": {"resourceContent": {}, "apiVersion": "str", "scope": "str"}, + }, + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py new file mode 100644 index 000000000000..326cf9fd65ff --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations.py @@ -0,0 +1,256 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyStatesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_management_group(self, resource_group): + response = self.client.policy_states.list_query_results_for_management_group( + policy_states_resource="str", + management_group_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_management_group(self, resource_group): + response = self.client.policy_states.summarize_for_management_group( + policy_states_summary_resource="str", + management_group_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_subscription(self, resource_group): + response = self.client.policy_states.list_query_results_for_subscription( + policy_states_resource="str", + subscription_id="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_subscription(self, resource_group): + response = self.client.policy_states.summarize_for_subscription( + policy_states_summary_resource="str", + subscription_id="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_resource_group(self, resource_group): + response = self.client.policy_states.list_query_results_for_resource_group( + policy_states_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_resource_group(self, resource_group): + response = self.client.policy_states.summarize_for_resource_group( + policy_states_summary_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_resource(self, resource_group): + response = self.client.policy_states.list_query_results_for_resource( + policy_states_resource="str", + resource_id="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_resource(self, resource_group): + response = self.client.policy_states.summarize_for_resource( + policy_states_summary_resource="str", + resource_id="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_begin_trigger_subscription_evaluation(self, resource_group): + response = self.client.policy_states.begin_trigger_subscription_evaluation( + subscription_id="str", + api_version="2024-10-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_begin_trigger_resource_group_evaluation(self, resource_group): + response = self.client.policy_states.begin_trigger_resource_group_evaluation( + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_policy_set_definition(self, resource_group): + response = self.client.policy_states.list_query_results_for_policy_set_definition( + policy_states_resource="str", + subscription_id="str", + policy_set_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_policy_set_definition(self, resource_group): + response = self.client.policy_states.summarize_for_policy_set_definition( + policy_states_summary_resource="str", + subscription_id="str", + policy_set_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_policy_definition(self, resource_group): + response = self.client.policy_states.list_query_results_for_policy_definition( + policy_states_resource="str", + subscription_id="str", + policy_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_policy_definition(self, resource_group): + response = self.client.policy_states.summarize_for_policy_definition( + policy_states_summary_resource="str", + subscription_id="str", + policy_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_subscription_level_policy_assignment(self, resource_group): + response = self.client.policy_states.list_query_results_for_subscription_level_policy_assignment( + policy_states_resource="str", + subscription_id="str", + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_subscription_level_policy_assignment(self, resource_group): + response = self.client.policy_states.summarize_for_subscription_level_policy_assignment( + policy_states_summary_resource="str", + subscription_id="str", + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): + response = self.client.policy_states.list_query_results_for_resource_group_level_policy_assignment( + policy_states_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_states_summarize_for_resource_group_level_policy_assignment(self, resource_group): + response = self.client.policy_states.summarize_for_resource_group_level_policy_assignment( + policy_states_summary_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py new file mode 100644 index 000000000000..68b3dceadbc6 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_states_operations_async.py @@ -0,0 +1,261 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyStatesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_management_group(self, resource_group): + response = self.client.policy_states.list_query_results_for_management_group( + policy_states_resource="str", + management_group_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_management_group(self, resource_group): + response = await self.client.policy_states.summarize_for_management_group( + policy_states_summary_resource="str", + management_group_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_subscription(self, resource_group): + response = self.client.policy_states.list_query_results_for_subscription( + policy_states_resource="str", + subscription_id="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_subscription(self, resource_group): + response = await self.client.policy_states.summarize_for_subscription( + policy_states_summary_resource="str", + subscription_id="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_resource_group(self, resource_group): + response = self.client.policy_states.list_query_results_for_resource_group( + policy_states_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_resource_group(self, resource_group): + response = await self.client.policy_states.summarize_for_resource_group( + policy_states_summary_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_resource(self, resource_group): + response = self.client.policy_states.list_query_results_for_resource( + policy_states_resource="str", + resource_id="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_resource(self, resource_group): + response = await self.client.policy_states.summarize_for_resource( + policy_states_summary_resource="str", + resource_id="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_begin_trigger_subscription_evaluation(self, resource_group): + response = await ( + await self.client.policy_states.begin_trigger_subscription_evaluation( + subscription_id="str", + api_version="2024-10-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_begin_trigger_resource_group_evaluation(self, resource_group): + response = await ( + await self.client.policy_states.begin_trigger_resource_group_evaluation( + subscription_id="str", + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_policy_set_definition(self, resource_group): + response = self.client.policy_states.list_query_results_for_policy_set_definition( + policy_states_resource="str", + subscription_id="str", + policy_set_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_policy_set_definition(self, resource_group): + response = await self.client.policy_states.summarize_for_policy_set_definition( + policy_states_summary_resource="str", + subscription_id="str", + policy_set_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_policy_definition(self, resource_group): + response = self.client.policy_states.list_query_results_for_policy_definition( + policy_states_resource="str", + subscription_id="str", + policy_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_policy_definition(self, resource_group): + response = await self.client.policy_states.summarize_for_policy_definition( + policy_states_summary_resource="str", + subscription_id="str", + policy_definition_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_subscription_level_policy_assignment(self, resource_group): + response = self.client.policy_states.list_query_results_for_subscription_level_policy_assignment( + policy_states_resource="str", + subscription_id="str", + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_subscription_level_policy_assignment(self, resource_group): + response = await self.client.policy_states.summarize_for_subscription_level_policy_assignment( + policy_states_summary_resource="str", + subscription_id="str", + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_list_query_results_for_resource_group_level_policy_assignment(self, resource_group): + response = self.client.policy_states.list_query_results_for_resource_group_level_policy_assignment( + policy_states_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_states_summarize_for_resource_group_level_policy_assignment(self, resource_group): + response = await self.client.policy_states.summarize_for_resource_group_level_policy_assignment( + policy_states_summary_resource="str", + subscription_id="str", + resource_group_name=resource_group.name, + policy_assignment_name="str", + authorization_namespace="Microsoft.Authorization", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py new file mode 100644 index 000000000000..28323a580dea --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations.py @@ -0,0 +1,67 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyTrackedResourcesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_tracked_resources_list_query_results_for_management_group(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_management_group( + management_group_name="str", + policy_tracked_resources_resource="str", + management_groups_namespace="Microsoft.Management", + api_version="2018-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_tracked_resources_list_query_results_for_subscription(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_subscription( + policy_tracked_resources_resource="str", + api_version="2018-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_tracked_resources_list_query_results_for_resource_group(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_resource_group( + resource_group_name=resource_group.name, + policy_tracked_resources_resource="str", + api_version="2018-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_policy_tracked_resources_list_query_results_for_resource(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_resource( + resource_id="str", + policy_tracked_resources_resource="str", + api_version="2018-07-01-preview", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py new file mode 100644 index 000000000000..4a1da9718fb4 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_policy_tracked_resources_operations_async.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsPolicyTrackedResourcesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_tracked_resources_list_query_results_for_management_group(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_management_group( + management_group_name="str", + policy_tracked_resources_resource="str", + management_groups_namespace="Microsoft.Management", + api_version="2018-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_tracked_resources_list_query_results_for_subscription(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_subscription( + policy_tracked_resources_resource="str", + api_version="2018-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_tracked_resources_list_query_results_for_resource_group(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_resource_group( + resource_group_name=resource_group.name, + policy_tracked_resources_resource="str", + api_version="2018-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_policy_tracked_resources_list_query_results_for_resource(self, resource_group): + response = self.client.policy_tracked_resources.list_query_results_for_resource( + resource_id="str", + policy_tracked_resources_resource="str", + api_version="2018-07-01-preview", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py new file mode 100644 index 000000000000..8e44e6340978 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations.py @@ -0,0 +1,407 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsRemediationsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_deployments_at_management_group(self, resource_group): + response = self.client.remediations.list_deployments_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_cancel_at_management_group(self, resource_group): + response = self.client.remediations.cancel_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_for_management_group(self, resource_group): + response = self.client.remediations.list_for_management_group( + management_group_id="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_create_or_update_at_management_group(self, resource_group): + response = self.client.remediations.create_or_update_at_management_group( + management_group_id="str", + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_get_at_management_group(self, resource_group): + response = self.client.remediations.get_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_delete_at_management_group(self, resource_group): + response = self.client.remediations.delete_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_deployments_at_subscription(self, resource_group): + response = self.client.remediations.list_deployments_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_cancel_at_subscription(self, resource_group): + response = self.client.remediations.cancel_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_for_subscription(self, resource_group): + response = self.client.remediations.list_for_subscription( + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_create_or_update_at_subscription(self, resource_group): + response = self.client.remediations.create_or_update_at_subscription( + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_get_at_subscription(self, resource_group): + response = self.client.remediations.get_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_delete_at_subscription(self, resource_group): + response = self.client.remediations.delete_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_deployments_at_resource_group(self, resource_group): + response = self.client.remediations.list_deployments_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_cancel_at_resource_group(self, resource_group): + response = self.client.remediations.cancel_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_for_resource_group(self, resource_group): + response = self.client.remediations.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_create_or_update_at_resource_group(self, resource_group): + response = self.client.remediations.create_or_update_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_get_at_resource_group(self, resource_group): + response = self.client.remediations.get_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_delete_at_resource_group(self, resource_group): + response = self.client.remediations.delete_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_deployments_at_resource(self, resource_group): + response = self.client.remediations.list_deployments_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_cancel_at_resource(self, resource_group): + response = self.client.remediations.cancel_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_list_for_resource(self, resource_group): + response = self.client.remediations.list_for_resource( + resource_id="str", + api_version="2024-10-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_create_or_update_at_resource(self, resource_group): + response = self.client.remediations.create_or_update_at_resource( + resource_id="str", + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_get_at_resource(self, resource_group): + response = self.client.remediations.get_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_remediations_delete_at_resource(self, resource_group): + response = self.client.remediations.delete_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py new file mode 100644 index 000000000000..437e14590c53 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_remediations_operations_async.py @@ -0,0 +1,408 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.policyinsights.aio import PolicyInsightsClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPolicyInsightsRemediationsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(PolicyInsightsClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_deployments_at_management_group(self, resource_group): + response = self.client.remediations.list_deployments_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_cancel_at_management_group(self, resource_group): + response = await self.client.remediations.cancel_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_for_management_group(self, resource_group): + response = self.client.remediations.list_for_management_group( + management_group_id="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_create_or_update_at_management_group(self, resource_group): + response = await self.client.remediations.create_or_update_at_management_group( + management_group_id="str", + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_get_at_management_group(self, resource_group): + response = await self.client.remediations.get_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_delete_at_management_group(self, resource_group): + response = await self.client.remediations.delete_at_management_group( + management_group_id="str", + remediation_name="str", + management_groups_namespace="Microsoft.Management", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_deployments_at_subscription(self, resource_group): + response = self.client.remediations.list_deployments_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_cancel_at_subscription(self, resource_group): + response = await self.client.remediations.cancel_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_for_subscription(self, resource_group): + response = self.client.remediations.list_for_subscription( + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_create_or_update_at_subscription(self, resource_group): + response = await self.client.remediations.create_or_update_at_subscription( + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_get_at_subscription(self, resource_group): + response = await self.client.remediations.get_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_delete_at_subscription(self, resource_group): + response = await self.client.remediations.delete_at_subscription( + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_deployments_at_resource_group(self, resource_group): + response = self.client.remediations.list_deployments_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_cancel_at_resource_group(self, resource_group): + response = await self.client.remediations.cancel_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_for_resource_group(self, resource_group): + response = self.client.remediations.list_for_resource_group( + resource_group_name=resource_group.name, + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_create_or_update_at_resource_group(self, resource_group): + response = await self.client.remediations.create_or_update_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_get_at_resource_group(self, resource_group): + response = await self.client.remediations.get_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_delete_at_resource_group(self, resource_group): + response = await self.client.remediations.delete_at_resource_group( + resource_group_name=resource_group.name, + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_deployments_at_resource(self, resource_group): + response = self.client.remediations.list_deployments_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_cancel_at_resource(self, resource_group): + response = await self.client.remediations.cancel_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_list_for_resource(self, resource_group): + response = self.client.remediations.list_for_resource( + resource_id="str", + api_version="2024-10-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_create_or_update_at_resource(self, resource_group): + response = await self.client.remediations.create_or_update_at_resource( + resource_id="str", + remediation_name="str", + parameters={ + "correlationId": "str", + "createdOn": "2020-02-20 00:00:00", + "deploymentStatus": {"failedDeployments": 0, "successfulDeployments": 0, "totalDeployments": 0}, + "failureThreshold": {"percentage": 0.0}, + "filters": {"locations": ["str"], "resourceIds": ["str"]}, + "id": "str", + "lastUpdatedOn": "2020-02-20 00:00:00", + "name": "str", + "parallelDeployments": 0, + "policyAssignmentId": "str", + "policyDefinitionReferenceId": "str", + "provisioningState": "str", + "resourceCount": 0, + "resourceDiscoveryMode": "str", + "statusMessage": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_get_at_resource(self, resource_group): + response = await self.client.remediations.get_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_remediations_delete_at_resource(self, resource_group): + response = await self.client.remediations.delete_at_resource( + resource_id="str", + remediation_name="str", + api_version="2024-10-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/setup.py b/sdk/policyinsights/azure-mgmt-policyinsights/setup.py index 73029b25f6c2..dcf631fd3553 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/setup.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,67 @@ PACKAGE_PPRINT_NAME = "Policy Insights" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'License :: OSI Approved :: MIT License', + "Development Status :: 4 - Beta", + "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "msrest>=0.7.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.5.0", ], - python_requires=">=3.7" + python_requires=">=3.9", )