diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/README.md b/sdk/policyinsights/azure-mgmt-policyinsights/README.md index 507c37cb0e1b..64046d75aac3 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.8+. 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.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -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. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-policyinsights%2FREADME.png) diff --git a/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json b/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json index 0839a738a4e9..d7a59477eb6a 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json +++ b/sdk/policyinsights/azure-mgmt-policyinsights/_meta.json @@ -1,11 +1,11 @@ { - "commit": "f38115ac455af89493b0a0719d9a987404560dda", + "commit": "a750d37f171756aa9c8a2e47b3c79dbeb2bde17d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.2.7", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "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", + "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/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.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/_configuration.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py index e4f19bd2600a..f6f2648508ea 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for PolicyInsightsClient. Note that all parameters used to create this instance are saved as instance @@ -32,7 +31,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 +40,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 +49,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..6b821833f3f8 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 @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import PolicyInsightsClientConfiguration @@ -75,7 +78,25 @@ def __init__( self._config = PolicyInsightsClientConfiguration( credential=credential, subscription_id=subscription_id, **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=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 +118,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 +138,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/_serialization.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_serialization.py index 2c170e28dbca..8139854b97bb 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_serialization.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/_serialization.py @@ -38,7 +38,22 @@ 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, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore @@ -48,12 +63,14 @@ import isodate # type: ignore -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") +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + class RawDeserializer: @@ -107,7 +124,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 +143,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 @@ -153,13 +172,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: @@ -277,8 +289,8 @@ class Model(object): _attribute_map: Dict[str, Dict[str, Any]] = {} _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: 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__) @@ -287,25 +299,25 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" 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: @@ -322,8 +334,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 +346,15 @@ 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(self, keep_readonly=keep_readonly, **kwargs) # type: ignore - 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: @@ -368,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -384,7 +401,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -393,10 +410,15 @@ def deserialize(cls, data, content_type=None): :raises: DeserializationError if something went wrong """ 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: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -409,8 +431,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ 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 +440,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): @@ -518,7 +540,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): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -534,7 +556,7 @@ 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 @@ -602,7 +624,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): @@ -622,12 +644,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,12 +657,13 @@ 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) + raise SerializationError(msg) from err else: return serialized @@ -656,8 +678,8 @@ def body(self, data, data_type, **kwargs): """ # 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: @@ -683,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) 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) @@ -703,6 +725,7 @@ 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: @@ -715,7 +738,9 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -723,10 +748,8 @@ def query(self, name, data, data_type, **kwargs): # 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) @@ -777,6 +800,8 @@ def serialize_data(self, data, data_type, **kwargs): 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) @@ -795,7 +820,7 @@ 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) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -863,6 +888,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): 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'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -875,9 +902,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) @@ -922,7 +954,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): 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: @@ -955,7 +989,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) @@ -1132,10 +1166,10 @@ 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): @@ -1161,7 +1195,8 @@ def rest_key_extractor(attr, attr_desc, data): 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,7 +1205,6 @@ 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:]) @@ -1191,7 +1225,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:]) @@ -1242,7 +1275,7 @@ 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 @@ -1266,7 +1299,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): @@ -1332,7 +1365,7 @@ class Deserializer(object): 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}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1352,7 +1385,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 @@ -1405,12 +1438,12 @@ 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): 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 @@ -1442,7 +1475,7 @@ 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) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1471,22 +1504,22 @@ 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. """ 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 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,7 +1529,7 @@ 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. """ try: @@ -1539,7 +1572,7 @@ 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 @@ -1613,7 +1646,7 @@ 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) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1661,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): 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: @@ -1718,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1769,7 +1802,6 @@ 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: @@ -1823,10 +1855,10 @@ def deserialize_decimal(attr): 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): @@ -1854,7 +1886,7 @@ 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) + raise DeserializationError(msg) from err else: return duration @@ -1871,7 +1903,7 @@ def deserialize_date(attr): 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): @@ -1906,7 +1938,7 @@ def deserialize_rfc(attr): 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) + raise DeserializationError(msg) from err else: return date_obj @@ -1943,7 +1975,7 @@ 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) + raise DeserializationError(msg) from err else: return date_obj @@ -1959,9 +1991,10 @@ def deserialize_unix(attr): 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) + raise DeserializationError(msg) from err else: 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..e5754a47ce68 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.0.0b1" 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..0370c14ed94c 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,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class PolicyInsightsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PolicyInsightsClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for PolicyInsightsClient. Note that all parameters used to create this instance are saved as instance @@ -32,7 +31,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 +40,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 +49,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..75f44c043d11 100644 --- a/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py +++ b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/_policy_insights_client.py @@ -8,9 +8,12 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -76,7 +79,25 @@ def __init__( self._config = PolicyInsightsClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(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), + 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=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) @@ -98,7 +119,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 +141,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/_attestations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/aio/operations/_attestations_operations.py index 1e9c5d0d72b7..a26e7962ab5e 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -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,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._attestations_operations import ( build_create_or_update_at_resource_group_request, build_create_or_update_at_resource_request, @@ -45,10 +46,10 @@ build_list_for_subscription_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +81,6 @@ def list_for_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 +88,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -107,24 +107,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 +131,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 +148,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -168,58 +162,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 +228,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 +236,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 +255,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 +272,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 +289,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 +305,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 +321,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,22 +336,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,16 +360,12 @@ 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 @@ -418,12 +375,11 @@ async def delete_at_subscription( # pylint: disable=inconsistent-return-stateme :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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -434,22 +390,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,11 +415,7 @@ 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( @@ -477,7 +428,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 +435,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -504,25 +454,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 +479,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 +496,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -566,19 +514,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 +534,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 +585,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 +596,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 +609,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 +621,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 +634,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 +645,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 +663,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 +679,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 +700,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,23 +715,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,16 +740,12 @@ 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 @@ -843,12 +758,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -859,23 +773,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,11 +799,7 @@ 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( @@ -902,7 +811,6 @@ def list_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 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 +818,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -929,24 +837,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 +861,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 +878,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -988,58 +892,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 +961,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 +972,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 +984,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 +996,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 +1004,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 +1015,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 +1033,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 +1049,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 +1067,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1210,22 +1082,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,16 +1106,12 @@ 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 @@ -1256,12 +1123,11 @@ async 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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1272,22 +1138,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 +1163,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..60e80e73214a 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,14 +19,12 @@ 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 ...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, @@ -36,10 +34,10 @@ build_list_query_results_for_subscription_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -105,12 +103,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,10 +118,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 +132,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 +149,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 +201,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -225,10 +216,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 +231,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 +248,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 +300,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -330,10 +315,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 +330,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 +347,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 +399,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,10 +417,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 +433,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 +450,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 +502,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -555,10 +520,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 +536,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 +553,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 +608,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -671,10 +626,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 +643,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 +660,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..3dc845c0889e 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,18 @@ 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 ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -59,12 +57,11 @@ def __init__(self, *args, **kwargs) -> None: 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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -75,20 +72,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 +94,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..0201f6c78ca2 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Literal, Optional, Type, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,14 +19,12 @@ 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 ...operations._policy_events_operations import ( build_list_query_results_for_management_group_request, build_list_query_results_for_policy_definition_request, @@ -39,10 +37,10 @@ build_next_link_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,11 +81,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 +91,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -129,7 +122,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 +135,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 +159,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 +178,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 +195,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, @@ -226,7 +212,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 +219,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,7 +250,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 +262,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 +286,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 +305,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 +322,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, @@ -364,7 +342,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 +349,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -403,7 +380,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 +393,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 +417,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 +436,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 +453,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, @@ -500,7 +470,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 +477,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -541,7 +510,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 +523,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 +549,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 +568,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,12 +585,8 @@ 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, @@ -643,11 +605,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 +615,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -689,7 +646,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 +660,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 +684,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 +703,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 +720,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, @@ -790,11 +740,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 +750,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -836,7 +781,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 +795,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 +819,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 +838,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,12 +855,8 @@ 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, @@ -937,11 +875,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 +885,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -983,7 +916,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 +930,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 +954,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 +973,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 +990,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, @@ -1087,11 +1013,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 +1023,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1133,7 +1054,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 +1069,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 +1093,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 +1112,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 +1128,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..338afa0970c5 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,21 +19,19 @@ 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 ...operations._policy_metadata_operations import build_get_resource_request, build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -63,12 +61,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -79,21 +76,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,14 +99,12 @@ 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( @@ -120,7 +114,6 @@ def list( :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 +122,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -146,22 +139,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 +161,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 +177,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..b5cfa9e3deb9 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,24 +19,22 @@ 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 ...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, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +69,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 +76,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 +92,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -121,33 +114,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 +149,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 +176,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 +183,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 +192,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 +203,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 +211,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -247,34 +229,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 +265,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 +290,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 +297,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 +317,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -387,34 +346,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 +382,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..2048e30cce33 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # 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 typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, Literal, Optional, Type, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -16,12 +16,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 +30,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._policy_states_operations import ( build_list_query_results_for_management_group_request, build_list_query_results_for_policy_definition_request, @@ -52,10 +52,10 @@ build_trigger_subscription_evaluation_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -97,11 +97,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 +107,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -143,7 +138,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 +151,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 +175,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 +194,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 +211,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 +230,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -265,7 +248,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 +261,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 +270,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 +287,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( @@ -334,7 +312,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 +319,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -373,7 +350,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 +362,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 +386,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 +405,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 +422,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 +441,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -487,7 +456,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 +469,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 +477,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 +494,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( @@ -558,7 +522,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 +529,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -597,7 +560,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 +573,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 +597,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 +616,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 +633,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 +655,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -715,7 +670,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 +683,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 +692,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 +709,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( @@ -784,7 +734,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 +741,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -825,7 +774,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 +787,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 +813,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 +832,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 +849,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 +868,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -942,7 +883,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 +896,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 +904,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 +921,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1006,36 +942,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 +983,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 +990,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 +1004,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 +1020,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1113,37 +1042,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 +1088,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 +1095,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 +1110,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,20 +1126,16 @@ 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, @@ -1233,11 +1155,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 +1165,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1279,7 +1196,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 +1210,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 +1234,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 +1253,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 +1270,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 +1292,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1405,7 +1310,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 +1323,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 +1333,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 +1350,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( @@ -1478,11 +1378,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 +1388,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1524,7 +1419,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 +1433,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 +1457,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 +1476,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 +1493,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 +1515,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1650,7 +1533,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 +1546,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 +1556,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,19 +1573,15 @@ 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, @@ -1723,11 +1601,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 +1611,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1769,7 +1642,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 +1656,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 +1680,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 +1699,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 +1716,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 +1738,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1895,7 +1756,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 +1769,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 +1779,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 +1796,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, @@ -1971,11 +1827,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 +1837,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2017,7 +1868,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 +1883,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 +1907,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 +1926,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 +1943,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 +1968,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2147,7 +1986,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 +1999,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 +2010,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 +2027,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..a7fdc228e0ee 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # 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 typing import Any, AsyncIterable, Callable, Dict, Literal, Optional, Type, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,14 +19,12 @@ 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 ...operations._policy_tracked_resources_operations import ( build_list_query_results_for_management_group_request, build_list_query_results_for_resource_group_request, @@ -34,10 +32,10 @@ build_list_query_results_for_subscription_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,11 +77,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 +89,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -117,26 +108,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 +134,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,10 +151,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/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_subscription( self, @@ -181,7 +166,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 +175,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -212,25 +194,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 +219,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 +236,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, @@ -278,7 +254,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 +263,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -309,26 +282,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 +308,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 +325,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, @@ -376,7 +343,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 +352,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -407,25 +371,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 +396,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 +412,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..b6398c335c63 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 @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, AsyncIterable, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -19,15 +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.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 ...operations._remediations_operations import ( build_cancel_at_management_group_request, build_cancel_at_resource_group_request, @@ -55,10 +54,10 @@ build_list_for_subscription_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -98,11 +97,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 +109,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -132,25 +126,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 +151,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 +168,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 +178,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -213,23 +196,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,16 +221,12 @@ 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( @@ -260,11 +238,6 @@ def list_for_management_group( :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 +248,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,25 +267,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 +292,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 +309,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 +330,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 +340,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 +352,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 +363,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 +375,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -442,19 +396,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 +416,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 +433,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 +450,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -528,23 +468,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 +493,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 +510,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -598,23 +528,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,16 +555,12 @@ 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( @@ -647,7 +572,6 @@ def list_deployments_at_subscription( :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 +581,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -674,24 +598,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 +622,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 +639,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -743,22 +660,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,16 +684,12 @@ 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( @@ -787,7 +699,6 @@ def list_for_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 +706,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -814,24 +725,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 +749,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 +766,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 +784,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 +791,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 +809,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -933,34 +833,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 +869,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1007,22 +897,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 +921,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 +934,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1065,22 +949,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 +975,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( @@ -1119,7 +998,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 +1007,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1146,25 +1024,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 +1049,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 +1066,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 +1076,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1220,23 +1091,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,16 +1116,12 @@ 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( @@ -1267,7 +1133,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 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 +1140,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1294,25 +1159,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 +1184,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 +1201,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 +1222,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 +1232,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 +1244,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 +1255,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 +1267,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1427,19 +1285,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 +1305,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 +1322,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 +1339,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1506,23 +1354,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 +1379,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 +1396,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1569,23 +1411,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 +1438,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( @@ -1624,7 +1461,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 +1470,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1651,24 +1487,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 +1511,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 +1528,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 +1536,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1722,22 +1551,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,16 +1575,12 @@ 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( @@ -1768,7 +1592,6 @@ def list_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 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 +1599,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1795,24 +1618,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 +1642,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 +1659,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 +1680,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 +1690,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 +1702,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 +1713,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 +1721,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1925,34 +1739,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 +1775,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 +1790,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2001,22 +1805,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 +1829,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 +1846,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2063,22 +1861,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 +1887,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..123c9affb52a 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 @@ -10,6 +10,7 @@ from ._models_py3 import AttestationEvidence from ._models_py3 import AttestationListResult from ._models_py3 import CheckManagementGroupRestrictionsRequest +from ._models_py3 import CheckRestrictionEvaluationDetails from ._models_py3 import CheckRestrictionsRequest from ._models_py3 import CheckRestrictionsResourceDetails from ._models_py3 import CheckRestrictionsResult @@ -38,6 +39,7 @@ from ._models_py3 import PolicyAssignmentSummary from ._models_py3 import PolicyDefinitionSummary from ._models_py3 import PolicyDetails +from ._models_py3 import PolicyEffectDetails from ._models_py3 import PolicyEvaluationDetails from ._models_py3 import PolicyEvaluationResult from ._models_py3 import PolicyEvent @@ -89,6 +91,7 @@ "AttestationEvidence", "AttestationListResult", "CheckManagementGroupRestrictionsRequest", + "CheckRestrictionEvaluationDetails", "CheckRestrictionsRequest", "CheckRestrictionsResourceDetails", "CheckRestrictionsResult", @@ -117,6 +120,7 @@ "PolicyAssignmentSummary", "PolicyDefinitionSummary", "PolicyDetails", + "PolicyEffectDetails", "PolicyEvaluationDetails", "PolicyEvaluationResult", "PolicyEvent", 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..c01b917b840b 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 @@ -30,7 +30,7 @@ class Resource(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -51,7 +51,7 @@ 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 @@ -64,10 +64,10 @@ class Attestation(Resource): # pylint: disable=too-many-instance-attributes 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}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -148,8 +148,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. @@ -205,7 +205,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,7 +238,7 @@ 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 @@ -265,8 +265,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 +279,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 = 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 +346,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 +354,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 +399,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 +443,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 -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 +462,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 +488,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 +545,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,7 +618,7 @@ 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 @@ -598,7 +654,7 @@ 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 @@ -767,8 +823,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. @@ -842,8 +898,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 +952,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,7 +1011,7 @@ 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 @@ -998,7 +1054,7 @@ 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 @@ -1041,7 +1097,7 @@ 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 @@ -1062,7 +1118,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 +1138,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 +1158,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 +1211,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 @@ -1187,7 +1243,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 +1252,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 +1264,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 +1273,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.policy_effect = None + self.reason = None class FieldRestrictions(_serialization.Model): @@ -1242,7 +1309,7 @@ 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] @@ -1267,7 +1334,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 +1372,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 +1415,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 +1453,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 +1469,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 +1488,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 +1534,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 +1588,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,7 +1648,7 @@ 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 @@ -1590,6 +1659,29 @@ def __init__(self, **kwargs): self.policy_definition_reference_id = 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 = None + + class PolicyEvaluationDetails(_serialization.Model): """Policy evaluation details. @@ -1610,8 +1702,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,27 +1729,33 @@ 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.effect_details = None class PolicyEvent(_serialization.Model): # pylint: disable=too-many-instance-attributes @@ -1812,8 +1910,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 +2058,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 +2094,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 @@ -2066,7 +2168,7 @@ 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 @@ -2103,7 +2205,7 @@ 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 @@ -2147,7 +2249,7 @@ 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 @@ -2203,7 +2305,7 @@ class PolicyMetadataProperties(PolicyMetadataSlimProperties): "requirements": {"key": "requirements", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.description = None @@ -2240,7 +2342,7 @@ 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 @@ -2418,8 +2520,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. @@ -2569,8 +2671,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,7 +2727,7 @@ 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 @@ -2656,7 +2758,7 @@ 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 @@ -2674,7 +2776,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,7 +2806,7 @@ 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 @@ -2769,8 +2871,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 @@ -2835,7 +2937,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 +3011,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. @@ -2997,7 +3101,7 @@ 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 @@ -3030,7 +3134,7 @@ 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 @@ -3064,7 +3168,7 @@ 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 @@ -3077,19 +3181,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,7 +3229,7 @@ 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 @@ -3133,7 +3249,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,7 +3309,7 @@ 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 @@ -3236,8 +3352,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 +3398,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 +3463,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 +3529,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,7 +3582,7 @@ 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 @@ -3495,7 +3611,7 @@ 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 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/_attestations_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_attestations_operations.py index dec1033e723e..912de5e5526d 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,13 +16,14 @@ 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 @@ -29,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +49,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 +58,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 +73,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") @@ -92,7 +93,7 @@ def build_create_or_update_at_subscription_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") @@ -109,7 +110,7 @@ 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 @@ -122,7 +123,7 @@ def build_get_at_subscription_request(attestation_name: str, subscription_id: st "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,7 +138,7 @@ 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 @@ -150,7 +151,7 @@ def build_delete_at_subscription_request(attestation_name: str, subscription_id: "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,7 +173,7 @@ 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 @@ -187,7 +188,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 +203,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") @@ -225,7 +226,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,7 +245,7 @@ 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 @@ -260,7 +261,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,7 +278,7 @@ 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 @@ -293,7 +294,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 +311,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 +320,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 +335,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 +352,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 +369,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 +379,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 +394,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 +404,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") @@ -439,7 +442,6 @@ def list_for_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 +449,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -466,24 +468,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 +492,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 +509,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -527,58 +523,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 +589,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 +597,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 +616,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 +633,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 +650,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 +666,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 +682,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -733,22 +697,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 +721,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 +736,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -793,22 +751,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,11 +776,7 @@ 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( @@ -836,7 +789,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 +796,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -863,25 +815,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 +840,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 +857,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -925,19 +875,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 +895,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 +946,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 +957,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 +970,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 +982,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 +995,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 +1006,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 +1024,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 +1040,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 +1061,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1154,23 +1076,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 +1101,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 +1119,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1218,23 +1134,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,11 +1160,7 @@ 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( @@ -1261,7 +1172,6 @@ def list_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 Attestation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Attestation] :raises ~azure.core.exceptions.HttpResponseError: @@ -1269,10 +1179,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1288,24 +1198,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 +1222,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 +1239,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1347,58 +1253,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 +1322,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 +1333,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 +1345,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 +1357,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 +1365,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 +1376,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 +1394,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 +1410,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 +1428,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1569,22 +1443,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 +1467,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 +1484,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1631,22 +1499,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 +1524,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..0cec84c72d7d 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime import sys -from typing import Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,18 @@ 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +38,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,7 +54,7 @@ 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 @@ -71,7 +69,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 +94,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,7 +111,7 @@ 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 @@ -129,7 +127,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 +152,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,7 +169,7 @@ 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 @@ -186,7 +184,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 +211,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,7 +231,7 @@ 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 @@ -257,7 +255,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 +280,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,7 +300,7 @@ 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 @@ -326,7 +324,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 +349,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,7 +370,7 @@ 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 @@ -397,7 +395,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") @@ -483,12 +481,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -499,10 +496,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 +510,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 +527,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 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 def list_query_results_for_resource_group( @@ -587,12 +579,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -603,10 +594,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 +609,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 +626,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 +678,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -708,10 +693,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 +708,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 +725,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 +777,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -820,10 +795,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 +811,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 +828,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 +880,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -933,10 +898,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 +914,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 +931,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 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 - 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 +986,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1049,10 +1004,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 +1021,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 +1038,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 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/operations/_operations.py b/sdk/policyinsights/azure-mgmt-policyinsights/azure/mgmt/policyinsights/operations/_operations.py index 3c8442baf3f1..4408acb810e5 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import sys -from typing import Any, Callable, Dict, Optional, TypeVar +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +18,18 @@ 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +41,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 @@ -81,12 +79,11 @@ def __init__(self, *args, **kwargs): 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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,20 +94,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 +116,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..f153f85917cb 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -20,20 +20,18 @@ ) 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +39,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,7 +59,7 @@ 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 @@ -75,7 +73,7 @@ def build_list_query_results_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") @@ -106,7 +104,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 +113,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 +126,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,7 +143,7 @@ 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 @@ -158,7 +156,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 _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,7 +187,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 +196,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 +209,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,7 +227,7 @@ 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 @@ -243,7 +241,7 @@ def build_list_query_results_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") @@ -274,7 +272,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 +281,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 +294,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,7 +312,7 @@ 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 @@ -327,7 +325,7 @@ def build_list_query_results_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") @@ -360,7 +358,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 +367,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 +380,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,7 +401,7 @@ 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 @@ -418,7 +416,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 +447,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 +456,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 +469,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,7 +490,7 @@ 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 @@ -507,7 +505,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 +536,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 +545,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 +558,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,7 +579,7 @@ 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 @@ -596,7 +594,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 +625,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 +634,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 +647,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,7 +669,7 @@ 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 @@ -687,7 +685,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 +716,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 +725,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") @@ -776,11 +774,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 +784,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -822,7 +815,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 +828,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 +852,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 +871,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 +888,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, @@ -919,7 +905,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 +912,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -958,7 +943,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 +955,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 +979,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 +998,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 +1015,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, @@ -1057,7 +1035,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 +1042,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1096,7 +1073,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 +1086,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 +1110,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 +1129,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 +1146,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, @@ -1193,7 +1163,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 +1170,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1234,7 +1203,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 +1216,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 +1242,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 +1261,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,12 +1278,8 @@ 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, @@ -1336,11 +1298,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 +1308,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1382,7 +1339,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 +1353,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 +1377,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 +1396,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 +1413,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, @@ -1483,11 +1433,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 +1443,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1529,7 +1474,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 +1488,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 +1512,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 +1531,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,12 +1548,8 @@ 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, @@ -1630,11 +1568,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 +1578,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1676,7 +1609,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 +1623,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 +1647,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 +1666,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 +1683,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, @@ -1780,11 +1706,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 +1716,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1826,7 +1747,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 +1762,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 +1786,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 +1805,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 +1821,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..88c0d19a9e66 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,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,18 @@ ) 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +42,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 +51,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 +66,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 @@ -110,12 +108,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -126,21 +123,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,14 +146,12 @@ 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( @@ -167,7 +161,6 @@ def list( :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 +168,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -192,22 +185,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 +207,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 +223,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..7245e0755a9f 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -18,20 +19,18 @@ 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,11 +38,13 @@ _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") @@ -55,7 +56,7 @@ def build_check_at_subscription_scope_request(subscription_id: str, **kwargs: An "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 +69,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") @@ -90,7 +91,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 +104,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") @@ -124,7 +127,7 @@ def build_check_at_management_group_scope_request(management_group_id: str, **kw "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") @@ -167,7 +170,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 +177,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 +193,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -218,33 +215,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 +250,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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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 +277,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 +284,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 +293,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 +304,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 +312,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -344,34 +330,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 +366,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 +391,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 +398,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 +418,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -484,34 +447,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 +483,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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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..a52a3f846edf 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime import sys -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +from typing import Any, Callable, Dict, Iterable, Iterator, Literal, Optional, Type, TypeVar, Union, cast from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,13 +16,14 @@ 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 @@ -30,12 +31,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +43,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,7 +63,7 @@ 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 @@ -77,7 +77,7 @@ def build_list_query_results_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") @@ -108,7 +108,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 +117,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 +130,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,7 +146,7 @@ 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 @@ -162,7 +162,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 +181,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,7 +198,7 @@ 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 @@ -211,7 +211,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 _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -242,7 +242,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 +251,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,7 +277,7 @@ 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 @@ -292,7 +292,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 +311,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,7 +329,7 @@ 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 @@ -343,7 +343,7 @@ def build_list_query_results_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") @@ -374,7 +374,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 +383,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 +396,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,7 +410,7 @@ 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 @@ -426,7 +426,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 +445,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,7 +463,7 @@ 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 @@ -476,7 +476,7 @@ def build_list_query_results_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") @@ -509,7 +509,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 +518,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,7 +544,7 @@ 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 @@ -559,7 +559,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,11 +578,13 @@ 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 @@ -594,7 +596,7 @@ def build_trigger_subscription_evaluation_request(subscription_id: str, **kwargs "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,13 +607,13 @@ 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 @@ -624,7 +626,7 @@ def build_trigger_resource_group_evaluation_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") @@ -635,7 +637,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,7 +658,7 @@ 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 @@ -671,7 +673,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 +704,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 +713,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 +726,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,7 +743,7 @@ 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 @@ -758,7 +760,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 +779,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,7 +800,7 @@ 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 @@ -813,7 +815,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 +846,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 +855,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 +868,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,7 +885,7 @@ 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 @@ -900,7 +902,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 +921,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,7 +942,7 @@ 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 @@ -955,7 +957,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 +988,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 +997,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 +1010,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,7 +1027,7 @@ 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 @@ -1042,7 +1044,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 +1063,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,7 +1085,7 @@ 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 @@ -1099,7 +1101,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 +1132,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 +1141,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 +1154,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,7 +1172,7 @@ 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 @@ -1188,7 +1190,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") @@ -1244,11 +1246,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 +1256,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1290,7 +1287,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 +1300,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 +1324,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 +1343,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 +1360,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 +1379,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1412,7 +1397,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 +1410,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 +1419,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 +1436,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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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( @@ -1481,7 +1461,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 +1468,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1520,7 +1499,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 +1511,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 +1535,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 +1554,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 +1571,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 +1590,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1634,7 +1605,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 +1618,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 +1626,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 +1643,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( @@ -1705,7 +1671,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 +1678,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1744,7 +1709,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 +1722,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 +1746,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 +1765,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 +1782,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 +1804,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1862,7 +1819,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 +1832,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 +1841,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 +1858,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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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( @@ -1931,7 +1883,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 +1890,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1972,7 +1923,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 +1936,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 +1962,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 +1981,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 +1998,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 +2017,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2089,7 +2032,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 +2045,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 +2053,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 +2070,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 deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - 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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2153,36 +2089,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 +2130,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 +2137,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 +2151,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 +2167,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 - - begin_trigger_subscription_evaluation.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/latest/triggerEvaluation" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - 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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2260,37 +2189,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 +2235,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 +2242,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 +2257,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,20 +2273,16 @@ 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, @@ -2380,11 +2302,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 +2312,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2426,7 +2343,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 +2357,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 +2381,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 +2400,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 +2417,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 +2439,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2552,7 +2457,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 +2470,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 +2480,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 +2497,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( @@ -2625,11 +2525,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 +2535,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2671,7 +2566,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 +2580,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 +2604,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 +2623,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 +2640,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 +2662,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2797,7 +2680,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 +2693,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 +2703,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,19 +2720,15 @@ 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, @@ -2870,11 +2748,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 +2758,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2916,7 +2789,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 +2803,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 +2827,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 +2846,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 +2863,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 +2885,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3042,7 +2903,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 +2916,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 +2926,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 +2943,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, @@ -3118,11 +2974,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 +2984,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3164,7 +3015,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 +3030,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 +3054,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 +3073,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 +3090,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 +3115,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -3294,7 +3133,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 +3146,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 +3157,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 +3174,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 cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - summarize_for_resource_group_level_policy_assignment.metadata = { - "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize" - } + 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..77fb3cce4bf1 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,7 @@ # 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 typing import Any, Callable, Dict, Iterable, Literal, Optional, Type, TypeVar, Union from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +19,18 @@ ) 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +38,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,9 +52,7 @@ 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 @@ -72,7 +68,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 +83,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,9 +94,7 @@ 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 @@ -115,7 +109,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 +124,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,9 +136,7 @@ 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 @@ -160,7 +152,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 +167,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,9 +178,7 @@ 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 @@ -203,7 +193,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: @@ -255,11 +245,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 +256,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -292,26 +275,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 +301,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,10 +318,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/policyTrackedResources/{policyTrackedResourcesResource}/queryResults" - } - @distributed_trace def list_query_results_for_subscription( self, @@ -356,7 +333,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 +341,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -386,25 +360,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 +385,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 +402,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, @@ -452,7 +420,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 +428,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -482,26 +447,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 +473,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 +490,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, @@ -549,7 +508,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 +516,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -579,25 +535,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 +560,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 +576,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..c74b299f4cad 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=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from typing import Any, Callable, Dict, IO, Iterable, Literal, Optional, Type, TypeVar, Union, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -19,20 +20,18 @@ ) 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 -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +39,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,7 +48,7 @@ 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 @@ -63,7 +62,7 @@ def build_list_deployments_at_management_group_request( "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,7 +84,7 @@ 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 @@ -99,7 +98,7 @@ def build_cancel_at_management_group_request( "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,7 +118,7 @@ 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 @@ -132,7 +131,7 @@ def build_list_for_management_group_request( "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 +146,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 +155,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") @@ -171,7 +170,7 @@ def build_create_or_update_at_management_group_request( "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,7 +192,7 @@ 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 @@ -207,7 +206,7 @@ def build_get_at_management_group_request( "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,7 +226,7 @@ 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 @@ -241,7 +240,7 @@ def build_delete_at_management_group_request( "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,13 +251,13 @@ 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 @@ -271,7 +270,7 @@ def build_list_deployments_at_subscription_request( "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,7 +287,7 @@ 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 @@ -301,7 +300,7 @@ def build_cancel_at_subscription_request(remediation_name: str, subscription_id: "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 +317,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 +326,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 +341,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") @@ -362,7 +361,7 @@ def build_create_or_update_at_subscription_request( "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,7 +378,7 @@ 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 @@ -392,7 +391,7 @@ def build_get_at_subscription_request(remediation_name: str, subscription_id: st "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,7 +406,7 @@ 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 @@ -420,7 +419,7 @@ def build_delete_at_subscription_request(remediation_name: str, subscription_id: "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,13 +430,13 @@ 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 @@ -451,7 +450,7 @@ def build_list_deployments_at_resource_group_request( "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,7 +469,7 @@ 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 @@ -484,7 +483,7 @@ def build_cancel_at_resource_group_request( "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,7 +505,7 @@ 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 @@ -519,7 +518,7 @@ def build_list_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 if top is not None: @@ -534,13 +533,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") @@ -555,7 +554,7 @@ def build_create_or_update_at_resource_group_request( "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,7 +573,7 @@ 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 @@ -588,7 +587,7 @@ def build_get_at_resource_group_request( "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,7 +604,7 @@ 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 @@ -619,7 +618,7 @@ def build_delete_at_resource_group_request( "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,13 +629,13 @@ 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 @@ -649,7 +648,7 @@ def build_list_deployments_at_resource_request( "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,7 +665,7 @@ 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 @@ -678,7 +677,7 @@ def build_cancel_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") @@ -695,7 +694,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 +703,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 +718,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 +735,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 +752,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 +762,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 +777,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 +787,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") @@ -832,11 +833,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 +844,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -865,25 +861,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 +886,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 +903,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 +913,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -946,23 +931,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,16 +956,12 @@ 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( @@ -993,11 +973,6 @@ def list_for_management_group( :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 +983,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1027,25 +1002,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 +1027,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 +1044,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 +1065,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 +1075,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 +1087,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 +1098,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 +1110,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1175,19 +1131,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 +1151,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 +1168,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 +1185,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1261,23 +1203,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 +1228,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 +1245,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1331,23 +1263,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,16 +1290,12 @@ 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( @@ -1380,7 +1307,6 @@ def list_deployments_at_subscription( :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 +1315,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1406,24 +1332,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 +1356,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 +1373,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1475,22 +1394,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,16 +1418,12 @@ 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( @@ -1519,7 +1433,6 @@ def list_for_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 +1440,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1546,24 +1459,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 +1483,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 +1500,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 +1518,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 +1525,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 +1543,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1665,34 +1567,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 +1603,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1739,22 +1631,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 +1655,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 +1668,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1797,22 +1683,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 +1709,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( @@ -1851,7 +1732,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 +1740,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1877,25 +1757,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 +1782,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 +1799,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 +1809,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1951,23 +1824,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,16 +1849,12 @@ 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( @@ -1998,7 +1866,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 Remediation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -2006,10 +1873,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2025,25 +1892,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 +1917,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 +1934,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 +1955,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 +1965,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 +1977,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 +1988,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 +2000,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2158,19 +2018,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 +2038,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 +2055,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 +2072,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2237,23 +2087,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 +2112,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 +2129,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2300,23 +2144,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 +2171,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( @@ -2355,7 +2194,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 +2202,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2381,24 +2219,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 +2243,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 +2260,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 +2268,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2452,22 +2283,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,16 +2307,12 @@ 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( @@ -2498,7 +2324,6 @@ def list_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 Remediation or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.policyinsights.models.Remediation] :raises ~azure.core.exceptions.HttpResponseError: @@ -2506,10 +2331,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2525,24 +2350,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 +2374,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 +2391,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 +2412,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 +2422,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 +2434,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 +2445,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 +2453,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2655,34 +2471,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 +2507,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 +2522,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2731,22 +2537,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 +2561,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 +2578,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[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -2793,22 +2593,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 +2619,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..7f36fc64614f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -54,6 +55,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..b68701dcdbbd 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -54,6 +55,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..f5407c271fd3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +42,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..c05db832733f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -53,6 +54,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..9601713420e1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,13 +30,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..4d9759a26d95 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,13 +30,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..49542a34431c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,12 +30,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..4507561e31b1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..ebd5e22f6383 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..ab737aa867bd 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +36,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..c2f1972e5a53 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..0cfe2000a492 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..8b201ec87981 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..f4427a24daaf 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..fdfe2e6393aa 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +35,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..c2b5d0948ebb 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +35,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..f7b520704a2b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..da91b066653d 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..e5554fe034c1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..0ae6ca6e0a02 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..5c11990bc950 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..452c72fe198b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..2920efb2c403 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..27c9ae90c58f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..8927a9eb5287 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..02b4d5674422 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..61d9ce32fd93 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..f0c3cadbdca1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..c0c33625d48c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -33,6 +34,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..1b3e3e64480b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..6c72e9ce157b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..0a67129e3624 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..989c10d42a42 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..0937064f79d5 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..21f4f4305095 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..76064bbe7407 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..c47d48b7ac44 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +40,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..2c64ffc828bd 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +40,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..95090fad489c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..4d5b54c4ecfb 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..5e1f5bd2b056 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..bc828285e1bd 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..fc5c0b327264 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..9a86c243eb42 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..b67926c71aa1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..7fd6c6834102 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..4204fe68337d 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..c974f63c6d46 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..57d79d45a7ea 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..0ff68e7fe1da 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..1e624f6ed752 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..1f34a6903996 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..f6a80886ede5 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..2f15cb306248 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..9ab817f2d72d 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..e00fae20eb72 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +36,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..016547ad21c7 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +35,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..c34b580b5e49 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +35,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..ac21e42ddee3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..fad06c09b577 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -46,6 +47,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..3ac8c33e08cb --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_resource_group_scope_include_audit_effect.py @@ -0,0 +1,53 @@ +# 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..bb561284d45f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -45,6 +46,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..8c27f8f002af --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/policy_restrictions_check_at_subscription_scope_include_audit_effect.py @@ -0,0 +1,52 @@ +# 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..8b41add21643 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..2e9ae53a5327 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..e9bee55b544c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..368ebc26d5c3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..56fe4c60b2f3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..177ff11241aa 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..0a9788afc2a0 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..7b35f8d8dfb1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +40,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..b066b9954b7c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -39,6 +40,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..292f9badf681 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..15bd67dcf183 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..61c727291774 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..8a583d02dec8 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..34bb7e7357d7 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..525f21d8ce82 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..4acf783c5c08 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..e55cd7b1567e 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..fcd5cdbb440e 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..5f3210a7247f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..728b7001e64a 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..63ea3820cdf3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..e1687a230383 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..7bfebcfab9a3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..bd48886f8c1c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..857d3b59bfbc 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..24e2b5345c8d 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..382ee610e6e1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..2655aea3cb81 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -38,6 +39,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..c4fc16773c8b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..83539d5c715e 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..62d8a5fa028a 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..07109430e8c7 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..2995c2ae5d6f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..baa5da23f31d 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..c846ee68924c 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..75a29e3de8d9 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..507cf5905ed1 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,13 +30,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..846f55ee1d84 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -29,12 +30,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..e0a1a1ca1aca 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 @@ -7,6 +7,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..66d2c88463c3 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 @@ -7,6 +7,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..52a3afb66ca4 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 @@ -7,6 +7,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..497c38c68581 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 @@ -7,6 +7,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..6dee1522330d 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 @@ -7,6 +7,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..31318c416e32 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 @@ -7,6 +7,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..7d14291029d1 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 @@ -7,6 +7,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..57ca37987a8d 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 @@ -7,6 +7,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..675e20b79c51 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..0aed46782cc6 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..ff0904ea6324 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..f59e8593f27a 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +36,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..76182f8e347b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +42,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..51362cfeb412 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +42,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..543b81e96dd9 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -41,6 +42,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..87820ff9b907 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -40,6 +41,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..db6b9d30580e 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -46,6 +47,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..30eaf06a79fc --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_samples/remediations_create_subscription_scope_resource_ids_filter.py @@ -0,0 +1,62 @@ +# 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..4da5d7cea63d 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..bfc84a19bf62 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..cf1761ff0506 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..bf58ef2f7a8f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +36,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..76efc643a985 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..4d357349009b 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..9f8afbaaa94f 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..c7ad163b49c3 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -35,6 +36,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..6021fbf011ea 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..2d431745dbc2 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..3078bd3a09d5 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -37,6 +38,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..fda547bb49b4 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..1311deec1ed9 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..54162219c658 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..c0188f92083a 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..bc94d27197f6 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..48d7c06f5ea7 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..1f51b8e847fd 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -36,6 +37,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..a8c66c670ebf 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +35,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..68eb954df4da 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 @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.policyinsights import PolicyInsightsClient """ @@ -34,6 +35,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..d2b2310141c5 --- /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() + + +# aovid 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..676ae57f0679 --- /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_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_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_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_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_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_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_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_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_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_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_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_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..9347212fb42e --- /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_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_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_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_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_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_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_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_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_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_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_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_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..2b282a5aff05 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations.py @@ -0,0 +1,99 @@ +# 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_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_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_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_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_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_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..ce00063142f3 --- /dev/null +++ b/sdk/policyinsights/azure-mgmt-policyinsights/generated_tests/test_policy_insights_component_policy_states_operations_async.py @@ -0,0 +1,104 @@ +# 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_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_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_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_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_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_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..38154f68afe6 --- /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_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..23cc73371d09 --- /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_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..f57e42a2521f --- /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_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_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_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_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_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_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_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_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..a5c843e63408 --- /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_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_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_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_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_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_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_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_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..c04f5e65d7a9 --- /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_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_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..8e395e96814f --- /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_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_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..92aa9273fcc6 --- /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_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_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_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..ef7d0700b8da --- /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_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_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_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..cb12a65948ed --- /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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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..0421d468f526 --- /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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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..5d3a4cb3e056 --- /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_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_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_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_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..faec6b5c8b26 --- /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_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_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_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_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..099e37e9aa27 --- /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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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..a444af22d8ef --- /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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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..fc469383c38f 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,68 @@ 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.8", + "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.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", )