diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/CHANGELOG.md b/sdk/eventgrid/azure-mgmt-eventgrid/CHANGELOG.md index 897751af2c2a..e9fabec75cdd 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/azure-mgmt-eventgrid/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 0.0.0 (it should be stable) (2022-08-17) + + + ## 10.2.0 (2022-06-20) **Features** diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/_meta.json b/sdk/eventgrid/azure-mgmt-eventgrid/_meta.json index 5f81584f7682..9436c5301697 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/_meta.json +++ b/sdk/eventgrid/azure-mgmt-eventgrid/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.0.1", + "@autorest/modelerfour@4.23.5" ], "commit": "34c658b6354f16d452e937ee983bb73386ff50a4", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/eventgrid/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/eventgrid/resource-manager/readme.md --models-mode=msrest --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.0.1 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/eventgrid/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/__init__.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/__init__.py index 755903d6307d..14c9e139ae01 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/__init__.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['EventGridManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["EventGridManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_configuration.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_configuration.py index c359484d356d..2880d401a07b 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_configuration.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_configuration.py @@ -25,24 +25,19 @@ class EventGridManagementClientConfiguration(Configuration): # pylint: disable= Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-06-15". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(EventGridManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", "2022-06-15") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +47,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-eventgrid/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-eventgrid/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - 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.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_event_grid_management_client.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_event_grid_management_client.py index 8df704df72cb..041416e5c2e8 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_event_grid_management_client.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_event_grid_management_client.py @@ -9,20 +9,42 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models from ._configuration import EventGridManagementClientConfiguration -from .operations import ChannelsOperations, DomainEventSubscriptionsOperations, DomainTopicEventSubscriptionsOperations, DomainTopicsOperations, DomainsOperations, EventSubscriptionsOperations, ExtensionTopicsOperations, Operations, PartnerConfigurationsOperations, PartnerNamespacesOperations, PartnerRegistrationsOperations, PartnerTopicEventSubscriptionsOperations, PartnerTopicsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, SystemTopicEventSubscriptionsOperations, SystemTopicsOperations, TopicEventSubscriptionsOperations, TopicTypesOperations, TopicsOperations, VerifiedPartnersOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + ChannelsOperations, + DomainEventSubscriptionsOperations, + DomainTopicEventSubscriptionsOperations, + DomainTopicsOperations, + DomainsOperations, + EventSubscriptionsOperations, + ExtensionTopicsOperations, + Operations, + PartnerConfigurationsOperations, + PartnerNamespacesOperations, + PartnerRegistrationsOperations, + PartnerTopicEventSubscriptionsOperations, + PartnerTopicsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + SystemTopicEventSubscriptionsOperations, + SystemTopicsOperations, + TopicEventSubscriptionsOperations, + TopicTypesOperations, + TopicsOperations, + VerifiedPartnersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class EventGridManagementClient: # pylint: disable=too-many-instance-attributes + +class EventGridManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure EventGrid Management Client. :ivar channels: ChannelsOperations operations @@ -74,10 +96,10 @@ class EventGridManagementClient: # pylint: disable=too-many-instance-attribut :vartype topic_types: azure.mgmt.eventgrid.operations.TopicTypesOperations :ivar verified_partners: VerifiedPartnersOperations operations :vartype verified_partners: azure.mgmt.eventgrid.operations.VerifiedPartnersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -95,7 +117,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = EventGridManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = EventGridManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -105,31 +129,52 @@ def __init__( self.channels = ChannelsOperations(self._client, self._config, self._serialize, self._deserialize) self.domains = DomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.domain_topics = DomainTopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.topic_event_subscriptions = TopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.domain_event_subscriptions = DomainEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.event_subscriptions = EventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.domain_topic_event_subscriptions = DomainTopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.system_topic_event_subscriptions = SystemTopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_topic_event_subscriptions = PartnerTopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.topic_event_subscriptions = TopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.domain_event_subscriptions = DomainEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.event_subscriptions = EventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.domain_topic_event_subscriptions = DomainTopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.system_topic_event_subscriptions = SystemTopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.partner_topic_event_subscriptions = PartnerTopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_configurations = PartnerConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_namespaces = PartnerNamespacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_registrations = PartnerRegistrationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.partner_configurations = PartnerConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.partner_namespaces = PartnerNamespacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.partner_registrations = PartnerRegistrationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.partner_topics = PartnerTopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.system_topics = SystemTopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_topics = ExtensionTopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.extension_topics = ExtensionTopicsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.topic_types = TopicTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.verified_partners = VerifiedPartnersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.verified_partners = VerifiedPartnersOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -138,7 +183,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_patch.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_patch.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_serialization.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_serialization.py new file mode 100644 index 000000000000..648f84cc4e65 --- /dev/null +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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 + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # 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("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_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:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + 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 content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.warning( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + 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"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + 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: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_vendor.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_vendor.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): 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 - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_version.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_version.py index dca644af5794..9f1dc6e309ba 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_version.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0" +VERSION = "0.0.0 (it should be stable)" diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/__init__.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/__init__.py index e6434022dff3..c538725259a5 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/__init__.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._event_grid_management_client import EventGridManagementClient -__all__ = ['EventGridManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["EventGridManagementClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_configuration.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_configuration.py index fe1ec20750c8..b51d8e45888c 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_configuration.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_configuration.py @@ -25,24 +25,19 @@ class EventGridManagementClientConfiguration(Configuration): # pylint: disable= Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-06-15". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(EventGridManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", "2022-06-15") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +47,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-eventgrid/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-eventgrid/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - 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.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + 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.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_event_grid_management_client.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_event_grid_management_client.py index 56b3a49003df..bdd2ced78bcc 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_event_grid_management_client.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_event_grid_management_client.py @@ -9,20 +9,42 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import EventGridManagementClientConfiguration -from .operations import ChannelsOperations, DomainEventSubscriptionsOperations, DomainTopicEventSubscriptionsOperations, DomainTopicsOperations, DomainsOperations, EventSubscriptionsOperations, ExtensionTopicsOperations, Operations, PartnerConfigurationsOperations, PartnerNamespacesOperations, PartnerRegistrationsOperations, PartnerTopicEventSubscriptionsOperations, PartnerTopicsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, SystemTopicEventSubscriptionsOperations, SystemTopicsOperations, TopicEventSubscriptionsOperations, TopicTypesOperations, TopicsOperations, VerifiedPartnersOperations +from .operations import ( + ChannelsOperations, + DomainEventSubscriptionsOperations, + DomainTopicEventSubscriptionsOperations, + DomainTopicsOperations, + DomainsOperations, + EventSubscriptionsOperations, + ExtensionTopicsOperations, + Operations, + PartnerConfigurationsOperations, + PartnerNamespacesOperations, + PartnerRegistrationsOperations, + PartnerTopicEventSubscriptionsOperations, + PartnerTopicsOperations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + SystemTopicEventSubscriptionsOperations, + SystemTopicsOperations, + TopicEventSubscriptionsOperations, + TopicTypesOperations, + TopicsOperations, + VerifiedPartnersOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class EventGridManagementClient: # pylint: disable=too-many-instance-attributes + +class EventGridManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure EventGrid Management Client. :ivar channels: ChannelsOperations operations @@ -76,10 +98,10 @@ class EventGridManagementClient: # pylint: disable=too-many-instance-attribut :vartype topic_types: azure.mgmt.eventgrid.aio.operations.TopicTypesOperations :ivar verified_partners: VerifiedPartnersOperations operations :vartype verified_partners: azure.mgmt.eventgrid.aio.operations.VerifiedPartnersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -97,7 +119,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = EventGridManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = EventGridManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -107,31 +131,52 @@ def __init__( self.channels = ChannelsOperations(self._client, self._config, self._serialize, self._deserialize) self.domains = DomainsOperations(self._client, self._config, self._serialize, self._deserialize) self.domain_topics = DomainTopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.topic_event_subscriptions = TopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.domain_event_subscriptions = DomainEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.event_subscriptions = EventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.domain_topic_event_subscriptions = DomainTopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.system_topic_event_subscriptions = SystemTopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_topic_event_subscriptions = PartnerTopicEventSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.topic_event_subscriptions = TopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.domain_event_subscriptions = DomainEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.event_subscriptions = EventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.domain_topic_event_subscriptions = DomainTopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.system_topic_event_subscriptions = SystemTopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.partner_topic_event_subscriptions = PartnerTopicEventSubscriptionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.topics = TopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_configurations = PartnerConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_namespaces = PartnerNamespacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.partner_registrations = PartnerRegistrationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.partner_configurations = PartnerConfigurationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.partner_namespaces = PartnerNamespacesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.partner_registrations = PartnerRegistrationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.partner_topics = PartnerTopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.system_topics = SystemTopicsOperations(self._client, self._config, self._serialize, self._deserialize) - self.extension_topics = ExtensionTopicsOperations(self._client, self._config, self._serialize, self._deserialize) + self.extension_topics = ExtensionTopicsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.topic_types = TopicTypesOperations(self._client, self._config, self._serialize, self._deserialize) - self.verified_partners = VerifiedPartnersOperations(self._client, self._config, self._serialize, self._deserialize) - + self.verified_partners = VerifiedPartnersOperations( + self._client, self._config, self._serialize, self._deserialize + ) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -140,7 +185,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_patch.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_patch.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/__init__.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/__init__.py index 74227e25aa0d..c04bd7bb5725 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/__init__.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/__init__.py @@ -28,26 +28,32 @@ from ._topic_types_operations import TopicTypesOperations from ._verified_partners_operations import VerifiedPartnersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ChannelsOperations', - 'DomainsOperations', - 'DomainTopicsOperations', - 'TopicEventSubscriptionsOperations', - 'DomainEventSubscriptionsOperations', - 'EventSubscriptionsOperations', - 'DomainTopicEventSubscriptionsOperations', - 'SystemTopicEventSubscriptionsOperations', - 'PartnerTopicEventSubscriptionsOperations', - 'Operations', - 'TopicsOperations', - 'PartnerConfigurationsOperations', - 'PartnerNamespacesOperations', - 'PartnerRegistrationsOperations', - 'PartnerTopicsOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'SystemTopicsOperations', - 'ExtensionTopicsOperations', - 'TopicTypesOperations', - 'VerifiedPartnersOperations', + "ChannelsOperations", + "DomainsOperations", + "DomainTopicsOperations", + "TopicEventSubscriptionsOperations", + "DomainEventSubscriptionsOperations", + "EventSubscriptionsOperations", + "DomainTopicEventSubscriptionsOperations", + "SystemTopicEventSubscriptionsOperations", + "PartnerTopicEventSubscriptionsOperations", + "Operations", + "TopicsOperations", + "PartnerConfigurationsOperations", + "PartnerNamespacesOperations", + "PartnerRegistrationsOperations", + "PartnerTopicsOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "SystemTopicsOperations", + "ExtensionTopicsOperations", + "TopicTypesOperations", + "VerifiedPartnersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_channels_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_channels_operations.py index 9f0a3a0a50f6..ae2b326270aa 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_channels_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_channels_operations.py @@ -6,110 +6,187 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._channels_operations import build_create_or_update_request, build_delete_request_initial, build_get_full_url_request, build_get_request, build_list_by_partner_namespace_request, build_update_request -T = TypeVar('T') +from ...operations._channels_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_full_url_request, + build_get_request, + build_list_by_partner_namespace_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ChannelsOperations: - """ChannelsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ChannelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`channels` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any - ) -> "_models.Channel": + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any + ) -> _models.Channel: """Get a channel. Get properties of a channel. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Channel, or the result of cls(response) + :return: Channel or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Channel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Channel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Channel] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Channel', pipeline_response) + deserialized = self._deserialize("Channel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_info: _models.Channel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Channel: + """Create or update a channel. + + Synchronously creates or updates a new channel with the specified parameters. + + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_info: Channel information. Required. + :type channel_info: ~azure.mgmt.eventgrid.models.Channel + :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: Channel or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.Channel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Channel: + """Create or update a channel. + + Synchronously creates or updates a new channel with the specified parameters. + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_info: Channel information. Required. + :type channel_info: IO + :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: Channel or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.Channel + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -117,55 +194,68 @@ async def create_or_update( resource_group_name: str, partner_namespace_name: str, channel_name: str, - channel_info: "_models.Channel", + channel_info: Union[_models.Channel, IO], **kwargs: Any - ) -> "_models.Channel": + ) -> _models.Channel: """Create or update a channel. Synchronously creates or updates a new channel with the specified parameters. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_name: str - :param channel_info: Channel information. - :type channel_info: ~azure.mgmt.eventgrid.models.Channel + :param channel_info: Channel information. Is either a model type or a IO type. Required. + :type channel_info: ~azure.mgmt.eventgrid.models.Channel 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 - :return: Channel, or the result of cls(response) + :return: Channel or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Channel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Channel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Channel] - _json = self._serialize.body(channel_info, 'Channel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(channel_info, (IO, bytes)): + _content = channel_info + else: + _json = self._serialize.body(channel_info, "Channel") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -173,51 +263,47 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Channel', pipeline_response) + deserialized = self._deserialize("Channel", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Channel', pipeline_response) + deserialized = self._deserialize("Channel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -227,26 +313,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a channel. Delete an existing channel. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_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. @@ -258,53 +340,59 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - @distributed_trace_async + @overload async def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, partner_namespace_name: str, channel_name: str, - channel_update_parameters: "_models.ChannelUpdateParameters", + channel_update_parameters: _models.ChannelUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Update a Channel. @@ -312,47 +400,125 @@ async def update( # pylint: disable=inconsistent-return-statements Synchronously updates a channel with the specified parameters. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_name: str - :param channel_update_parameters: Channel update information. + :param channel_update_parameters: Channel update information. Required. :type channel_update_parameters: ~azure.mgmt.eventgrid.models.ChannelUpdateParameters + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update a Channel. + + Synchronously updates a channel with the specified parameters. + + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_update_parameters: Channel update information. Required. + :type channel_update_parameters: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ - _json = self._serialize.body(channel_update_parameters, 'ChannelUpdateParameters') + @distributed_trace_async + async def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_update_parameters: Union[_models.ChannelUpdateParameters, IO], + **kwargs: Any + ) -> None: + """Update a Channel. + + Synchronously updates a channel with the specified parameters. + + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_update_parameters: Channel update information. Is either a model type or a IO + type. Required. + :type channel_update_parameters: ~azure.mgmt.eventgrid.models.ChannelUpdateParameters 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(channel_update_parameters, (IO, bytes)): + _content = channel_update_parameters + else: + _json = self._serialize.body(channel_update_parameters, "ChannelUpdateParameters") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,8 +528,7 @@ async def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore @distributed_trace def list_by_partner_namespace( @@ -373,14 +538,15 @@ def list_by_partner_namespace( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.ChannelsListResult"]: + ) -> AsyncIterable["_models.Channel"]: """List channels. List all the channels in a partner namespace. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -395,46 +561,44 @@ def list_by_partner_namespace( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ChannelsListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.ChannelsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Channel or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.Channel] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ChannelsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChannelsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_partner_namespace_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_partner_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_partner_namespace.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_partner_namespace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - partner_namespace_name=partner_namespace_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -448,10 +612,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -461,72 +623,67 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_partner_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels"} # type: ignore + list_by_partner_namespace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels"} # type: ignore @distributed_trace_async async def get_full_url( - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of partner destination channel. Get the full endpoint URL of a partner destination channel. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the Channel. + :param channel_name: Name of the Channel. Required. :type channel_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_event_subscriptions_operations.py index a7ccc09f9e1e..688f6532e43d 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_event_subscriptions_operations.py @@ -6,213 +6,232 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._domain_event_subscriptions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_delivery_attributes_request, build_get_full_url_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._domain_event_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_delivery_attributes_request, + build_get_full_url_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DomainEventSubscriptionsOperations: - """DomainEventSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DomainEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`domain_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_delivery_attributes( - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription for domain. Get all delivery attributes for an event subscription for domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain topic. + :param domain_name: Name of the domain topic. Required. :type domain_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a domain. Get properties of an event subscription of a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the partner topic. + :param domain_name: Name of the partner topic. Required. :type domain_name: str :param event_subscription_name: Name of the event subscription to be found. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters only. + Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -220,18 +239,105 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription to a domain. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain topic. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription to a domain. + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain topic. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -239,24 +345,28 @@ async def begin_create_or_update( resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Create or update an event subscription to a domain. Asynchronously creates a new event subscription or updates an existing event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain topic. + :param domain_name: Name of the domain topic. Required. :type domain_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -268,84 +378,84 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -355,28 +465,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete an event subscription for a domain. Delete an existing event subscription for a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :param event_subscription_name: Name of the event subscription to be deleted. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -388,98 +494,193 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update an event subscription for a domain. + + Update an existing event subscription for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update an event subscription for a domain. + + Update an existing event subscription for a topic. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -487,22 +688,27 @@ async def begin_update( resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Update an event subscription for a domain. Update an existing event subscription for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -514,115 +720,115 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async async def get_full_url( - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription for domain. Get the full endpoint URL for an event subscription for domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain topic. + :param domain_name: Name of the domain topic. Required. :type domain_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list( @@ -632,14 +838,15 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all event subscriptions for a specific domain. List all event subscriptions that have been created for a specific topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -654,47 +861,44 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -708,10 +912,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,8 +923,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topic_event_subscriptions_operations.py index b1f8cb8ada9a..9a97d7856299 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topic_event_subscriptions_operations.py @@ -6,114 +6,125 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._domain_topic_event_subscriptions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_delivery_attributes_request, build_get_full_url_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._domain_topic_event_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_delivery_attributes_request, + build_get_full_url_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DomainTopicEventSubscriptionsOperations: - """DomainTopicEventSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DomainTopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`domain_topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get a nested event subscription for domain topic. Get properties of a nested event subscription for a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _create_or_update_initial( self, @@ -121,39 +132,48 @@ async def _create_or_update_initial( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -161,18 +181,111 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update a nested event subscription to a domain topic. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the top level domain. Required. + :type domain_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update a nested event subscription to a domain topic. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the top level domain. Required. + :type domain_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -181,26 +294,30 @@ async def begin_create_or_update( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Create or update a nested event subscription to a domain topic. Asynchronously creates a new event subscription or updates an existing event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -212,19 +329,19 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, @@ -232,67 +349,66 @@ async def begin_create_or_update( event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -302,31 +418,26 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a nested event subscription for a domain topic. Delete a nested existing event subscription for a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be deleted. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -338,46 +449,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _update_initial( self, @@ -385,54 +500,151 @@ async def _update_initial( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update a nested event subscription for a domain topic. + Update an existing event subscription for a domain topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update a nested event subscription for a domain topic. + + Update an existing event subscription for a domain topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -441,24 +653,29 @@ async def begin_update( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Update a nested event subscription for a domain topic. Update an existing event subscription for a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -470,19 +687,19 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, @@ -490,100 +707,99 @@ async def begin_update( event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async async def get_full_url( - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of a nested event subscription for domain topic. Get the full endpoint URL for a nested event subscription for domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list( @@ -594,16 +810,17 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all nested event subscriptions for a specific domain topic. List all event subscriptions that have been created for a specific domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -618,49 +835,45 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - topic_name=topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -674,10 +887,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -687,76 +898,70 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions"} # type: ignore @distributed_trace_async async def get_delivery_attributes( - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription for domain topic. Get all delivery attributes for an event subscription for domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topics_operations.py index 59c3fa7d5b77..b0674d6fb8b0 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domain_topics_operations.py @@ -6,176 +6,178 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._domain_topics_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_domain_request -T = TypeVar('T') +from ...operations._domain_topics_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_domain_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DomainTopicsOperations: - """DomainTopicsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DomainTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`domain_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any - ) -> "_models.DomainTopic": + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any + ) -> _models.DomainTopic: """Get a domain topic. Get properties of a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_topic_name: Name of the topic. + :param domain_topic_name: Name of the topic. Required. :type domain_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DomainTopic, or the result of cls(response) + :return: DomainTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DomainTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainTopic', pipeline_response) + deserialized = self._deserialize("DomainTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any - ) -> "_models.DomainTopic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any + ) -> _models.DomainTopic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopic] + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainTopic', pipeline_response) + deserialized = self._deserialize("DomainTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore @distributed_trace_async async def begin_create_or_update( - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.DomainTopic"]: + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.DomainTopic]: """Create or update a domain topic. Asynchronously creates or updates a new domain topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_topic_name: Name of the domain topic. + :param domain_topic_name: Name of the domain topic. Required. :type domain_topic_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. @@ -188,81 +190,81 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either DomainTopic or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.DomainTopic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopic] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DomainTopic', pipeline_response) + deserialized = self._deserialize("DomainTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -272,26 +274,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a domain topic. Delete existing domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_topic_name: Name of the domain topic. + :param domain_topic_name: Name of the domain topic. Required. :type domain_topic_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. @@ -303,45 +301,49 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore @distributed_trace def list_by_domain( @@ -351,14 +353,15 @@ def list_by_domain( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.DomainTopicsListResult"]: + ) -> AsyncIterable["_models.DomainTopic"]: """List domain topics. List all the topics in a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Domain name. + :param domain_name: Domain name. Required. :type domain_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -373,47 +376,44 @@ def list_by_domain( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DomainTopicsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.DomainTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DomainTopic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.DomainTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_domain.metadata['url'], + api_version=api_version, + template_url=self.list_by_domain.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_domain_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -427,10 +427,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -440,8 +438,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics"} # type: ignore + list_by_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domains_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domains_operations.py index 6f8cfc705e14..1efe2d0a586d 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domains_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_domains_operations.py @@ -6,176 +6,198 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_shared_access_keys_request, build_regenerate_key_request, build_update_request_initial -T = TypeVar('T') +from ...operations._domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_shared_access_keys_request, + build_regenerate_key_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DomainsOperations: - """DomainsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.Domain": + async def get(self, resource_group_name: str, domain_name: str, **kwargs: Any) -> _models.Domain: """Get a domain. Get properties of a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Domain, or the result of cls(response) + :return: Domain or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Domain - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Domain] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - domain_name: str, - domain_info: "_models.Domain", - **kwargs: Any - ) -> "_models.Domain": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_info, 'Domain') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, domain_name: str, domain_info: Union[_models.Domain, IO], **kwargs: Any + ) -> _models.Domain: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Domain] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_info, (IO, bytes)): + _content = domain_info + else: + _json = self._serialize.body(domain_info, "Domain") + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, domain_name: str, - domain_info: "_models.Domain", + domain_info: _models.Domain, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Domain"]: + ) -> AsyncLROPoller[_models.Domain]: """Create or update a domain. Asynchronously creates or updates a new domain with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_info: Domain information. + :param domain_info: Domain information. Required. :type domain_info: ~azure.mgmt.eventgrid.models.Domain + :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 @@ -187,81 +209,152 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either Domain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Domain] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + domain_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Domain]: + """Create or update a domain. + + Asynchronously creates or updates a new domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_info: Domain information. Required. + :type domain_info: IO + :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 Domain or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, domain_name: str, domain_info: Union[_models.Domain, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Domain]: + """Create or update a domain. + + Asynchronously creates or updates a new domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_info: Domain information. Is either a model type or a IO type. Required. + :type domain_info: ~azure.mgmt.eventgrid.models.Domain 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. + :return: An instance of AsyncLROPoller that returns either Domain or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Domain] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_info=domain_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -271,23 +364,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, domain_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete a domain. Delete existing domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_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. @@ -299,80 +387,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore async def _update_initial( self, resource_group_name: str, domain_name: str, - domain_update_parameters: "_models.DomainUpdateParameters", + domain_update_parameters: Union[_models.DomainUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.Domain"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Domain"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_update_parameters, 'DomainUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.Domain]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Domain]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_update_parameters, (IO, bytes)): + _content = domain_update_parameters + else: + _json = self._serialize.body(domain_update_parameters, "DomainUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -381,34 +482,114 @@ async def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + domain_name: str, + domain_update_parameters: _models.DomainUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a domain. + + Asynchronously updates a domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_update_parameters: Domain update information. Required. + :type domain_update_parameters: ~azure.mgmt.eventgrid.models.DomainUpdateParameters + :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 Domain or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + domain_name: str, + domain_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a domain. + Asynchronously updates a domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_update_parameters: Domain update information. Required. + :type domain_update_parameters: IO + :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 Domain or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, domain_name: str, - domain_update_parameters: "_models.DomainUpdateParameters", + domain_update_parameters: Union[_models.DomainUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Domain"]: + ) -> AsyncLROPoller[None]: """Update a domain. Asynchronously updates a domain with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_update_parameters: Domain update information. - :type domain_update_parameters: ~azure.mgmt.eventgrid.models.DomainUpdateParameters + :param domain_update_parameters: Domain update information. Is either a model type or a IO + type. Required. + :type domain_update_parameters: ~azure.mgmt.eventgrid.models.DomainUpdateParameters 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 @@ -420,58 +601,58 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either Domain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Domain] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_update_parameters=domain_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DomainsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.Domain"]: """List domains under an Azure subscription. List all the domains under an Azure subscription. @@ -489,41 +670,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DomainsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.DomainsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Domain or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -537,10 +719,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -550,25 +730,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/domains"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/domains"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.DomainsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.Domain"]: """List domains under a resource group. List all the domains under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -583,43 +758,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DomainsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.DomainsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Domain or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -633,10 +808,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -646,135 +819,204 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains"} # type: ignore @distributed_trace_async async def list_shared_access_keys( - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.DomainSharedAccessKeys": + self, resource_group_name: str, domain_name: str, **kwargs: Any + ) -> _models.DomainSharedAccessKeys: """List keys for a domain. List the two keys used to publish to a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DomainSharedAccessKeys, or the result of cls(response) + :return: DomainSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainSharedAccessKeys] - request = build_list_shared_access_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_shared_access_keys.metadata['url'], + template_url=self.list_shared_access_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("DomainSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_shared_access_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys"} # type: ignore + list_shared_access_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys"} # type: ignore + + @overload + async def regenerate_key( + self, + resource_group_name: str, + domain_name: str, + regenerate_key_request: _models.DomainRegenerateKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DomainSharedAccessKeys: + """Regenerate key for a domain. + + Regenerate a shared access key for a domain. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.DomainRegenerateKeyRequest + :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: DomainSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def regenerate_key( + self, + resource_group_name: str, + domain_name: str, + regenerate_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DomainSharedAccessKeys: + """Regenerate key for a domain. + + Regenerate a shared access key for a domain. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: IO + :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: DomainSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_key( self, resource_group_name: str, domain_name: str, - regenerate_key_request: "_models.DomainRegenerateKeyRequest", + regenerate_key_request: Union[_models.DomainRegenerateKeyRequest, IO], **kwargs: Any - ) -> "_models.DomainSharedAccessKeys": + ) -> _models.DomainSharedAccessKeys: """Regenerate key for a domain. Regenerate a shared access key for a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param regenerate_key_request: Request body to regenerate key. - :type regenerate_key_request: ~azure.mgmt.eventgrid.models.DomainRegenerateKeyRequest + :param regenerate_key_request: Request body to regenerate key. Is either a model type or a IO + type. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.DomainRegenerateKeyRequest 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 - :return: DomainSharedAccessKeys, or the result of cls(response) + :return: DomainSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_key_request, 'DomainRegenerateKeyRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainSharedAccessKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_request, (IO, bytes)): + _content = regenerate_key_request + else: + _json = self._serialize.body(regenerate_key_request, "DomainRegenerateKeyRequest") request = build_regenerate_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("DomainSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_event_subscriptions_operations.py index d8e3a004753f..4eddfe6b4c78 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_event_subscriptions_operations.py @@ -6,54 +6,73 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._event_subscriptions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_delivery_attributes_request, build_get_full_url_request, build_get_request, build_list_by_domain_topic_request, build_list_by_resource_request, build_list_global_by_resource_group_for_topic_type_request, build_list_global_by_resource_group_request, build_list_global_by_subscription_for_topic_type_request, build_list_global_by_subscription_request, build_list_regional_by_resource_group_for_topic_type_request, build_list_regional_by_resource_group_request, build_list_regional_by_subscription_for_topic_type_request, build_list_regional_by_subscription_request, build_update_request_initial -T = TypeVar('T') +from ...operations._event_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_delivery_attributes_request, + build_get_full_url_request, + build_get_request, + build_list_by_domain_topic_request, + build_list_by_resource_request, + build_list_global_by_resource_group_for_topic_type_request, + build_list_global_by_resource_group_request, + build_list_global_by_subscription_for_topic_type_request, + build_list_global_by_subscription_request, + build_list_regional_by_resource_group_for_topic_type_request, + build_list_regional_by_resource_group_request, + build_list_regional_by_subscription_for_topic_type_request, + build_list_regional_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class EventSubscriptionsOperations: - """EventSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + async def get(self, scope: str, event_subscription_name: str, **kwargs: Any) -> _models.EventSubscription: """Get an event subscription. Get properties of an event subscription. @@ -65,112 +84,216 @@ async def get( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _create_or_update_initial( self, scope: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription. + + Asynchronously creates a new event subscription or updates an existing event subscription based + on the specified scope. + + :param scope: The identifier of the resource to which the event subscription needs to be + created or updated. The scope can be a subscription, or a resource group, or a top level + resource belonging to a resource provider namespace, or an EventGrid topic. For example, use + '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription. Event subscription names must + be between 3 and 64 characters in length and should use alphanumeric letters only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription. + + Asynchronously creates a new event subscription or updates an existing event subscription based + on the specified scope. + :param scope: The identifier of the resource to which the event subscription needs to be + created or updated. The scope can be a subscription, or a resource group, or a top level + resource belonging to a resource provider namespace, or an EventGrid topic. For example, use + '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription. Event subscription names must + be between 3 and 64 characters in length and should use alphanumeric letters only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, scope: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Create or update an event subscription. Asynchronously creates a new event subscription or updates an existing event subscription based @@ -184,14 +307,17 @@ async def begin_create_or_update( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str :param event_subscription_name: Name of the event subscription. Event subscription names must - be between 3 and 64 characters in length and should use alphanumeric letters only. + be between 3 and 64 characters in length and should use alphanumeric letters only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -203,80 +329,81 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore scope=scope, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - event_subscription_name: str, - **kwargs: Any + self, scope: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -286,16 +413,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, scope: str, event_subscription_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete an event subscription. Delete an existing event subscription. @@ -307,9 +428,9 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_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. @@ -321,103 +442,204 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _update_initial( self, scope: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update an event subscription. + + Asynchronously updates an existing event subscription. + + :param scope: The scope of existing event subscription. The scope can be a subscription, or a + resource group, or a top level resource belonging to a resource provider namespace, or an + EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update an event subscription. + + Asynchronously updates an existing event subscription. + :param scope: The scope of existing event subscription. The scope can be a subscription, or a + resource group, or a top level resource belonging to a resource provider namespace, or an + EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, scope: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Update an event subscription. Asynchronously updates an existing event subscription. @@ -429,13 +651,17 @@ async def begin_update( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -447,58 +673,58 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore scope=scope, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async async def get_full_url( - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, scope: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription. Get the full endpoint URL for an event subscription. @@ -510,61 +736,58 @@ async def get_full_url( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list_global_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventSubscription"]: """Get an aggregated list of all global event subscriptions under an Azure subscription. List all aggregated global event subscriptions under a specific Azure subscription. @@ -582,43 +805,42 @@ def list_global_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_global_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_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) # type: ignore else: - - request = build_list_global_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -632,10 +854,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -645,25 +865,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_global_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_global_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def list_global_by_subscription_for_topic_type( - self, - topic_type_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + self, topic_type_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventSubscription"]: """List all global event subscriptions for a topic type. List all global event subscriptions under an Azure subscription for a topic type. - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -678,45 +892,43 @@ def list_global_by_subscription_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_global_by_subscription_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_subscription_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_global_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -730,10 +942,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -743,25 +953,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_global_by_subscription_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_global_by_subscription_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_global_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventSubscription"]: """List all global event subscriptions under an Azure subscription and resource group. List all global event subscriptions under a specific Azure subscription and resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -776,45 +981,43 @@ def list_global_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_global_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_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) # type: ignore else: - - request = build_list_global_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -828,10 +1031,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -841,11 +1042,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_global_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_global_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def list_global_by_resource_group_for_topic_type( @@ -855,14 +1054,15 @@ def list_global_by_resource_group_for_topic_type( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all global event subscriptions under a resource group for a topic type. List all global event subscriptions under a resource group for a specific topic type. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -877,47 +1077,44 @@ def list_global_by_resource_group_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_global_by_resource_group_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_resource_group_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_global_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -931,10 +1128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -944,25 +1139,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_global_by_resource_group_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_global_by_resource_group_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_subscription( - self, - location: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + self, location: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription. List all event subscriptions from the given location under a specific Azure subscription. - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -977,45 +1166,43 @@ def list_regional_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_subscription_request( - subscription_id=self._config.subscription_id, location=location, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_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) # type: ignore else: - - request = build_list_regional_by_subscription_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1029,10 +1216,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1042,11 +1227,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_regional_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore + list_regional_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_resource_group( @@ -1056,15 +1239,16 @@ def list_regional_by_resource_group( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription and resource group. List all event subscriptions from the given location under a specific Azure subscription and resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1079,47 +1263,44 @@ def list_regional_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, location=location, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_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) # type: ignore else: - - request = build_list_regional_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - location=location, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1133,10 +1314,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1146,11 +1325,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_regional_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore + list_regional_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_subscription_for_topic_type( @@ -1160,15 +1337,15 @@ def list_regional_by_subscription_for_topic_type( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription for a topic type. List all event subscriptions from the given location under a specific Azure subscription and topic type. - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1183,47 +1360,44 @@ def list_regional_by_subscription_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, location=location, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_subscription_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_subscription_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_regional_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, - location=location, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1237,10 +1411,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1250,11 +1422,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_regional_by_subscription_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_regional_by_subscription_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_resource_group_for_topic_type( @@ -1265,7 +1435,7 @@ def list_regional_by_resource_group_for_topic_type( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription and resource group for a topic type. @@ -1273,10 +1443,11 @@ def list_regional_by_resource_group_for_topic_type( resource group and topic type. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1291,49 +1462,45 @@ def list_regional_by_resource_group_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, location=location, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_resource_group_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_resource_group_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_regional_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - location=location, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1347,10 +1514,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1360,11 +1525,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_regional_by_resource_group_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_regional_by_resource_group_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_by_resource( @@ -1376,18 +1539,19 @@ def list_by_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all event subscriptions. List all event subscriptions that have been created for a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param provider_namespace: Namespace of the provider of the topic. + :param provider_namespace: Namespace of the provider of the topic. Required. :type provider_namespace: str - :param resource_type_name: Name of the resource type. + :param resource_type_name: Name of the resource type. Required. :type resource_type_name: str - :param resource_name: Name of the resource. + :param resource_name: Name of the resource. Required. :type resource_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1402,51 +1566,46 @@ def list_by_resource( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provider_namespace=provider_namespace, resource_type_name=resource_type_name, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - provider_namespace=provider_namespace, - resource_type_name=resource_type_name, - resource_name=resource_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1460,10 +1619,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1473,11 +1630,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def list_by_domain_topic( @@ -1488,16 +1643,17 @@ def list_by_domain_topic( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all event subscriptions for a specific domain topic. List all event subscriptions that have been created for a specific domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1512,49 +1668,45 @@ def list_by_domain_topic( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_domain_topic_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_domain_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_domain_topic.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_domain_topic_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - topic_name=topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1568,10 +1720,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1581,19 +1731,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_domain_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_by_domain_topic.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace_async async def get_delivery_attributes( - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, scope: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription. Get all delivery attributes for an event subscription. @@ -1605,50 +1750,50 @@ async def get_delivery_attributes( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_extension_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_extension_topics_operations.py index ca364929ebb9..419ec94515ef 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_extension_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_extension_topics_operations.py @@ -8,47 +8,49 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import 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._extension_topics_operations import build_get_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ExtensionTopicsOperations: - """ExtensionTopicsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExtensionTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`extension_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - scope: str, - **kwargs: Any - ) -> "_models.ExtensionTopic": + async def get(self, scope: str, **kwargs: Any) -> _models.ExtensionTopic: """Get properties of an extension topic. Get the properties of an extension topic. @@ -58,47 +60,47 @@ async def get( provider namespace. For example, use '/subscriptions/{subscriptionId}/' for a subscription, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' - for Azure resource. + for Azure resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionTopic, or the result of cls(response) + :return: ExtensionTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.ExtensionTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtensionTopic] - request = build_get_request( scope=scope, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionTopic', pipeline_response) + deserialized = self._deserialize("ExtensionTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/extensionTopics/default"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/extensionTopics/default"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_operations.py index 3d5e1da4b887..186c16c9522b 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_operations.py @@ -7,84 +7,90 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import 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._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationsListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """List available operations. List the available operations supported by the Microsoft.EventGrid resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.OperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -98,10 +104,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -111,8 +115,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.EventGrid/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.EventGrid/operations"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_configurations_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_configurations_operations.py index d49ec6738b37..c0a3e4066b6b 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_configurations_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_configurations_operations.py @@ -6,136 +6,158 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._partner_configurations_operations import build_authorize_partner_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_unauthorize_partner_request, build_update_request_initial -T = TypeVar('T') +from ...operations._partner_configurations_operations import ( + build_authorize_partner_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_unauthorize_partner_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PartnerConfigurationsOperations: - """PartnerConfigurationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PartnerConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`partner_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.PartnerConfiguration": + async def get(self, resource_group_name: str, **kwargs: Any) -> _models.PartnerConfiguration: """Get a partner configuration. Get properties of a partner configuration. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerConfiguration, or the result of cls(response) + :return: PartnerConfiguration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, - partner_configuration_info: "_models.PartnerConfiguration", + partner_configuration_info: Union[_models.PartnerConfiguration, IO], **kwargs: Any - ) -> "_models.PartnerConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_configuration_info, 'PartnerConfiguration') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PartnerConfiguration: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_configuration_info, (IO, bytes)): + _content = partner_configuration_info + else: + _json = self._serialize.body(partner_configuration_info, "PartnerConfiguration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -143,34 +165,108 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_configuration_info: _models.PartnerConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerConfiguration]: + """Create or update a partner configuration. + + Synchronously creates or updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_info: Partner configuration information. Required. + :type partner_configuration_info: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :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 PartnerConfiguration or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_configuration_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerConfiguration]: + """Create or update a partner configuration. + Synchronously creates or updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_info: Partner configuration information. Required. + :type partner_configuration_info: IO + :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 PartnerConfiguration or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, - partner_configuration_info: "_models.PartnerConfiguration", + partner_configuration_info: Union[_models.PartnerConfiguration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PartnerConfiguration"]: + ) -> AsyncLROPoller[_models.PartnerConfiguration]: """Create or update a partner configuration. Synchronously creates or updates a partner configuration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_configuration_info: Partner configuration information. - :type partner_configuration_info: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :param partner_configuration_info: Partner configuration information. Is either a model type or + a IO type. Required. + :type partner_configuration_info: ~azure.mgmt.eventgrid.models.PartnerConfiguration 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 @@ -182,78 +278,80 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PartnerConfiguration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_configuration_info=partner_configuration_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -263,20 +361,16 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete a partner configuration. Delete existing partner configuration. :param resource_group_name: The name of the resource group within the user's subscription. + 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. @@ -288,77 +382,92 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore async def _update_initial( self, resource_group_name: str, - partner_configuration_update_parameters: "_models.PartnerConfigurationUpdateParameters", + partner_configuration_update_parameters: Union[_models.PartnerConfigurationUpdateParameters, IO], **kwargs: Any - ) -> "_models.PartnerConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_configuration_update_parameters, 'PartnerConfigurationUpdateParameters') + ) -> _models.PartnerConfiguration: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_configuration_update_parameters, (IO, bytes)): + _content = partner_configuration_update_parameters + else: + _json = self._serialize.body( + partner_configuration_update_parameters, "PartnerConfigurationUpdateParameters" + ) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -366,35 +475,41 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, - partner_configuration_update_parameters: "_models.PartnerConfigurationUpdateParameters", + partner_configuration_update_parameters: _models.PartnerConfigurationUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PartnerConfiguration"]: + ) -> AsyncLROPoller[_models.PartnerConfiguration]: """Update a partner configuration. Synchronously updates a partner configuration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param partner_configuration_update_parameters: Partner configuration update information. + Required. :type partner_configuration_update_parameters: ~azure.mgmt.eventgrid.models.PartnerConfigurationUpdateParameters + :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 @@ -406,98 +521,173 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either PartnerConfiguration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + partner_configuration_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerConfiguration]: + """Update a partner configuration. + + Synchronously updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_update_parameters: Partner configuration update information. + Required. + :type partner_configuration_update_parameters: IO + :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 PartnerConfiguration or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + partner_configuration_update_parameters: Union[_models.PartnerConfigurationUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerConfiguration]: + """Update a partner configuration. + + Synchronously updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_update_parameters: Partner configuration update information. Is + either a model type or a IO type. Required. + :type partner_configuration_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerConfigurationUpdateParameters 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. + :return: An instance of AsyncLROPoller that returns either PartnerConfiguration or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_configuration_update_parameters=partner_configuration_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerConfigurationsListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PartnerConfiguration"]: """List partner configurations under a resource group. List all the partner configurations under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerConfigurationsListResult or the result of + :return: An iterator like instance of either PartnerConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerConfigurationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfigurationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfigurationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -511,10 +701,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -524,19 +712,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerConfigurationsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerConfiguration"]: """List partner configurations under an Azure subscription. List all the partner configurations under an Azure subscription. @@ -554,43 +737,44 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerConfigurationsListResult or the result of + :return: An iterator like instance of either PartnerConfiguration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerConfigurationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfigurationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfigurationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -604,10 +788,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -617,134 +799,250 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore - @distributed_trace_async + @overload async def authorize_partner( self, resource_group_name: str, - partner_info: "_models.Partner", + partner_info: _models.Partner, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PartnerConfiguration": + ) -> _models.PartnerConfiguration: """Authorize a partner. Authorize a single partner either by partner registration immutable Id or by partner name. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_info: The information of the partner to be authorized. + :param partner_info: The information of the partner to be authorized. Required. :type partner_info: ~azure.mgmt.eventgrid.models.Partner + :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: PartnerConfiguration, or the result of cls(response) + :return: PartnerConfiguration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def authorize_partner( + self, resource_group_name: str, partner_info: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PartnerConfiguration: + """Authorize a partner. + + Authorize a single partner either by partner registration immutable Id or by partner name. - _json = self._serialize.body(partner_info, 'Partner') + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be authorized. Required. + :type partner_info: IO + :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: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def authorize_partner( + self, resource_group_name: str, partner_info: Union[_models.Partner, IO], **kwargs: Any + ) -> _models.PartnerConfiguration: + """Authorize a partner. + + Authorize a single partner either by partner registration immutable Id or by partner name. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be authorized. Is either a model type or + a IO type. Required. + :type partner_info: ~azure.mgmt.eventgrid.models.Partner 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 + :return: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_info, (IO, bytes)): + _content = partner_info + else: + _json = self._serialize.body(partner_info, "Partner") request = build_authorize_partner_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.authorize_partner.metadata['url'], + content=_content, + template_url=self.authorize_partner.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - authorize_partner.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner"} # type: ignore - + authorize_partner.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner"} # type: ignore - @distributed_trace_async + @overload async def unauthorize_partner( self, resource_group_name: str, - partner_info: "_models.Partner", + partner_info: _models.Partner, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PartnerConfiguration": + ) -> _models.PartnerConfiguration: """Unauthorize a partner. Unauthorize a single partner either by partner registration immutable Id or by partner name. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_info: The information of the partner to be unauthorized. + :param partner_info: The information of the partner to be unauthorized. Required. :type partner_info: ~azure.mgmt.eventgrid.models.Partner + :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: PartnerConfiguration, or the result of cls(response) + :return: PartnerConfiguration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def unauthorize_partner( + self, resource_group_name: str, partner_info: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PartnerConfiguration: + """Unauthorize a partner. + + Unauthorize a single partner either by partner registration immutable Id or by partner name. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be unauthorized. Required. + :type partner_info: IO + :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: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def unauthorize_partner( + self, resource_group_name: str, partner_info: Union[_models.Partner, IO], **kwargs: Any + ) -> _models.PartnerConfiguration: + """Unauthorize a partner. - _json = self._serialize.body(partner_info, 'Partner') + Unauthorize a single partner either by partner registration immutable Id or by partner name. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be unauthorized. Is either a model type + or a IO type. Required. + :type partner_info: ~azure.mgmt.eventgrid.models.Partner 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 + :return: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_info, (IO, bytes)): + _content = partner_info + else: + _json = self._serialize.body(partner_info, "Partner") request = build_unauthorize_partner_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.unauthorize_partner.metadata['url'], + content=_content, + template_url=self.unauthorize_partner.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unauthorize_partner.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner"} # type: ignore - + unauthorize_partner.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_namespaces_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_namespaces_operations.py index 5138548a8a1d..79090cb088b0 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_namespaces_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_namespaces_operations.py @@ -6,176 +6,279 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._partner_namespaces_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_shared_access_keys_request, build_regenerate_key_request, build_update_request_initial -T = TypeVar('T') +from ...operations._partner_namespaces_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_shared_access_keys_request, + build_regenerate_key_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PartnerNamespacesOperations: - """PartnerNamespacesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PartnerNamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`partner_namespaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any - ) -> "_models.PartnerNamespace": + self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any + ) -> _models.PartnerNamespace: """Get a partner namespace. Get properties of a partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerNamespace, or the result of cls(response) + :return: PartnerNamespace or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespace] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_info: "_models.PartnerNamespace", + partner_namespace_info: Union[_models.PartnerNamespace, IO], **kwargs: Any - ) -> "_models.PartnerNamespace": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_namespace_info, 'PartnerNamespace') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PartnerNamespace: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespace] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_namespace_info, (IO, bytes)): + _content = partner_namespace_info + else: + _json = self._serialize.body(partner_namespace_info, "PartnerNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_info: _models.PartnerNamespace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerNamespace]: + """Create a partner namespace. + + Asynchronously creates a new partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_info: PartnerNamespace information. Required. + :type partner_namespace_info: ~azure.mgmt.eventgrid.models.PartnerNamespace + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerNamespace]: + """Create a partner namespace. + + Asynchronously creates a new partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_info: PartnerNamespace information. Required. + :type partner_namespace_info: IO + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_info: "_models.PartnerNamespace", + partner_namespace_info: Union[_models.PartnerNamespace, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PartnerNamespace"]: + ) -> AsyncLROPoller[_models.PartnerNamespace]: """Create a partner namespace. Asynchronously creates a new partner namespace with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param partner_namespace_info: PartnerNamespace information. - :type partner_namespace_info: ~azure.mgmt.eventgrid.models.PartnerNamespace + :param partner_namespace_info: PartnerNamespace information. Is either a model type or a IO + type. Required. + :type partner_namespace_info: ~azure.mgmt.eventgrid.models.PartnerNamespace 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 @@ -187,81 +290,82 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PartnerNamespace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, partner_namespace_info=partner_namespace_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any + self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -271,23 +375,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a partner namespace. Delete existing partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_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. @@ -299,80 +400,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_update_parameters: "_models.PartnerNamespaceUpdateParameters", + partner_namespace_update_parameters: Union[_models.PartnerNamespaceUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.PartnerNamespace"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PartnerNamespace"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_namespace_update_parameters, 'PartnerNamespaceUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.PartnerNamespace]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PartnerNamespace]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_namespace_update_parameters, (IO, bytes)): + _content = partner_namespace_update_parameters + else: + _json = self._serialize.body(partner_namespace_update_parameters, "PartnerNamespaceUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -381,35 +495,116 @@ async def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_update_parameters: _models.PartnerNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a partner namespace. + + Asynchronously updates a partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_update_parameters: Partner namespace update information. Required. + :type partner_namespace_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerNamespaceUpdateParameters + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a partner namespace. + + Asynchronously updates a partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_update_parameters: Partner namespace update information. Required. + :type partner_namespace_update_parameters: IO + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_update_parameters: "_models.PartnerNamespaceUpdateParameters", + partner_namespace_update_parameters: Union[_models.PartnerNamespaceUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PartnerNamespace"]: + ) -> AsyncLROPoller[None]: """Update a partner namespace. Asynchronously updates a partner namespace with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param partner_namespace_update_parameters: Partner namespace update information. + :param partner_namespace_update_parameters: Partner namespace update information. Is either a + model type or a IO type. Required. :type partner_namespace_update_parameters: - ~azure.mgmt.eventgrid.models.PartnerNamespaceUpdateParameters + ~azure.mgmt.eventgrid.models.PartnerNamespaceUpdateParameters 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 @@ -421,58 +616,58 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either PartnerNamespace or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, partner_namespace_update_parameters=partner_namespace_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerNamespacesListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerNamespace"]: """List partner namespaces under an Azure subscription. List all the partner namespaces under an Azure subscription. @@ -490,43 +685,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerNamespacesListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespacesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerNamespace or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespacesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespacesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -540,10 +734,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -553,25 +745,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerNamespacesListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerNamespace"]: """List partner namespaces under a resource group. List all the partner namespaces under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -586,45 +773,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerNamespacesListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespacesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerNamespace or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespacesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespacesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -638,10 +823,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -651,135 +834,205 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore @distributed_trace_async async def list_shared_access_keys( - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any - ) -> "_models.PartnerNamespaceSharedAccessKeys": + self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any + ) -> _models.PartnerNamespaceSharedAccessKeys: """List keys for a partner namespace. List the two keys used to publish to a partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerNamespaceSharedAccessKeys, or the result of cls(response) + :return: PartnerNamespaceSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespaceSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespaceSharedAccessKeys] - request = build_list_shared_access_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_shared_access_keys.metadata['url'], + template_url=self.list_shared_access_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespaceSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("PartnerNamespaceSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_shared_access_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys"} # type: ignore + list_shared_access_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys"} # type: ignore + + @overload + async def regenerate_key( + self, + resource_group_name: str, + partner_namespace_name: str, + regenerate_key_request: _models.PartnerNamespaceRegenerateKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerNamespaceSharedAccessKeys: + """Regenerate key for a partner namespace. + + Regenerate a shared access key for a partner namespace. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.PartnerNamespaceRegenerateKeyRequest + :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: PartnerNamespaceSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + partner_namespace_name: str, + regenerate_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerNamespaceSharedAccessKeys: + """Regenerate key for a partner namespace. + + Regenerate a shared access key for a partner namespace. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: IO + :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: PartnerNamespaceSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def regenerate_key( self, resource_group_name: str, partner_namespace_name: str, - regenerate_key_request: "_models.PartnerNamespaceRegenerateKeyRequest", + regenerate_key_request: Union[_models.PartnerNamespaceRegenerateKeyRequest, IO], **kwargs: Any - ) -> "_models.PartnerNamespaceSharedAccessKeys": + ) -> _models.PartnerNamespaceSharedAccessKeys: """Regenerate key for a partner namespace. Regenerate a shared access key for a partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param regenerate_key_request: Request body to regenerate key. + :param regenerate_key_request: Request body to regenerate key. Is either a model type or a IO + type. Required. :type regenerate_key_request: ~azure.mgmt.eventgrid.models.PartnerNamespaceRegenerateKeyRequest + 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 - :return: PartnerNamespaceSharedAccessKeys, or the result of cls(response) + :return: PartnerNamespaceSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespaceSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(regenerate_key_request, 'PartnerNamespaceRegenerateKeyRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespaceSharedAccessKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_request, (IO, bytes)): + _content = regenerate_key_request + else: + _json = self._serialize.body(regenerate_key_request, "PartnerNamespaceRegenerateKeyRequest") request = build_regenerate_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespaceSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("PartnerNamespaceSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_registrations_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_registrations_operations.py index 548d369ec82f..cce85136cfdd 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_registrations_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_registrations_operations.py @@ -6,142 +6,163 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._partner_registrations_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial -T = TypeVar('T') +from ...operations._partner_registrations_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PartnerRegistrationsOperations: - """PartnerRegistrationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PartnerRegistrationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`partner_registrations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any - ) -> "_models.PartnerRegistration": + self, resource_group_name: str, partner_registration_name: str, **kwargs: Any + ) -> _models.PartnerRegistration: """Get a partner registration. Gets a partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerRegistration, or the result of cls(response) + :return: PartnerRegistration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerRegistration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistration] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, partner_registration_name: str, - partner_registration_info: "_models.PartnerRegistration", + partner_registration_info: Union[_models.PartnerRegistration, IO], **kwargs: Any - ) -> "_models.PartnerRegistration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_registration_info, 'PartnerRegistration') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PartnerRegistration: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_registration_info, (IO, bytes)): + _content = partner_registration_info + else: + _json = self._serialize.body(partner_registration_info, "PartnerRegistration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -149,37 +170,117 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_info: _models.PartnerRegistration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerRegistration]: + """Create a partner registration. + + Creates a new partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_info: PartnerRegistration information. Required. + :type partner_registration_info: ~azure.mgmt.eventgrid.models.PartnerRegistration + :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 PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PartnerRegistration]: + """Create a partner registration. + + Creates a new partner registration with the specified parameters. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_info: PartnerRegistration information. Required. + :type partner_registration_info: IO + :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 PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, partner_registration_name: str, - partner_registration_info: "_models.PartnerRegistration", + partner_registration_info: Union[_models.PartnerRegistration, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PartnerRegistration"]: + ) -> AsyncLROPoller[_models.PartnerRegistration]: """Create a partner registration. Creates a new partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_name: str - :param partner_registration_info: PartnerRegistration information. - :type partner_registration_info: ~azure.mgmt.eventgrid.models.PartnerRegistration + :param partner_registration_info: PartnerRegistration information. Is either a model type or a + IO type. Required. + :type partner_registration_info: ~azure.mgmt.eventgrid.models.PartnerRegistration 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 @@ -191,81 +292,82 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either PartnerRegistration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistration] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, partner_registration_info=partner_registration_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any + self, resource_group_name: str, partner_registration_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -275,23 +377,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, partner_registration_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a partner registration. Deletes a partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_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. @@ -303,80 +402,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore async def _update_initial( self, resource_group_name: str, partner_registration_name: str, - partner_registration_update_parameters: "_models.PartnerRegistrationUpdateParameters", + partner_registration_update_parameters: Union[_models.PartnerRegistrationUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.PartnerRegistration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PartnerRegistration"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_registration_update_parameters, 'PartnerRegistrationUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.PartnerRegistration]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PartnerRegistration]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_registration_update_parameters, (IO, bytes)): + _content = partner_registration_update_parameters + else: + _json = self._serialize.body(partner_registration_update_parameters, "PartnerRegistrationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -385,35 +497,41 @@ async def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - @distributed_trace_async + @overload async def begin_update( self, resource_group_name: str, partner_registration_name: str, - partner_registration_update_parameters: "_models.PartnerRegistrationUpdateParameters", + partner_registration_update_parameters: _models.PartnerRegistrationUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PartnerRegistration"]: + ) -> AsyncLROPoller[None]: """Update a partner registration. Updates a partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_name: str :param partner_registration_update_parameters: Partner registration update information. + Required. :type partner_registration_update_parameters: ~azure.mgmt.eventgrid.models.PartnerRegistrationUpdateParameters + :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 @@ -425,58 +543,135 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either PartnerRegistration or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a partner registration. + + Updates a partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_update_parameters: Partner registration update information. + Required. + :type partner_registration_update_parameters: IO + :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 PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_update_parameters: Union[_models.PartnerRegistrationUpdateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a partner registration. + + Updates a partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_update_parameters: Partner registration update information. Is + either a model type or a IO type. Required. + :type partner_registration_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerRegistrationUpdateParameters 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. + :return: An instance of AsyncLROPoller that returns either PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, partner_registration_update_parameters=partner_registration_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerRegistrationsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerRegistration"]: """List partner registrations under an Azure subscription. List all the partner registrations under an Azure subscription. @@ -494,43 +689,43 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerRegistrationsListResult or the result of - cls(response) + :return: An iterator like instance of either PartnerRegistration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistrationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistrationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistrationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -544,10 +739,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -557,25 +750,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerRegistrationsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerRegistration"]: """List partner registrations under a resource group. List all the partner registrations under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -590,45 +778,44 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerRegistrationsListResult or the result of - cls(response) + :return: An iterator like instance of either PartnerRegistration or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistrationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistrationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistrationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -642,10 +829,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -655,8 +840,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topic_event_subscriptions_operations.py index 3660b9e3fef5..a5bddc728613 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topic_event_subscriptions_operations.py @@ -6,149 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._partner_topic_event_subscriptions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_delivery_attributes_request, build_get_full_url_request, build_get_request, build_list_by_partner_topic_request, build_update_request_initial -T = TypeVar('T') +from ...operations._partner_topic_event_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_delivery_attributes_request, + build_get_full_url_request, + build_get_request, + build_list_by_partner_topic_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PartnerTopicEventSubscriptionsOperations: - """PartnerTopicEventSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PartnerTopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`partner_topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a partner topic. Get properties of an event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be found. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters only. + Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -156,18 +178,107 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription of a partner topic. + + Asynchronously creates or updates an event subscription of a partner topic with the specified + parameters. Existing event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription of a partner topic. + + Asynchronously creates or updates an event subscription of a partner topic with the specified + parameters. Existing event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -175,25 +286,29 @@ async def begin_create_or_update( resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Create or update an event subscription of a partner topic. Asynchronously creates or updates an event subscription of a partner topic with the specified parameters. Existing event subscriptions will be updated with this API. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -205,84 +320,84 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -292,28 +407,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete an event subscription of a partner topic. Delete an existing event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -325,98 +436,197 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update event subscription of a partner topic. + Update an existing event subscription of a partner topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update event subscription of a partner topic. + + Update an existing event subscription of a partner topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -424,24 +634,29 @@ async def begin_update( resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Update event subscription of a partner topic. Update an existing event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -453,117 +668,117 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async async def get_full_url( - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription of a partner topic. Get the full endpoint URL for an event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list_by_partner_topic( @@ -573,14 +788,15 @@ def list_by_partner_topic( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List event subscriptions of a partner topic. List event subscriptions that belong to a specific partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -595,47 +811,44 @@ def list_by_partner_topic( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_partner_topic_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_partner_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_partner_topic.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_partner_topic_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - partner_topic_name=partner_topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -649,10 +862,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -662,74 +873,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_partner_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions"} # type: ignore + list_by_partner_topic.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions"} # type: ignore @distributed_trace_async async def get_delivery_attributes( - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription of a partner topic. Get all delivery attributes for an event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topics_operations.py index e18837f1f0c0..d80d50f81b20 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_partner_topics_operations.py @@ -6,158 +6,244 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._partner_topics_operations import build_activate_request, build_create_or_update_request, build_deactivate_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._partner_topics_operations import ( + build_activate_request, + build_create_or_update_request, + build_deactivate_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PartnerTopicsOperations: - """PartnerTopicsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PartnerTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`partner_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> "_models.PartnerTopic": + async def get(self, resource_group_name: str, partner_topic_name: str, **kwargs: Any) -> _models.PartnerTopic: """Get a partner topic. Get properties of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_info: _models.PartnerTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerTopic: + """Create a partner topic. + + Asynchronously creates a new partner topic with the specified parameters. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_info: Partner Topic information. Required. + :type partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerTopic + :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: PartnerTopic or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerTopic: + """Create a partner topic. + + Asynchronously creates a new partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_info: Partner Topic information. Required. + :type partner_topic_info: IO + :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: PartnerTopic or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( self, resource_group_name: str, partner_topic_name: str, - partner_topic_info: "_models.PartnerTopic", + partner_topic_info: Union[_models.PartnerTopic, IO], **kwargs: Any - ) -> "_models.PartnerTopic": + ) -> _models.PartnerTopic: """Create a partner topic. Asynchronously creates a new partner topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str - :param partner_topic_info: Partner Topic information. - :type partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerTopic + :param partner_topic_info: Partner Topic information. Is either a model type or a IO type. + Required. + :type partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerTopic 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 - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(partner_topic_info, 'PartnerTopic') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_topic_info, (IO, bytes)): + _content = partner_topic_info + else: + _json = self._serialize.body(partner_topic_info, "PartnerTopic") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -165,49 +251,46 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any + self, resource_group_name: str, partner_topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -217,23 +300,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, partner_topic_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a partner topic. Delete existing partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_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. @@ -245,97 +325,176 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, partner_topic_name: str, - partner_topic_update_parameters: "_models.PartnerTopicUpdateParameters", + partner_topic_update_parameters: _models.PartnerTopicUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Optional["_models.PartnerTopic"]: + ) -> Optional[_models.PartnerTopic]: """Update a partner topic. Asynchronously updates a partner topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str - :param partner_topic_update_parameters: PartnerTopic update information. + :param partner_topic_update_parameters: PartnerTopic update information. Required. :type partner_topic_update_parameters: ~azure.mgmt.eventgrid.models.PartnerTopicUpdateParameters + :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: PartnerTopic or None or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.PartnerTopic]: + """Update a partner topic. + + Asynchronously updates a partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_update_parameters: PartnerTopic update information. Required. + :type partner_topic_update_parameters: IO + :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: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or None or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PartnerTopic"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_update_parameters: Union[_models.PartnerTopicUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.PartnerTopic]: + """Update a partner topic. + + Asynchronously updates a partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_update_parameters: PartnerTopic update information. Is either a model type + or a IO type. Required. + :type partner_topic_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerTopicUpdateParameters 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 + :return: PartnerTopic or None or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - _json = self._serialize.body(partner_topic_update_parameters, 'PartnerTopicUpdateParameters') + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PartnerTopic]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_topic_update_parameters, (IO, bytes)): + _content = partner_topic_update_parameters + else: + _json = self._serialize.body(partner_topic_update_parameters, "PartnerTopicUpdateParameters") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -344,23 +503,19 @@ async def update( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerTopicsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerTopic"]: """List partner topics under an Azure subscription. List all the partner topics under an Azure subscription. @@ -378,43 +533,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerTopicsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerTopic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -428,10 +582,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -441,25 +593,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.PartnerTopicsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.PartnerTopic"]: """List partner topics under a resource group. List all the partner topics under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -474,45 +621,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerTopicsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerTopic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PartnerTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -526,10 +671,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -539,128 +682,120 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore @distributed_trace_async - async def activate( - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> "_models.PartnerTopic": + async def activate(self, resource_group_name: str, partner_topic_name: str, **kwargs: Any) -> _models.PartnerTopic: """Activate a partner topic. Activate a newly created partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - request = build_activate_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.activate.metadata['url'], + template_url=self.activate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - activate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate"} # type: ignore - + activate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate"} # type: ignore @distributed_trace_async async def deactivate( - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> "_models.PartnerTopic": + self, resource_group_name: str, partner_topic_name: str, **kwargs: Any + ) -> _models.PartnerTopic: """Deactivate a partner topic. Deactivate specific partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - request = build_deactivate_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.deactivate.metadata['url'], + template_url=self.deactivate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate"} # type: ignore - + deactivate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_patch.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_endpoint_connections_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_endpoint_connections_operations.py index 40991aa575dd..629e247b3151 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_endpoint_connections_operations.py @@ -6,46 +6,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_by_resource_request, build_update_request_initial -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_by_resource_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -55,68 +67,70 @@ async def get( parent_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Get a specific private endpoint connection. Get a specific private endpoint connection under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param private_endpoint_connection_name: The name of the private endpoint connection - connection. + connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _update_initial( self, @@ -124,39 +138,48 @@ async def _update_initial( parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -164,18 +187,115 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], + parent_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update a specific private endpoint connection. + + Update a specific private endpoint connection under a topic, domain or partner namespace. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param parent_type: The type of the parent resource. This can be either \'topics\', + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. + :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType + :param parent_name: The name of the parent resource (namely, either, the topic name, domain + name, or partner namespace name). Required. + :type parent_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection + connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection object to update. Required. + :type private_endpoint_connection: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], + parent_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Update a specific private endpoint connection. + + Update a specific private endpoint connection under a topic, domain or partner namespace. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param parent_type: The type of the parent resource. This can be either \'topics\', + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. + :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType + :param parent_name: The name of the parent resource (namely, either, the topic name, domain + name, or partner namespace name). Required. + :type parent_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection + connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection object to update. Required. + :type private_endpoint_connection: IO + :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 PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -184,26 +304,32 @@ async def begin_update( parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Update a specific private endpoint connection. Update a specific private endpoint connection under a topic, domain or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param private_endpoint_connection_name: The name of the private endpoint connection - connection. + connection. Required. :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection object to update. - :type private_endpoint_connection: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection + :param private_endpoint_connection: The private endpoint connection object to update. Is either + a model type or a IO type. Required. + :type private_endpoint_connection: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection 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 @@ -216,19 +342,19 @@ async def begin_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, @@ -236,32 +362,35 @@ async def begin_update( private_endpoint_connection=private_endpoint_connection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -271,32 +400,33 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -306,11 +436,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements + async def begin_delete( self, resource_group_name: str, parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], @@ -323,15 +452,17 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Delete a specific private endpoint connection under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param private_endpoint_connection_name: The name of the private endpoint connection - connection. + connection. Required. :type private_endpoint_connection_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. @@ -343,46 +474,50 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list_by_resource( @@ -393,18 +528,20 @@ def list_by_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """Lists all private endpoint connections under a resource. Get all private endpoint connections under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -419,49 +556,47 @@ def list_by_resource( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - parent_type=parent_type, - parent_name=parent_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -475,10 +610,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -488,8 +621,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections"} # type: ignore + list_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_link_resources_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_link_resources_operations.py index af9aac0393da..1ea98ac370e9 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_link_resources_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_private_link_resources_operations.py @@ -7,43 +7,50 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import 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._private_link_resources_operations import build_get_request, build_list_by_resource_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -53,67 +60,68 @@ async def get( parent_name: str, private_link_resource_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": + ) -> _models.PrivateLinkResource: """Get a private link resource. Get properties of a private link resource. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Required. :type parent_type: str :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str - :param private_link_resource_name: The name of private link resource. + :param private_link_resource_name: The name of private link resource. Required. :type private_link_resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_link_resource_name=private_link_resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore @distributed_trace def list_by_resource( @@ -124,18 +132,19 @@ def list_by_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourcesListResult"]: + ) -> AsyncIterable["_models.PrivateLinkResource"]: """List private link resources under specific topic, domain, or partner namespace. List all the private link resources under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Required. :type parent_type: str :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -150,49 +159,46 @@ def list_by_resource( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourcesListResult or the result of - cls(response) + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PrivateLinkResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourcesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - parent_type=parent_type, - parent_name=parent_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -206,10 +212,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -219,8 +223,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources"} # type: ignore + list_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topic_event_subscriptions_operations.py index dda746cdd662..151eb7a6b103 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topic_event_subscriptions_operations.py @@ -6,165 +6,275 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._system_topic_event_subscriptions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_delivery_attributes_request, build_get_full_url_request, build_get_request, build_list_by_system_topic_request, build_update_request_initial -T = TypeVar('T') +from ...operations._system_topic_event_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_delivery_attributes_request, + build_get_full_url_request, + build_get_request, + build_list_by_system_topic_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SystemTopicEventSubscriptionsOperations: - """SystemTopicEventSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SystemTopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`system_topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a system topic. Get an event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription for a system topic. + + Asynchronously creates or updates an event subscription with the specified parameters. Existing + event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription for a system topic. + + Asynchronously creates or updates an event subscription with the specified parameters. Existing + event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -172,25 +282,29 @@ async def begin_create_or_update( resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Create or update an event subscription for a system topic. Asynchronously creates or updates an event subscription with the specified parameters. Existing event subscriptions will be updated with this API. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -202,84 +316,84 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -289,28 +403,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete an event subscription of a system topic. Delete an existing event subscription of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -322,98 +432,197 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update event subscription of a system topic. + Update an existing event subscription of a system topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update event subscription of a system topic. + + Update an existing event subscription of a system topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -421,24 +630,29 @@ async def begin_update( resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Update event subscription of a system topic. Update an existing event subscription of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -450,117 +664,117 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async async def get_full_url( - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription of a system topic. Get the full endpoint URL for an event subscription of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list_by_system_topic( @@ -570,14 +784,15 @@ def list_by_system_topic( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List event subscriptions of a system topic. List event subscriptions that belong to a specific system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -592,47 +807,44 @@ def list_by_system_topic( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_system_topic_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_system_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_system_topic.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_system_topic_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - system_topic_name=system_topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -646,10 +858,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -659,74 +869,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_system_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions"} # type: ignore + list_by_system_topic.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions"} # type: ignore @distributed_trace_async async def get_delivery_attributes( - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription. Get all delivery attributes for an event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topics_operations.py index 10e37adcc11c..12dc132d3d0c 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_system_topics_operations.py @@ -6,142 +6,161 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._system_topics_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial -T = TypeVar('T') +from ...operations._system_topics_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SystemTopicsOperations: - """SystemTopicsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SystemTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`system_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any - ) -> "_models.SystemTopic": + async def get(self, resource_group_name: str, system_topic_name: str, **kwargs: Any) -> _models.SystemTopic: """Get a system topic. Get properties of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SystemTopic, or the result of cls(response) + :return: SystemTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.SystemTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, system_topic_name: str, - system_topic_info: "_models.SystemTopic", + system_topic_info: Union[_models.SystemTopic, IO], **kwargs: Any - ) -> "_models.SystemTopic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(system_topic_info, 'SystemTopic') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.SystemTopic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(system_topic_info, (IO, bytes)): + _content = system_topic_info + else: + _json = self._serialize.body(system_topic_info, "SystemTopic") + + request = build_create_or_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -149,37 +168,117 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_info: _models.SystemTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SystemTopic]: + """Create a system topic. + + Asynchronously creates a new system topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_info: System Topic information. Required. + :type system_topic_info: ~azure.mgmt.eventgrid.models.SystemTopic + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SystemTopic]: + """Create a system topic. + + Asynchronously creates a new system topic with the specified parameters. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_info: System Topic information. Required. + :type system_topic_info: IO + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, system_topic_name: str, - system_topic_info: "_models.SystemTopic", + system_topic_info: Union[_models.SystemTopic, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SystemTopic"]: + ) -> AsyncLROPoller[_models.SystemTopic]: """Create a system topic. Asynchronously creates a new system topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str - :param system_topic_info: System Topic information. - :type system_topic_info: ~azure.mgmt.eventgrid.models.SystemTopic + :param system_topic_info: System Topic information. Is either a model type or a IO type. + Required. + :type system_topic_info: ~azure.mgmt.eventgrid.models.SystemTopic 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 @@ -191,81 +290,82 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either SystemTopic or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.SystemTopic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, system_topic_info=system_topic_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any + self, resource_group_name: str, system_topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -275,23 +375,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, system_topic_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a system topic. Delete existing system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_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. @@ -303,80 +400,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore async def _update_initial( self, resource_group_name: str, system_topic_name: str, - system_topic_update_parameters: "_models.SystemTopicUpdateParameters", + system_topic_update_parameters: Union[_models.SystemTopicUpdateParameters, IO], **kwargs: Any - ) -> "_models.SystemTopic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(system_topic_update_parameters, 'SystemTopicUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.SystemTopic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(system_topic_update_parameters, (IO, bytes)): + _content = system_topic_update_parameters + else: + _json = self._serialize.body(system_topic_update_parameters, "SystemTopicUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -384,37 +494,118 @@ async def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_update_parameters: _models.SystemTopicUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SystemTopic]: + """Update a system topic. + + Asynchronously updates a system topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_update_parameters: SystemTopic update information. Required. + :type system_topic_update_parameters: ~azure.mgmt.eventgrid.models.SystemTopicUpdateParameters + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SystemTopic]: + """Update a system topic. + Asynchronously updates a system topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_update_parameters: SystemTopic update information. Required. + :type system_topic_update_parameters: IO + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, system_topic_name: str, - system_topic_update_parameters: "_models.SystemTopicUpdateParameters", + system_topic_update_parameters: Union[_models.SystemTopicUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SystemTopic"]: + ) -> AsyncLROPoller[_models.SystemTopic]: """Update a system topic. Asynchronously updates a system topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str - :param system_topic_update_parameters: SystemTopic update information. + :param system_topic_update_parameters: SystemTopic update information. Is either a model type + or a IO type. Required. :type system_topic_update_parameters: ~azure.mgmt.eventgrid.models.SystemTopicUpdateParameters + 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 @@ -426,58 +617,58 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either SystemTopic or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.SystemTopic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, system_topic_update_parameters=system_topic_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SystemTopicsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.SystemTopic"]: """List system topics under an Azure subscription. List all the system topics under an Azure subscription. @@ -495,43 +686,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SystemTopicsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.SystemTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SystemTopic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -545,10 +735,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -558,25 +746,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.SystemTopicsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.SystemTopic"]: """List system topics under a resource group. List all the system topics under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -591,45 +774,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SystemTopicsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.SystemTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SystemTopic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -643,10 +824,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -656,8 +835,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_event_subscriptions_operations.py index f97b98d4b683..b4f5ef814fa9 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_event_subscriptions_operations.py @@ -6,213 +6,232 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._topic_event_subscriptions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_delivery_attributes_request, build_get_full_url_request, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') +from ...operations._topic_event_subscriptions_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_delivery_attributes_request, + build_get_full_url_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TopicEventSubscriptionsOperations: - """TopicEventSubscriptionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_delivery_attributes( - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription for topic. Get all delivery attributes for an event subscription for topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a topic. Get properties of an event subscription of a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the partner topic. + :param topic_name: Name of the partner topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be found. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters only. + Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -220,18 +239,105 @@ async def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription to a topic. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Create or update an event subscription to a topic. + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -239,24 +345,28 @@ async def begin_create_or_update( resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Create or update an event subscription to a topic. Asynchronously creates a new event subscription or updates an existing event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -268,84 +378,84 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -355,28 +465,24 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete an event subscription for a topic. Delete an existing event subscription for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be deleted. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -388,98 +494,193 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore async def _update_initial( self, resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update an event subscription for a topic. + + Update an existing event subscription for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EventSubscription]: + """Update an event subscription for a topic. + + Update an existing event subscription for a topic. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( @@ -487,22 +688,27 @@ async def begin_update( resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.EventSubscription"]: + ) -> AsyncLROPoller[_models.EventSubscription]: """Update an event subscription for a topic. Update an existing event subscription for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain. + :param topic_name: Name of the domain. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -514,115 +720,115 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace_async async def get_full_url( - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription for topic. Get the full endpoint URL for an event subscription for topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list( @@ -632,14 +838,15 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> AsyncIterable["_models.EventSubscriptionsListResult"]: + ) -> AsyncIterable["_models.EventSubscription"]: """List all event subscriptions for a specific topic. List all event subscriptions that have been created for a specific topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -654,47 +861,44 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - topic_name=topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -708,10 +912,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,8 +923,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_types_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_types_operations.py index 543c8267d763..d6131d595b5a 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_types_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topic_types_operations.py @@ -7,85 +7,91 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import 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._topic_types_operations import build_get_request, build_list_event_types_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TopicTypesOperations: - """TopicTypesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TopicTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`topic_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TopicTypesListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TopicTypeInfo"]: """List topic types. List all registered topic types. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicTypesListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.TopicTypesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TopicTypeInfo or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.TopicTypeInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicTypesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicTypesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -99,10 +105,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -112,113 +116,104 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.EventGrid/topicTypes"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.EventGrid/topicTypes"} # type: ignore @distributed_trace_async - async def get( - self, - topic_type_name: str, - **kwargs: Any - ) -> "_models.TopicTypeInfo": + async def get(self, topic_type_name: str, **kwargs: Any) -> _models.TopicTypeInfo: """Get a topic type. Get information about a topic type. - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicTypeInfo, or the result of cls(response) + :return: TopicTypeInfo or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.TopicTypeInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicTypeInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicTypeInfo] - request = build_get_request( topic_type_name=topic_type_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicTypeInfo', pipeline_response) + deserialized = self._deserialize("TopicTypeInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}"} # type: ignore @distributed_trace - def list_event_types( - self, - topic_type_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EventTypesListResult"]: + def list_event_types(self, topic_type_name: str, **kwargs: Any) -> AsyncIterable["_models.EventType"]: """List event types. List event types for a topic type. - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventTypesListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventTypesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventType or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventType] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventTypesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventTypesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_event_types_request( topic_type_name=topic_type_name, api_version=api_version, - template_url=self.list_event_types.metadata['url'], + template_url=self.list_event_types.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_types_request( - topic_type_name=topic_type_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -232,10 +227,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -245,8 +238,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_types.metadata = {'url': "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventTypes"} # type: ignore + list_event_types.metadata = {"url": "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventTypes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topics_operations.py index a97c3d3f5808..7f44cd1ab7ee 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_topics_operations.py @@ -6,176 +6,199 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + 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.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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._topics_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_event_types_request, build_list_shared_access_keys_request, build_regenerate_key_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._topics_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_event_types_request, + build_list_shared_access_keys_request, + build_regenerate_key_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class TopicsOperations: - """TopicsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any - ) -> "_models.Topic": + async def get(self, resource_group_name: str, topic_name: str, **kwargs: Any) -> _models.Topic: """Get a topic. Get properties of a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Topic, or the result of cls(response) + :return: Topic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Topic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Topic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore async def _create_or_update_initial( - self, - resource_group_name: str, - topic_name: str, - topic_info: "_models.Topic", - **kwargs: Any - ) -> "_models.Topic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(topic_info, 'Topic') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, topic_name: str, topic_info: Union[_models.Topic, IO], **kwargs: Any + ) -> _models.Topic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Topic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(topic_info, (IO, bytes)): + _content = topic_info + else: + _json = self._serialize.body(topic_info, "Topic") + + request = build_create_or_update_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, topic_name: str, - topic_info: "_models.Topic", + topic_info: _models.Topic, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.Topic"]: + ) -> AsyncLROPoller[_models.Topic]: """Create a topic. Asynchronously creates a new topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param topic_info: Topic information. + :param topic_info: Topic information. Required. :type topic_info: ~azure.mgmt.eventgrid.models.Topic + :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 @@ -186,81 +209,150 @@ async def begin_create_or_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Topic or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Topic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + topic_name: str, + topic_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Topic]: + """Create a topic. + + Asynchronously creates a new topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_info: Topic information. Required. + :type topic_info: IO + :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 Topic or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, resource_group_name: str, topic_name: str, topic_info: Union[_models.Topic, IO], **kwargs: Any + ) -> AsyncLROPoller[_models.Topic]: + """Create a topic. + + Asynchronously creates a new topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_info: Topic information. Is either a model type or a IO type. Required. + :type topic_info: ~azure.mgmt.eventgrid.models.Topic 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. + :return: An instance of AsyncLROPoller that returns either Topic or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Topic] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, topic_info=topic_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -270,23 +362,18 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, topic_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Delete a topic. Delete existing topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_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. @@ -298,80 +385,93 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore async def _update_initial( self, resource_group_name: str, topic_name: str, - topic_update_parameters: "_models.TopicUpdateParameters", + topic_update_parameters: Union[_models.TopicUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.Topic"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Topic"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(topic_update_parameters, 'TopicUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.Topic]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Topic]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(topic_update_parameters, (IO, bytes)): + _content = topic_update_parameters + else: + _json = self._serialize.body(topic_update_parameters, "TopicUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -380,34 +480,112 @@ async def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + topic_name: str, + topic_update_parameters: _models.TopicUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a topic. + + Asynchronously updates a topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_update_parameters: Topic update information. Required. + :type topic_update_parameters: ~azure.mgmt.eventgrid.models.TopicUpdateParameters + :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 Topic or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + topic_name: str, + topic_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update a topic. + + Asynchronously updates a topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_update_parameters: Topic update information. Required. + :type topic_update_parameters: IO + :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 Topic or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, topic_name: str, - topic_update_parameters: "_models.TopicUpdateParameters", + topic_update_parameters: Union[_models.TopicUpdateParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.Topic"]: + ) -> AsyncLROPoller[None]: """Update a topic. Asynchronously updates a topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param topic_update_parameters: Topic update information. - :type topic_update_parameters: ~azure.mgmt.eventgrid.models.TopicUpdateParameters + :param topic_update_parameters: Topic update information. Is either a model type or a IO type. + Required. + :type topic_update_parameters: ~azure.mgmt.eventgrid.models.TopicUpdateParameters 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 @@ -418,58 +596,58 @@ async def begin_update( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either Topic or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.Topic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, topic_update_parameters=topic_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TopicsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.Topic"]: """List topics under an Azure subscription. List all the topics under an Azure subscription. @@ -487,41 +665,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.TopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Topic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -535,10 +714,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -548,25 +725,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topics"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topics"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.TopicsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.Topic"]: """List topics under a resource group. List all the topics under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -581,43 +753,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.TopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Topic or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -631,10 +803,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -644,107 +814,112 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics"} # type: ignore @distributed_trace_async async def list_shared_access_keys( - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any - ) -> "_models.TopicSharedAccessKeys": + self, resource_group_name: str, topic_name: str, **kwargs: Any + ) -> _models.TopicSharedAccessKeys: """List keys for a topic. List the two keys used to publish to a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicSharedAccessKeys, or the result of cls(response) + :return: TopicSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.TopicSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicSharedAccessKeys] - request = build_list_shared_access_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_shared_access_keys.metadata['url'], + template_url=self.list_shared_access_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("TopicSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_shared_access_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys"} # type: ignore - + list_shared_access_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys"} # type: ignore async def _regenerate_key_initial( self, resource_group_name: str, topic_name: str, - regenerate_key_request: "_models.TopicRegenerateKeyRequest", + regenerate_key_request: Union[_models.TopicRegenerateKeyRequest, IO], **kwargs: Any - ) -> Optional["_models.TopicSharedAccessKeys"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TopicSharedAccessKeys"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(regenerate_key_request, 'TopicRegenerateKeyRequest') - - request = build_regenerate_key_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.TopicSharedAccessKeys]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TopicSharedAccessKeys]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_request, (IO, bytes)): + _content = regenerate_key_request + else: + _json = self._serialize.body(regenerate_key_request, "TopicRegenerateKeyRequest") + + request = build_regenerate_key_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._regenerate_key_initial.metadata['url'], + content=_content, + template_url=self._regenerate_key_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) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -753,34 +928,114 @@ async def _regenerate_key_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TopicSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("TopicSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _regenerate_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore + _regenerate_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + topic_name: str, + regenerate_key_request: _models.TopicRegenerateKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TopicSharedAccessKeys]: + """Regenerate key for a topic. + + Regenerate a shared access key for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.TopicRegenerateKeyRequest + :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 TopicSharedAccessKeys or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.TopicSharedAccessKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + topic_name: str, + regenerate_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.TopicSharedAccessKeys]: + """Regenerate key for a topic. + Regenerate a shared access key for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: IO + :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 TopicSharedAccessKeys or the result + of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.TopicSharedAccessKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_regenerate_key( self, resource_group_name: str, topic_name: str, - regenerate_key_request: "_models.TopicRegenerateKeyRequest", + regenerate_key_request: Union[_models.TopicRegenerateKeyRequest, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.TopicSharedAccessKeys"]: + ) -> AsyncLROPoller[_models.TopicSharedAccessKeys]: """Regenerate key for a topic. Regenerate a shared access key for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param regenerate_key_request: Request body to regenerate key. - :type regenerate_key_request: ~azure.mgmt.eventgrid.models.TopicRegenerateKeyRequest + :param regenerate_key_request: Request body to regenerate key. Is either a model type or a IO + type. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.TopicRegenerateKeyRequest 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 @@ -792,50 +1047,53 @@ async def begin_regenerate_key( :return: An instance of AsyncLROPoller that returns either TopicSharedAccessKeys or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.eventgrid.models.TopicSharedAccessKeys] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicSharedAccessKeys"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicSharedAccessKeys] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._regenerate_key_initial( + raw_result = await self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, regenerate_key_request=regenerate_key_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('TopicSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("TopicSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore + begin_regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore @distributed_trace def list_event_types( @@ -845,61 +1103,59 @@ def list_event_types( resource_type_name: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EventTypesListResult"]: + ) -> AsyncIterable["_models.EventType"]: """List topic event types. List event types for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param provider_namespace: Namespace of the provider of the topic. + :param provider_namespace: Namespace of the provider of the topic. Required. :type provider_namespace: str - :param resource_type_name: Name of the topic type. + :param resource_type_name: Name of the topic type. Required. :type resource_type_name: str - :param resource_name: Name of the topic. + :param resource_name: Name of the topic. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventTypesListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventTypesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventType or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.EventType] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventTypesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventTypesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_event_types_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provider_namespace=provider_namespace, resource_type_name=resource_type_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_event_types.metadata['url'], + template_url=self.list_event_types.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_types_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - provider_namespace=provider_namespace, - resource_type_name=resource_type_name, - resource_name=resource_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -913,10 +1169,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -926,8 +1180,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_event_types.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes"} # type: ignore + list_event_types.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_verified_partners_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_verified_partners_operations.py index fa667faa5c06..2b09f4695956 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_verified_partners_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/aio/operations/_verified_partners_operations.py @@ -7,106 +7,106 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import 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._verified_partners_operations import build_get_request, build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class VerifiedPartnersOperations: - """VerifiedPartnersOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class VerifiedPartnersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.aio.EventGridManagementClient`'s + :attr:`verified_partners` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def get( - self, - verified_partner_name: str, - **kwargs: Any - ) -> "_models.VerifiedPartner": + async def get(self, verified_partner_name: str, **kwargs: Any) -> _models.VerifiedPartner: """Get a verified partner. Get properties of a verified partner. - :param verified_partner_name: Name of the verified partner. + :param verified_partner_name: Name of the verified partner. Required. :type verified_partner_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VerifiedPartner, or the result of cls(response) + :return: VerifiedPartner or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.VerifiedPartner - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VerifiedPartner"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VerifiedPartner] - request = build_get_request( verified_partner_name=verified_partner_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('VerifiedPartner', pipeline_response) + deserialized = self._deserialize("VerifiedPartner", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.EventGrid/verifiedPartners/{verifiedPartnerName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.EventGrid/verifiedPartners/{verifiedPartnerName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterable["_models.VerifiedPartnersListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> AsyncIterable["_models.VerifiedPartner"]: """List all verified partners. Get a list of all verified partners. @@ -124,41 +124,41 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VerifiedPartnersListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.VerifiedPartnersListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VerifiedPartner or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.eventgrid.models.VerifiedPartner] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VerifiedPartnersListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.VerifiedPartnersListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -172,10 +172,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -185,8 +183,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.EventGrid/verifiedPartners"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.EventGrid/verifiedPartners"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/__init__.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/__init__.py index 7c514ba709c1..3cff3a18d283 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/__init__.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/__init__.py @@ -115,185 +115,187 @@ from ._models_py3 import VerifiedPartnersListResult from ._models_py3 import WebHookEventSubscriptionDestination - -from ._event_grid_management_client_enums import ( - AdvancedFilterOperatorType, - ChannelProvisioningState, - ChannelType, - CreatedByType, - DataResidencyBoundary, - DeadLetterEndPointType, - DeliveryAttributeMappingType, - DomainProvisioningState, - DomainTopicProvisioningState, - EndpointType, - EventDefinitionKind, - EventDeliverySchema, - EventSubscriptionIdentityType, - EventSubscriptionProvisioningState, - IdentityType, - InputSchema, - InputSchemaMappingType, - IpActionType, - PartnerConfigurationProvisioningState, - PartnerNamespaceProvisioningState, - PartnerRegistrationProvisioningState, - PartnerTopicActivationState, - PartnerTopicProvisioningState, - PartnerTopicRoutingMode, - PersistedConnectionStatus, - PrivateEndpointConnectionsParentType, - PublicNetworkAccess, - ReadinessState, - ResourceProvisioningState, - ResourceRegionType, - TopicProvisioningState, - TopicTypeProvisioningState, - TopicTypeSourceScope, - VerifiedPartnerProvisioningState, -) +from ._event_grid_management_client_enums import AdvancedFilterOperatorType +from ._event_grid_management_client_enums import ChannelProvisioningState +from ._event_grid_management_client_enums import ChannelType +from ._event_grid_management_client_enums import CreatedByType +from ._event_grid_management_client_enums import DataResidencyBoundary +from ._event_grid_management_client_enums import DeadLetterEndPointType +from ._event_grid_management_client_enums import DeliveryAttributeMappingType +from ._event_grid_management_client_enums import DomainProvisioningState +from ._event_grid_management_client_enums import DomainTopicProvisioningState +from ._event_grid_management_client_enums import EndpointType +from ._event_grid_management_client_enums import EventDefinitionKind +from ._event_grid_management_client_enums import EventDeliverySchema +from ._event_grid_management_client_enums import EventSubscriptionIdentityType +from ._event_grid_management_client_enums import EventSubscriptionProvisioningState +from ._event_grid_management_client_enums import IdentityType +from ._event_grid_management_client_enums import InputSchema +from ._event_grid_management_client_enums import InputSchemaMappingType +from ._event_grid_management_client_enums import IpActionType +from ._event_grid_management_client_enums import PartnerConfigurationProvisioningState +from ._event_grid_management_client_enums import PartnerNamespaceProvisioningState +from ._event_grid_management_client_enums import PartnerRegistrationProvisioningState +from ._event_grid_management_client_enums import PartnerTopicActivationState +from ._event_grid_management_client_enums import PartnerTopicProvisioningState +from ._event_grid_management_client_enums import PartnerTopicRoutingMode +from ._event_grid_management_client_enums import PersistedConnectionStatus +from ._event_grid_management_client_enums import PrivateEndpointConnectionsParentType +from ._event_grid_management_client_enums import PublicNetworkAccess +from ._event_grid_management_client_enums import ReadinessState +from ._event_grid_management_client_enums import ResourceProvisioningState +from ._event_grid_management_client_enums import ResourceRegionType +from ._event_grid_management_client_enums import TopicProvisioningState +from ._event_grid_management_client_enums import TopicTypeProvisioningState +from ._event_grid_management_client_enums import TopicTypeSourceScope +from ._event_grid_management_client_enums import VerifiedPartnerProvisioningState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AdvancedFilter', - 'AzureFunctionEventSubscriptionDestination', - 'BoolEqualsAdvancedFilter', - 'Channel', - 'ChannelUpdateParameters', - 'ChannelsListResult', - 'ConnectionState', - 'DeadLetterDestination', - 'DeadLetterWithResourceIdentity', - 'DeliveryAttributeListResult', - 'DeliveryAttributeMapping', - 'DeliveryWithResourceIdentity', - 'Domain', - 'DomainRegenerateKeyRequest', - 'DomainSharedAccessKeys', - 'DomainTopic', - 'DomainTopicsListResult', - 'DomainUpdateParameters', - 'DomainsListResult', - 'DynamicDeliveryAttributeMapping', - 'EventHubEventSubscriptionDestination', - 'EventSubscription', - 'EventSubscriptionDestination', - 'EventSubscriptionFilter', - 'EventSubscriptionFullUrl', - 'EventSubscriptionIdentity', - 'EventSubscriptionUpdateParameters', - 'EventSubscriptionsListResult', - 'EventType', - 'EventTypeInfo', - 'EventTypesListResult', - 'ExtensionTopic', - 'HybridConnectionEventSubscriptionDestination', - 'IdentityInfo', - 'InboundIpRule', - 'InlineEventProperties', - 'InputSchemaMapping', - 'IsNotNullAdvancedFilter', - 'IsNullOrUndefinedAdvancedFilter', - 'JsonField', - 'JsonFieldWithDefault', - 'JsonInputSchemaMapping', - 'NumberGreaterThanAdvancedFilter', - 'NumberGreaterThanOrEqualsAdvancedFilter', - 'NumberInAdvancedFilter', - 'NumberInRangeAdvancedFilter', - 'NumberLessThanAdvancedFilter', - 'NumberLessThanOrEqualsAdvancedFilter', - 'NumberNotInAdvancedFilter', - 'NumberNotInRangeAdvancedFilter', - 'Operation', - 'OperationInfo', - 'OperationsListResult', - 'Partner', - 'PartnerAuthorization', - 'PartnerConfiguration', - 'PartnerConfigurationUpdateParameters', - 'PartnerConfigurationsListResult', - 'PartnerDetails', - 'PartnerNamespace', - 'PartnerNamespaceRegenerateKeyRequest', - 'PartnerNamespaceSharedAccessKeys', - 'PartnerNamespaceUpdateParameters', - 'PartnerNamespacesListResult', - 'PartnerRegistration', - 'PartnerRegistrationUpdateParameters', - 'PartnerRegistrationsListResult', - 'PartnerTopic', - 'PartnerTopicInfo', - 'PartnerTopicUpdateParameters', - 'PartnerTopicsListResult', - 'PartnerUpdateTopicInfo', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourcesListResult', - 'Resource', - 'RetryPolicy', - 'ServiceBusQueueEventSubscriptionDestination', - 'ServiceBusTopicEventSubscriptionDestination', - 'StaticDeliveryAttributeMapping', - 'StorageBlobDeadLetterDestination', - 'StorageQueueEventSubscriptionDestination', - 'StringBeginsWithAdvancedFilter', - 'StringContainsAdvancedFilter', - 'StringEndsWithAdvancedFilter', - 'StringInAdvancedFilter', - 'StringNotBeginsWithAdvancedFilter', - 'StringNotContainsAdvancedFilter', - 'StringNotEndsWithAdvancedFilter', - 'StringNotInAdvancedFilter', - 'SystemData', - 'SystemTopic', - 'SystemTopicUpdateParameters', - 'SystemTopicsListResult', - 'Topic', - 'TopicRegenerateKeyRequest', - 'TopicSharedAccessKeys', - 'TopicTypeInfo', - 'TopicTypesListResult', - 'TopicUpdateParameters', - 'TopicsListResult', - 'TrackedResource', - 'UserIdentityProperties', - 'VerifiedPartner', - 'VerifiedPartnersListResult', - 'WebHookEventSubscriptionDestination', - 'AdvancedFilterOperatorType', - 'ChannelProvisioningState', - 'ChannelType', - 'CreatedByType', - 'DataResidencyBoundary', - 'DeadLetterEndPointType', - 'DeliveryAttributeMappingType', - 'DomainProvisioningState', - 'DomainTopicProvisioningState', - 'EndpointType', - 'EventDefinitionKind', - 'EventDeliverySchema', - 'EventSubscriptionIdentityType', - 'EventSubscriptionProvisioningState', - 'IdentityType', - 'InputSchema', - 'InputSchemaMappingType', - 'IpActionType', - 'PartnerConfigurationProvisioningState', - 'PartnerNamespaceProvisioningState', - 'PartnerRegistrationProvisioningState', - 'PartnerTopicActivationState', - 'PartnerTopicProvisioningState', - 'PartnerTopicRoutingMode', - 'PersistedConnectionStatus', - 'PrivateEndpointConnectionsParentType', - 'PublicNetworkAccess', - 'ReadinessState', - 'ResourceProvisioningState', - 'ResourceRegionType', - 'TopicProvisioningState', - 'TopicTypeProvisioningState', - 'TopicTypeSourceScope', - 'VerifiedPartnerProvisioningState', + "AdvancedFilter", + "AzureFunctionEventSubscriptionDestination", + "BoolEqualsAdvancedFilter", + "Channel", + "ChannelUpdateParameters", + "ChannelsListResult", + "ConnectionState", + "DeadLetterDestination", + "DeadLetterWithResourceIdentity", + "DeliveryAttributeListResult", + "DeliveryAttributeMapping", + "DeliveryWithResourceIdentity", + "Domain", + "DomainRegenerateKeyRequest", + "DomainSharedAccessKeys", + "DomainTopic", + "DomainTopicsListResult", + "DomainUpdateParameters", + "DomainsListResult", + "DynamicDeliveryAttributeMapping", + "EventHubEventSubscriptionDestination", + "EventSubscription", + "EventSubscriptionDestination", + "EventSubscriptionFilter", + "EventSubscriptionFullUrl", + "EventSubscriptionIdentity", + "EventSubscriptionUpdateParameters", + "EventSubscriptionsListResult", + "EventType", + "EventTypeInfo", + "EventTypesListResult", + "ExtensionTopic", + "HybridConnectionEventSubscriptionDestination", + "IdentityInfo", + "InboundIpRule", + "InlineEventProperties", + "InputSchemaMapping", + "IsNotNullAdvancedFilter", + "IsNullOrUndefinedAdvancedFilter", + "JsonField", + "JsonFieldWithDefault", + "JsonInputSchemaMapping", + "NumberGreaterThanAdvancedFilter", + "NumberGreaterThanOrEqualsAdvancedFilter", + "NumberInAdvancedFilter", + "NumberInRangeAdvancedFilter", + "NumberLessThanAdvancedFilter", + "NumberLessThanOrEqualsAdvancedFilter", + "NumberNotInAdvancedFilter", + "NumberNotInRangeAdvancedFilter", + "Operation", + "OperationInfo", + "OperationsListResult", + "Partner", + "PartnerAuthorization", + "PartnerConfiguration", + "PartnerConfigurationUpdateParameters", + "PartnerConfigurationsListResult", + "PartnerDetails", + "PartnerNamespace", + "PartnerNamespaceRegenerateKeyRequest", + "PartnerNamespaceSharedAccessKeys", + "PartnerNamespaceUpdateParameters", + "PartnerNamespacesListResult", + "PartnerRegistration", + "PartnerRegistrationUpdateParameters", + "PartnerRegistrationsListResult", + "PartnerTopic", + "PartnerTopicInfo", + "PartnerTopicUpdateParameters", + "PartnerTopicsListResult", + "PartnerUpdateTopicInfo", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourcesListResult", + "Resource", + "RetryPolicy", + "ServiceBusQueueEventSubscriptionDestination", + "ServiceBusTopicEventSubscriptionDestination", + "StaticDeliveryAttributeMapping", + "StorageBlobDeadLetterDestination", + "StorageQueueEventSubscriptionDestination", + "StringBeginsWithAdvancedFilter", + "StringContainsAdvancedFilter", + "StringEndsWithAdvancedFilter", + "StringInAdvancedFilter", + "StringNotBeginsWithAdvancedFilter", + "StringNotContainsAdvancedFilter", + "StringNotEndsWithAdvancedFilter", + "StringNotInAdvancedFilter", + "SystemData", + "SystemTopic", + "SystemTopicUpdateParameters", + "SystemTopicsListResult", + "Topic", + "TopicRegenerateKeyRequest", + "TopicSharedAccessKeys", + "TopicTypeInfo", + "TopicTypesListResult", + "TopicUpdateParameters", + "TopicsListResult", + "TrackedResource", + "UserIdentityProperties", + "VerifiedPartner", + "VerifiedPartnersListResult", + "WebHookEventSubscriptionDestination", + "AdvancedFilterOperatorType", + "ChannelProvisioningState", + "ChannelType", + "CreatedByType", + "DataResidencyBoundary", + "DeadLetterEndPointType", + "DeliveryAttributeMappingType", + "DomainProvisioningState", + "DomainTopicProvisioningState", + "EndpointType", + "EventDefinitionKind", + "EventDeliverySchema", + "EventSubscriptionIdentityType", + "EventSubscriptionProvisioningState", + "IdentityType", + "InputSchema", + "InputSchemaMappingType", + "IpActionType", + "PartnerConfigurationProvisioningState", + "PartnerNamespaceProvisioningState", + "PartnerRegistrationProvisioningState", + "PartnerTopicActivationState", + "PartnerTopicProvisioningState", + "PartnerTopicRoutingMode", + "PersistedConnectionStatus", + "PrivateEndpointConnectionsParentType", + "PublicNetworkAccess", + "ReadinessState", + "ResourceProvisioningState", + "ResourceRegionType", + "TopicProvisioningState", + "TopicTypeProvisioningState", + "TopicTypeSourceScope", + "VerifiedPartnerProvisioningState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_event_grid_management_client_enums.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_event_grid_management_client_enums.py index 5d74f5a932ba..d20c735e00b8 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_event_grid_management_client_enums.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_event_grid_management_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AdvancedFilterOperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The operator type used for filtering, e.g., NumberIn, StringContains, BoolEquals and others. - """ +class AdvancedFilterOperatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operator type used for filtering, e.g., NumberIn, StringContains, BoolEquals and others.""" NUMBER_IN = "NumberIn" NUMBER_NOT_IN = "NumberNotIn" @@ -35,9 +33,9 @@ class AdvancedFilterOperatorType(with_metaclass(CaseInsensitiveEnumMeta, str, En IS_NULL_OR_UNDEFINED = "IsNullOrUndefined" IS_NOT_NULL = "IsNotNull" -class ChannelProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the channel. - """ + +class ChannelProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the channel.""" CREATING = "Creating" UPDATING = "Updating" @@ -47,44 +45,44 @@ class ChannelProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum FAILED = "Failed" IDLE_DUE_TO_MIRRORED_PARTNER_TOPIC_DELETION = "IdleDueToMirroredPartnerTopicDeletion" -class ChannelType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of the event channel which represents the direction flow of events. - """ + +class ChannelType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the event channel which represents the direction flow of events.""" PARTNER_TOPIC = "PartnerTopic" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DataResidencyBoundary(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Data Residency Boundary of the resource. - """ + +class DataResidencyBoundary(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Data Residency Boundary of the resource.""" WITHIN_GEOPAIR = "WithinGeopair" WITHIN_REGION = "WithinRegion" -class DeadLetterEndPointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the endpoint for the dead letter destination - """ + +class DeadLetterEndPointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the endpoint for the dead letter destination.""" STORAGE_BLOB = "StorageBlob" -class DeliveryAttributeMappingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the delivery attribute or header name. - """ + +class DeliveryAttributeMappingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the delivery attribute or header name.""" STATIC = "Static" DYNAMIC = "Dynamic" -class DomainProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Event Grid Domain Resource. - """ + +class DomainProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Event Grid Domain Resource.""" CREATING = "Creating" UPDATING = "Updating" @@ -93,9 +91,9 @@ class DomainProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) CANCELED = "Canceled" FAILED = "Failed" -class DomainTopicProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the domain topic. - """ + +class DomainTopicProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the domain topic.""" CREATING = "Creating" UPDATING = "Updating" @@ -104,9 +102,9 @@ class DomainTopicProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, CANCELED = "Canceled" FAILED = "Failed" -class EndpointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the endpoint for the event subscription destination. - """ + +class EndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the endpoint for the event subscription destination.""" WEB_HOOK = "WebHook" EVENT_HUB = "EventHub" @@ -116,21 +114,22 @@ class EndpointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE_BUS_TOPIC = "ServiceBusTopic" AZURE_FUNCTION = "AzureFunction" -class EventDefinitionKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The kind of event type used. - """ + +class EventDefinitionKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of event type used.""" INLINE = "Inline" -class EventDeliverySchema(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The event delivery schema for the event subscription. - """ + +class EventDeliverySchema(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The event delivery schema for the event subscription.""" EVENT_GRID_SCHEMA = "EventGridSchema" CUSTOM_INPUT_SCHEMA = "CustomInputSchema" CLOUD_EVENT_SCHEMA_V1_0 = "CloudEventSchemaV1_0" -class EventSubscriptionIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class EventSubscriptionIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will remove any identity. @@ -139,9 +138,9 @@ class EventSubscriptionIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class EventSubscriptionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the event subscription. - """ + +class EventSubscriptionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the event subscription.""" CREATING = "Creating" UPDATING = "Updating" @@ -151,7 +150,8 @@ class EventSubscriptionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, FAILED = "Failed" AWAITING_MANUAL_ACTION = "AwaitingManualAction" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will remove any identity. @@ -162,7 +162,8 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" -class InputSchema(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class InputSchema(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This determines the format that Event Grid should expect for incoming events published to the Event Grid Domain Resource. """ @@ -171,21 +172,21 @@ class InputSchema(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CUSTOM_EVENT_SCHEMA = "CustomEventSchema" CLOUD_EVENT_SCHEMA_V1_0 = "CloudEventSchemaV1_0" -class InputSchemaMappingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Type of the custom mapping - """ + +class InputSchemaMappingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of the custom mapping.""" JSON = "Json" -class IpActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Action to perform based on the match or no match of the IpMask. - """ + +class IpActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Action to perform based on the match or no match of the IpMask.""" ALLOW = "Allow" -class PartnerConfigurationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the partner configuration. - """ + +class PartnerConfigurationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the partner configuration.""" CREATING = "Creating" UPDATING = "Updating" @@ -194,9 +195,9 @@ class PartnerConfigurationProvisioningState(with_metaclass(CaseInsensitiveEnumMe CANCELED = "Canceled" FAILED = "Failed" -class PartnerNamespaceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the partner namespace. - """ + +class PartnerNamespaceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the partner namespace.""" CREATING = "Creating" UPDATING = "Updating" @@ -205,9 +206,9 @@ class PartnerNamespaceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, CANCELED = "Canceled" FAILED = "Failed" -class PartnerRegistrationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the partner registration. - """ + +class PartnerRegistrationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the partner registration.""" CREATING = "Creating" UPDATING = "Updating" @@ -216,17 +217,17 @@ class PartnerRegistrationProvisioningState(with_metaclass(CaseInsensitiveEnumMet CANCELED = "Canceled" FAILED = "Failed" -class PartnerTopicActivationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Activation state of the partner topic. - """ + +class PartnerTopicActivationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Activation state of the partner topic.""" NEVER_ACTIVATED = "NeverActivated" ACTIVATED = "Activated" DEACTIVATED = "Deactivated" -class PartnerTopicProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the partner topic. - """ + +class PartnerTopicProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the partner topic.""" CREATING = "Creating" UPDATING = "Updating" @@ -236,7 +237,8 @@ class PartnerTopicProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, FAILED = "Failed" IDLE_DUE_TO_MIRRORED_CHANNEL_RESOURCE_DELETION = "IdleDueToMirroredChannelResourceDeletion" -class PartnerTopicRoutingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PartnerTopicRoutingMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This determines if events published to this partner namespace should use the source attribute in the event payload or use the channel name in the header when matching to the partner topic. If none is specified, @@ -246,41 +248,44 @@ class PartnerTopicRoutingMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) SOURCE_EVENT_ATTRIBUTE = "SourceEventAttribute" CHANNEL_NAME_HEADER = "ChannelNameHeader" -class PersistedConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the connection. - """ + +class PersistedConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PrivateEndpointConnectionsParentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PrivateEndpointConnectionsParentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PrivateEndpointConnectionsParentType.""" TOPICS = "topics" DOMAINS = "domains" PARTNER_NAMESPACES = "partnerNamespaces" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This determines if traffic is allowed over public network. By default it is enabled. You can further restrict to specific IPs by configuring :code:`` + />`. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ReadinessState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The readiness state of the corresponding partner topic. - """ + +class ReadinessState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The readiness state of the corresponding partner topic.""" NEVER_ACTIVATED = "NeverActivated" ACTIVATED = "Activated" -class ResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Private Endpoint Connection. - """ + +class ResourceProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Private Endpoint Connection.""" CREATING = "Creating" UPDATING = "Updating" @@ -289,16 +294,16 @@ class ResourceProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu CANCELED = "Canceled" FAILED = "Failed" -class ResourceRegionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Region type of the resource. - """ + +class ResourceRegionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Region type of the resource.""" REGIONAL_RESOURCE = "RegionalResource" GLOBAL_RESOURCE = "GlobalResource" -class TopicProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the topic. - """ + +class TopicProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the topic.""" CREATING = "Creating" UPDATING = "Updating" @@ -307,9 +312,9 @@ class TopicProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) CANCELED = "Canceled" FAILED = "Failed" -class TopicTypeProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the topic type - """ + +class TopicTypeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the topic type.""" CREATING = "Creating" UPDATING = "Updating" @@ -318,16 +323,18 @@ class TopicTypeProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, En CANCELED = "Canceled" FAILED = "Failed" -class TopicTypeSourceScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class TopicTypeSourceScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """TopicTypeSourceScope.""" RESOURCE = "Resource" RESOURCE_GROUP = "ResourceGroup" AZURE_SUBSCRIPTION = "AzureSubscription" MANAGEMENT_GROUP = "ManagementGroup" -class VerifiedPartnerProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the verified partner. - """ + +class VerifiedPartnerProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the verified partner.""" CREATING = "Creating" UPDATING = "Updating" diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_models_py3.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_models_py3.py index 59e5db93c3bc..f73805af8a3c 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_models_py3.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,93 +8,129 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from .. import _serialization -from ._event_grid_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AdvancedFilter(msrest.serialization.Model): +class AdvancedFilter(_serialization.Model): """This is the base type that represents an advanced filter. To configure an advanced filter, do not directly instantiate an object of this class. Instead, instantiate an object of a derived class such as BoolEqualsAdvancedFilter, NumberInAdvancedFilter, StringEqualsAdvancedFilter etc. depending on the type of the key based on which you want to filter. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: BoolEqualsAdvancedFilter, IsNotNullAdvancedFilter, IsNullOrUndefinedAdvancedFilter, NumberGreaterThanAdvancedFilter, NumberGreaterThanOrEqualsAdvancedFilter, NumberInAdvancedFilter, NumberInRangeAdvancedFilter, NumberLessThanAdvancedFilter, NumberLessThanOrEqualsAdvancedFilter, NumberNotInAdvancedFilter, NumberNotInRangeAdvancedFilter, StringBeginsWithAdvancedFilter, StringContainsAdvancedFilter, StringEndsWithAdvancedFilter, StringInAdvancedFilter, StringNotBeginsWithAdvancedFilter, StringNotContainsAdvancedFilter, StringNotEndsWithAdvancedFilter, StringNotInAdvancedFilter. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + BoolEqualsAdvancedFilter, IsNotNullAdvancedFilter, IsNullOrUndefinedAdvancedFilter, + NumberGreaterThanAdvancedFilter, NumberGreaterThanOrEqualsAdvancedFilter, + NumberInAdvancedFilter, NumberInRangeAdvancedFilter, NumberLessThanAdvancedFilter, + NumberLessThanOrEqualsAdvancedFilter, NumberNotInAdvancedFilter, + NumberNotInRangeAdvancedFilter, StringBeginsWithAdvancedFilter, StringContainsAdvancedFilter, + StringEndsWithAdvancedFilter, StringInAdvancedFilter, StringNotBeginsWithAdvancedFilter, + StringNotContainsAdvancedFilter, StringNotEndsWithAdvancedFilter, StringNotInAdvancedFilter All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } _subtype_map = { - 'operator_type': {'BoolEquals': 'BoolEqualsAdvancedFilter', 'IsNotNull': 'IsNotNullAdvancedFilter', 'IsNullOrUndefined': 'IsNullOrUndefinedAdvancedFilter', 'NumberGreaterThan': 'NumberGreaterThanAdvancedFilter', 'NumberGreaterThanOrEquals': 'NumberGreaterThanOrEqualsAdvancedFilter', 'NumberIn': 'NumberInAdvancedFilter', 'NumberInRange': 'NumberInRangeAdvancedFilter', 'NumberLessThan': 'NumberLessThanAdvancedFilter', 'NumberLessThanOrEquals': 'NumberLessThanOrEqualsAdvancedFilter', 'NumberNotIn': 'NumberNotInAdvancedFilter', 'NumberNotInRange': 'NumberNotInRangeAdvancedFilter', 'StringBeginsWith': 'StringBeginsWithAdvancedFilter', 'StringContains': 'StringContainsAdvancedFilter', 'StringEndsWith': 'StringEndsWithAdvancedFilter', 'StringIn': 'StringInAdvancedFilter', 'StringNotBeginsWith': 'StringNotBeginsWithAdvancedFilter', 'StringNotContains': 'StringNotContainsAdvancedFilter', 'StringNotEndsWith': 'StringNotEndsWithAdvancedFilter', 'StringNotIn': 'StringNotInAdvancedFilter'} - } - - def __init__( - self, - *, - key: Optional[str] = None, - **kwargs - ): + "operator_type": { + "BoolEquals": "BoolEqualsAdvancedFilter", + "IsNotNull": "IsNotNullAdvancedFilter", + "IsNullOrUndefined": "IsNullOrUndefinedAdvancedFilter", + "NumberGreaterThan": "NumberGreaterThanAdvancedFilter", + "NumberGreaterThanOrEquals": "NumberGreaterThanOrEqualsAdvancedFilter", + "NumberIn": "NumberInAdvancedFilter", + "NumberInRange": "NumberInRangeAdvancedFilter", + "NumberLessThan": "NumberLessThanAdvancedFilter", + "NumberLessThanOrEquals": "NumberLessThanOrEqualsAdvancedFilter", + "NumberNotIn": "NumberNotInAdvancedFilter", + "NumberNotInRange": "NumberNotInRangeAdvancedFilter", + "StringBeginsWith": "StringBeginsWithAdvancedFilter", + "StringContains": "StringContainsAdvancedFilter", + "StringEndsWith": "StringEndsWithAdvancedFilter", + "StringIn": "StringInAdvancedFilter", + "StringNotBeginsWith": "StringNotBeginsWithAdvancedFilter", + "StringNotContains": "StringNotContainsAdvancedFilter", + "StringNotEndsWith": "StringNotEndsWithAdvancedFilter", + "StringNotIn": "StringNotInAdvancedFilter", + } + } + + def __init__(self, *, key: Optional[str] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str """ - super(AdvancedFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.operator_type = None # type: Optional[str] self.key = key -class EventSubscriptionDestination(msrest.serialization.Model): +class EventSubscriptionDestination(_serialization.Model): """Information about the destination for an event subscription. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AzureFunctionEventSubscriptionDestination, EventHubEventSubscriptionDestination, HybridConnectionEventSubscriptionDestination, ServiceBusQueueEventSubscriptionDestination, ServiceBusTopicEventSubscriptionDestination, StorageQueueEventSubscriptionDestination, WebHookEventSubscriptionDestination. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AzureFunctionEventSubscriptionDestination, EventHubEventSubscriptionDestination, + HybridConnectionEventSubscriptionDestination, ServiceBusQueueEventSubscriptionDestination, + ServiceBusTopicEventSubscriptionDestination, StorageQueueEventSubscriptionDestination, + WebHookEventSubscriptionDestination All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, } _subtype_map = { - 'endpoint_type': {'AzureFunction': 'AzureFunctionEventSubscriptionDestination', 'EventHub': 'EventHubEventSubscriptionDestination', 'HybridConnection': 'HybridConnectionEventSubscriptionDestination', 'ServiceBusQueue': 'ServiceBusQueueEventSubscriptionDestination', 'ServiceBusTopic': 'ServiceBusTopicEventSubscriptionDestination', 'StorageQueue': 'StorageQueueEventSubscriptionDestination', 'WebHook': 'WebHookEventSubscriptionDestination'} - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(EventSubscriptionDestination, self).__init__(**kwargs) + "endpoint_type": { + "AzureFunction": "AzureFunctionEventSubscriptionDestination", + "EventHub": "EventHubEventSubscriptionDestination", + "HybridConnection": "HybridConnectionEventSubscriptionDestination", + "ServiceBusQueue": "ServiceBusQueueEventSubscriptionDestination", + "ServiceBusTopic": "ServiceBusTopicEventSubscriptionDestination", + "StorageQueue": "StorageQueueEventSubscriptionDestination", + "WebHook": "WebHookEventSubscriptionDestination", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.endpoint_type = None # type: Optional[str] @@ -102,9 +139,9 @@ class AzureFunctionEventSubscriptionDestination(EventSubscriptionDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar resource_id: The Azure Resource Id that represents the endpoint of the Azure Function destination of an event subscription. @@ -119,24 +156,27 @@ class AzureFunctionEventSubscriptionDestination(EventSubscriptionDestination): """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'max_events_per_batch': {'key': 'properties.maxEventsPerBatch', 'type': 'int'}, - 'preferred_batch_size_in_kilobytes': {'key': 'properties.preferredBatchSizeInKilobytes', 'type': 'int'}, - 'delivery_attribute_mappings': {'key': 'properties.deliveryAttributeMappings', 'type': '[DeliveryAttributeMapping]'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "max_events_per_batch": {"key": "properties.maxEventsPerBatch", "type": "int"}, + "preferred_batch_size_in_kilobytes": {"key": "properties.preferredBatchSizeInKilobytes", "type": "int"}, + "delivery_attribute_mappings": { + "key": "properties.deliveryAttributeMappings", + "type": "[DeliveryAttributeMapping]", + }, } def __init__( self, *, resource_id: Optional[str] = None, - max_events_per_batch: Optional[int] = 1, - preferred_batch_size_in_kilobytes: Optional[int] = 64, - delivery_attribute_mappings: Optional[List["DeliveryAttributeMapping"]] = None, + max_events_per_batch: int = 1, + preferred_batch_size_in_kilobytes: int = 64, + delivery_attribute_mappings: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs ): """ @@ -151,8 +191,8 @@ def __init__( :paramtype delivery_attribute_mappings: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(AzureFunctionEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'AzureFunction' # type: str + super().__init__(**kwargs) + self.endpoint_type = "AzureFunction" # type: str self.resource_id = resource_id self.max_events_per_batch = max_events_per_batch self.preferred_batch_size_in_kilobytes = preferred_batch_size_in_kilobytes @@ -164,12 +204,12 @@ class BoolEqualsAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -178,34 +218,28 @@ class BoolEqualsAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'bool'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "bool"}, } - def __init__( - self, - *, - key: Optional[str] = None, - value: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, value: Optional[bool] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword value: The boolean filter value. :paramtype value: bool """ - super(BoolEqualsAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'BoolEquals' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "BoolEquals" # type: str self.value = value -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Definition of a Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -219,24 +253,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -256,7 +286,7 @@ class Channel(Resource): :ivar system_data: The system metadata relating to Channel resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData :ivar channel_type: The type of the event channel which represents the direction flow of - events. Possible values include: "PartnerTopic". + events. "PartnerTopic" :vartype channel_type: str or ~azure.mgmt.eventgrid.models.ChannelType :ivar partner_topic_info: This property should be populated when channelType is PartnerTopic and represents information about the partner topic resource corresponding to the channel. @@ -264,12 +294,12 @@ class Channel(Resource): :ivar message_for_activation: Context or helpful message that can be used during the approval process by the subscriber. :vartype message_for_activation: str - :ivar provisioning_state: Provisioning state of the channel. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed", + :ivar provisioning_state: Provisioning state of the channel. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Canceled", "Failed", and "IdleDueToMirroredPartnerTopicDeletion". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.ChannelProvisioningState - :ivar readiness_state: The readiness state of the corresponding partner topic. Possible values - include: "NeverActivated", "Activated". + :ivar readiness_state: The readiness state of the corresponding partner topic. Known values + are: "NeverActivated" and "Activated". :vartype readiness_state: str or ~azure.mgmt.eventgrid.models.ReadinessState :ivar expiration_time_if_not_activated_utc: Expiration time of the channel. If this timer expires while the corresponding partner topic is never activated, @@ -278,39 +308,42 @@ class Channel(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'channel_type': {'key': 'properties.channelType', 'type': 'str'}, - 'partner_topic_info': {'key': 'properties.partnerTopicInfo', 'type': 'PartnerTopicInfo'}, - 'message_for_activation': {'key': 'properties.messageForActivation', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'readiness_state': {'key': 'properties.readinessState', 'type': 'str'}, - 'expiration_time_if_not_activated_utc': {'key': 'properties.expirationTimeIfNotActivatedUtc', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "channel_type": {"key": "properties.channelType", "type": "str"}, + "partner_topic_info": {"key": "properties.partnerTopicInfo", "type": "PartnerTopicInfo"}, + "message_for_activation": {"key": "properties.messageForActivation", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "readiness_state": {"key": "properties.readinessState", "type": "str"}, + "expiration_time_if_not_activated_utc": { + "key": "properties.expirationTimeIfNotActivatedUtc", + "type": "iso-8601", + }, } def __init__( self, *, - channel_type: Optional[Union[str, "ChannelType"]] = None, - partner_topic_info: Optional["PartnerTopicInfo"] = None, + channel_type: Optional[Union[str, "_models.ChannelType"]] = None, + partner_topic_info: Optional["_models.PartnerTopicInfo"] = None, message_for_activation: Optional[str] = None, - provisioning_state: Optional[Union[str, "ChannelProvisioningState"]] = None, - readiness_state: Optional[Union[str, "ReadinessState"]] = None, + provisioning_state: Optional[Union[str, "_models.ChannelProvisioningState"]] = None, + readiness_state: Optional[Union[str, "_models.ReadinessState"]] = None, expiration_time_if_not_activated_utc: Optional[datetime.datetime] = None, **kwargs ): """ :keyword channel_type: The type of the event channel which represents the direction flow of - events. Possible values include: "PartnerTopic". + events. "PartnerTopic" :paramtype channel_type: str or ~azure.mgmt.eventgrid.models.ChannelType :keyword partner_topic_info: This property should be populated when channelType is PartnerTopic and represents information about the partner topic resource corresponding to the channel. @@ -318,19 +351,19 @@ def __init__( :keyword message_for_activation: Context or helpful message that can be used during the approval process by the subscriber. :paramtype message_for_activation: str - :keyword provisioning_state: Provisioning state of the channel. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed", + :keyword provisioning_state: Provisioning state of the channel. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Canceled", "Failed", and "IdleDueToMirroredPartnerTopicDeletion". :paramtype provisioning_state: str or ~azure.mgmt.eventgrid.models.ChannelProvisioningState - :keyword readiness_state: The readiness state of the corresponding partner topic. Possible - values include: "NeverActivated", "Activated". + :keyword readiness_state: The readiness state of the corresponding partner topic. Known values + are: "NeverActivated" and "Activated". :paramtype readiness_state: str or ~azure.mgmt.eventgrid.models.ReadinessState :keyword expiration_time_if_not_activated_utc: Expiration time of the channel. If this timer expires while the corresponding partner topic is never activated, the channel and corresponding partner topic are deleted. :paramtype expiration_time_if_not_activated_utc: ~datetime.datetime """ - super(Channel, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.channel_type = channel_type self.partner_topic_info = partner_topic_info @@ -340,7 +373,7 @@ def __init__( self.expiration_time_if_not_activated_utc = expiration_time_if_not_activated_utc -class ChannelsListResult(msrest.serialization.Model): +class ChannelsListResult(_serialization.Model): """Result of the List Channels operation. :ivar value: A collection of Channels. @@ -350,29 +383,23 @@ class ChannelsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Channel]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Channel]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Channel"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Channel"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: A collection of Channels. :paramtype value: list[~azure.mgmt.eventgrid.models.Channel] :keyword next_link: A link for the next page of channels. :paramtype next_link: str """ - super(ChannelsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class ChannelUpdateParameters(msrest.serialization.Model): +class ChannelUpdateParameters(_serialization.Model): """Properties of the Channel update. :ivar expiration_time_if_not_activated_utc: Expiration time of the channel. If this timer @@ -385,15 +412,18 @@ class ChannelUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'expiration_time_if_not_activated_utc': {'key': 'properties.expirationTimeIfNotActivatedUtc', 'type': 'iso-8601'}, - 'partner_topic_info': {'key': 'properties.partnerTopicInfo', 'type': 'PartnerUpdateTopicInfo'}, + "expiration_time_if_not_activated_utc": { + "key": "properties.expirationTimeIfNotActivatedUtc", + "type": "iso-8601", + }, + "partner_topic_info": {"key": "properties.partnerTopicInfo", "type": "PartnerUpdateTopicInfo"}, } def __init__( self, *, expiration_time_if_not_activated_utc: Optional[datetime.datetime] = None, - partner_topic_info: Optional["PartnerUpdateTopicInfo"] = None, + partner_topic_info: Optional["_models.PartnerUpdateTopicInfo"] = None, **kwargs ): """ @@ -405,16 +435,16 @@ def __init__( type PartnerTopic. :paramtype partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerUpdateTopicInfo """ - super(ChannelUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.expiration_time_if_not_activated_utc = expiration_time_if_not_activated_utc self.partner_topic_info = partner_topic_info -class ConnectionState(msrest.serialization.Model): +class ConnectionState(_serialization.Model): """ConnectionState information. - :ivar status: Status of the connection. Possible values include: "Pending", "Approved", - "Rejected", "Disconnected". + :ivar status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", + and "Disconnected". :vartype status: str or ~azure.mgmt.eventgrid.models.PersistedConnectionStatus :ivar description: Description of the connection state. :vartype description: str @@ -423,70 +453,64 @@ class ConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Optional[Union[str, "PersistedConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PersistedConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Status of the connection. Possible values include: "Pending", "Approved", - "Rejected", "Disconnected". + :keyword status: Status of the connection. Known values are: "Pending", "Approved", "Rejected", + and "Disconnected". :paramtype status: str or ~azure.mgmt.eventgrid.models.PersistedConnectionStatus :keyword description: Description of the connection state. :paramtype description: str :keyword actions_required: Actions required (if any). :paramtype actions_required: str """ - super(ConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class DeadLetterDestination(msrest.serialization.Model): +class DeadLetterDestination(_serialization.Model): """Information about the dead letter destination for an event subscription. To configure a deadletter destination, do not directly instantiate an object of this class. Instead, instantiate an object of a derived class. Currently, StorageBlobDeadLetterDestination is the only class that derives from this class. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: StorageBlobDeadLetterDestination. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + StorageBlobDeadLetterDestination All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the dead letter destination.Constant - filled by server. Possible values include: "StorageBlob". + :ivar endpoint_type: Type of the endpoint for the dead letter destination. Required. + "StorageBlob" :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.DeadLetterEndPointType """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, } - _subtype_map = { - 'endpoint_type': {'StorageBlob': 'StorageBlobDeadLetterDestination'} - } + _subtype_map = {"endpoint_type": {"StorageBlob": "StorageBlobDeadLetterDestination"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(DeadLetterDestination, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.endpoint_type = None # type: Optional[str] -class DeadLetterWithResourceIdentity(msrest.serialization.Model): +class DeadLetterWithResourceIdentity(_serialization.Model): """Information about the deadletter destination with resource identity. :ivar identity: The identity to use when dead-lettering events. @@ -499,15 +523,15 @@ class DeadLetterWithResourceIdentity(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'EventSubscriptionIdentity'}, - 'dead_letter_destination': {'key': 'deadLetterDestination', 'type': 'DeadLetterDestination'}, + "identity": {"key": "identity", "type": "EventSubscriptionIdentity"}, + "dead_letter_destination": {"key": "deadLetterDestination", "type": "DeadLetterDestination"}, } def __init__( self, *, - identity: Optional["EventSubscriptionIdentity"] = None, - dead_letter_destination: Optional["DeadLetterDestination"] = None, + identity: Optional["_models.EventSubscriptionIdentity"] = None, + dead_letter_destination: Optional["_models.DeadLetterDestination"] = None, **kwargs ): """ @@ -519,12 +543,12 @@ def __init__( the authentication tokens being used during delivery / dead-lettering. :paramtype dead_letter_destination: ~azure.mgmt.eventgrid.models.DeadLetterDestination """ - super(DeadLetterWithResourceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.dead_letter_destination = dead_letter_destination -class DeliveryAttributeListResult(msrest.serialization.Model): +class DeliveryAttributeListResult(_serialization.Model): """Result of the Get delivery attributes operation. :ivar value: A collection of DeliveryAttributeMapping. @@ -532,67 +556,55 @@ class DeliveryAttributeListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DeliveryAttributeMapping]'}, + "value": {"key": "value", "type": "[DeliveryAttributeMapping]"}, } - def __init__( - self, - *, - value: Optional[List["DeliveryAttributeMapping"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs): """ :keyword value: A collection of DeliveryAttributeMapping. :paramtype value: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(DeliveryAttributeListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DeliveryAttributeMapping(msrest.serialization.Model): +class DeliveryAttributeMapping(_serialization.Model): """Delivery attribute mapping details. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: DynamicDeliveryAttributeMapping, StaticDeliveryAttributeMapping. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + DynamicDeliveryAttributeMapping, StaticDeliveryAttributeMapping All required parameters must be populated in order to send to Azure. :ivar name: Name of the delivery attribute or header. :vartype name: str - :ivar type: Required. Type of the delivery attribute or header name.Constant filled by server. - Possible values include: "Static", "Dynamic". + :ivar type: Type of the delivery attribute or header name. Required. Known values are: "Static" + and "Dynamic". :vartype type: str or ~azure.mgmt.eventgrid.models.DeliveryAttributeMappingType """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - _subtype_map = { - 'type': {'Dynamic': 'DynamicDeliveryAttributeMapping', 'Static': 'StaticDeliveryAttributeMapping'} - } + _subtype_map = {"type": {"Dynamic": "DynamicDeliveryAttributeMapping", "Static": "StaticDeliveryAttributeMapping"}} - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: Name of the delivery attribute or header. :paramtype name: str """ - super(DeliveryAttributeMapping, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = None # type: Optional[str] -class DeliveryWithResourceIdentity(msrest.serialization.Model): +class DeliveryWithResourceIdentity(_serialization.Model): """Information about the delivery for an event subscription with resource identity. :ivar identity: The identity to use when delivering events. @@ -605,15 +617,15 @@ class DeliveryWithResourceIdentity(msrest.serialization.Model): """ _attribute_map = { - 'identity': {'key': 'identity', 'type': 'EventSubscriptionIdentity'}, - 'destination': {'key': 'destination', 'type': 'EventSubscriptionDestination'}, + "identity": {"key": "identity", "type": "EventSubscriptionIdentity"}, + "destination": {"key": "destination", "type": "EventSubscriptionDestination"}, } def __init__( self, *, - identity: Optional["EventSubscriptionIdentity"] = None, - destination: Optional["EventSubscriptionDestination"] = None, + identity: Optional["_models.EventSubscriptionIdentity"] = None, + destination: Optional["_models.EventSubscriptionDestination"] = None, **kwargs ): """ @@ -625,7 +637,7 @@ def __init__( delivery / dead-lettering. :paramtype destination: ~azure.mgmt.eventgrid.models.EventSubscriptionDestination """ - super(DeliveryWithResourceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.identity = identity self.destination = destination @@ -643,46 +655,40 @@ class TrackedResource(Resource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class Domain(TrackedResource): +class Domain(TrackedResource): # pylint: disable=too-many-instance-attributes """EventGrid Domain. Variables are only populated by the server, and will be ignored when sending a request. @@ -695,9 +701,9 @@ class Domain(TrackedResource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar system_data: The system metadata relating to the Event Grid Domain resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData @@ -706,15 +712,15 @@ class Domain(TrackedResource): :ivar private_endpoint_connections: List of private endpoint connections. :vartype private_endpoint_connections: list[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] - :ivar provisioning_state: Provisioning state of the Event Grid Domain Resource. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the Event Grid Domain Resource. Known values + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.DomainProvisioningState :ivar endpoint: Endpoint for the Event Grid Domain Resource which is used for publishing the events. :vartype endpoint: str :ivar input_schema: This determines the format that Event Grid should expect for incoming - events published to the Event Grid Domain Resource. Possible values include: "EventGridSchema", - "CustomEventSchema", "CloudEventSchemaV1_0". + events published to the Event Grid Domain Resource. Known values are: "EventGridSchema", + "CustomEventSchema", and "CloudEventSchemaV1_0". :vartype input_schema: str or ~azure.mgmt.eventgrid.models.InputSchema :ivar input_schema_mapping: Information about the InputSchemaMapping which specified the info about mapping event payload. @@ -725,7 +731,7 @@ class Domain(TrackedResource): default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :ivar inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -764,43 +770,52 @@ class Domain(TrackedResource): flexibility to perform less operations and manage fewer resources by the user. :vartype auto_delete_topic_with_last_subscription: bool - :ivar data_residency_boundary: Data Residency Boundary of the resource. Possible values - include: "WithinGeopair", "WithinRegion". + :ivar data_residency_boundary: Data Residency Boundary of the resource. Known values are: + "WithinGeopair" and "WithinRegion". :vartype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'endpoint': {'readonly': True}, - 'metric_resource_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "endpoint": {"readonly": True}, + "metric_resource_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'endpoint': {'key': 'properties.endpoint', 'type': 'str'}, - 'input_schema': {'key': 'properties.inputSchema', 'type': 'str'}, - 'input_schema_mapping': {'key': 'properties.inputSchemaMapping', 'type': 'InputSchemaMapping'}, - 'metric_resource_id': {'key': 'properties.metricResourceId', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'inbound_ip_rules': {'key': 'properties.inboundIpRules', 'type': '[InboundIpRule]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'auto_create_topic_with_first_subscription': {'key': 'properties.autoCreateTopicWithFirstSubscription', 'type': 'bool'}, - 'auto_delete_topic_with_last_subscription': {'key': 'properties.autoDeleteTopicWithLastSubscription', 'type': 'bool'}, - 'data_residency_boundary': {'key': 'properties.dataResidencyBoundary', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "endpoint": {"key": "properties.endpoint", "type": "str"}, + "input_schema": {"key": "properties.inputSchema", "type": "str"}, + "input_schema_mapping": {"key": "properties.inputSchemaMapping", "type": "InputSchemaMapping"}, + "metric_resource_id": {"key": "properties.metricResourceId", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "inbound_ip_rules": {"key": "properties.inboundIpRules", "type": "[InboundIpRule]"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "auto_create_topic_with_first_subscription": { + "key": "properties.autoCreateTopicWithFirstSubscription", + "type": "bool", + }, + "auto_delete_topic_with_last_subscription": { + "key": "properties.autoDeleteTopicWithLastSubscription", + "type": "bool", + }, + "data_residency_boundary": {"key": "properties.dataResidencyBoundary", "type": "str"}, } def __init__( @@ -808,27 +823,27 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, - input_schema: Optional[Union[str, "InputSchema"]] = None, - input_schema_mapping: Optional["InputSchemaMapping"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - inbound_ip_rules: Optional[List["InboundIpRule"]] = None, - disable_local_auth: Optional[bool] = False, - auto_create_topic_with_first_subscription: Optional[bool] = True, - auto_delete_topic_with_last_subscription: Optional[bool] = True, - data_residency_boundary: Optional[Union[str, "DataResidencyBoundary"]] = None, + identity: Optional["_models.IdentityInfo"] = None, + input_schema: Optional[Union[str, "_models.InputSchema"]] = None, + input_schema_mapping: Optional["_models.InputSchemaMapping"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + inbound_ip_rules: Optional[List["_models.InboundIpRule"]] = None, + disable_local_auth: bool = False, + auto_create_topic_with_first_subscription: bool = True, + auto_delete_topic_with_last_subscription: bool = True, + data_residency_boundary: Optional[Union[str, "_models.DataResidencyBoundary"]] = None, **kwargs ): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword identity: Identity information for the Event Grid Domain resource. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo :keyword input_schema: This determines the format that Event Grid should expect for incoming - events published to the Event Grid Domain Resource. Possible values include: "EventGridSchema", - "CustomEventSchema", "CloudEventSchemaV1_0". + events published to the Event Grid Domain Resource. Known values are: "EventGridSchema", + "CustomEventSchema", and "CloudEventSchemaV1_0". :paramtype input_schema: str or ~azure.mgmt.eventgrid.models.InputSchema :keyword input_schema_mapping: Information about the InputSchemaMapping which specified the info about mapping event payload. @@ -837,7 +852,7 @@ def __init__( default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :keyword inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -876,11 +891,11 @@ def __init__( flexibility to perform less operations and manage fewer resources by the user. :paramtype auto_delete_topic_with_last_subscription: bool - :keyword data_residency_boundary: Data Residency Boundary of the resource. Possible values - include: "WithinGeopair", "WithinRegion". + :keyword data_residency_boundary: Data Residency Boundary of the resource. Known values are: + "WithinGeopair" and "WithinRegion". :paramtype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ - super(Domain, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.system_data = None self.identity = identity self.private_endpoint_connections = None @@ -897,38 +912,33 @@ def __init__( self.data_residency_boundary = data_residency_boundary -class DomainRegenerateKeyRequest(msrest.serialization.Model): +class DomainRegenerateKeyRequest(_serialization.Model): """Domain regenerate share access key request. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. Key name to regenerate key1 or key2. + :ivar key_name: Key name to regenerate key1 or key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. Key name to regenerate key1 or key2. + :keyword key_name: Key name to regenerate key1 or key2. Required. :paramtype key_name: str """ - super(DomainRegenerateKeyRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class DomainSharedAccessKeys(msrest.serialization.Model): +class DomainSharedAccessKeys(_serialization.Model): """Shared access keys of the Domain. :ivar key1: Shared access key1 for the domain. @@ -938,29 +948,23 @@ class DomainSharedAccessKeys(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'str'}, - 'key2': {'key': 'key2', 'type': 'str'}, + "key1": {"key": "key1", "type": "str"}, + "key2": {"key": "key2", "type": "str"}, } - def __init__( - self, - *, - key1: Optional[str] = None, - key2: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[str] = None, key2: Optional[str] = None, **kwargs): """ :keyword key1: Shared access key1 for the domain. :paramtype key1: str :keyword key2: Shared access key2 for the domain. :paramtype key2: str """ - super(DomainSharedAccessKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class DomainsListResult(msrest.serialization.Model): +class DomainsListResult(_serialization.Model): """Result of the List Domains operation. :ivar value: A collection of Domains. @@ -970,24 +974,18 @@ class DomainsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Domain]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Domain]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Domain"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Domain"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: A collection of Domains. :paramtype value: list[~azure.mgmt.eventgrid.models.Domain] :keyword next_link: A link for the next page of domains. :paramtype next_link: str """ - super(DomainsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1005,39 +1003,35 @@ class DomainTopic(Resource): :vartype type: str :ivar system_data: The system metadata relating to Domain Topic resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData - :ivar provisioning_state: Provisioning state of the domain topic. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the domain topic. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.DomainTopicProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DomainTopic, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None -class DomainTopicsListResult(msrest.serialization.Model): +class DomainTopicsListResult(_serialization.Model): """Result of the List Domain Topics operation. :ivar value: A collection of Domain Topics. @@ -1047,16 +1041,12 @@ class DomainTopicsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[DomainTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DomainTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["DomainTopic"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.DomainTopic"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of Domain Topics. @@ -1064,15 +1054,15 @@ def __init__( :keyword next_link: A link for the next page of domain topics. :paramtype next_link: str """ - super(DomainTopicsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class DomainUpdateParameters(msrest.serialization.Model): +class DomainUpdateParameters(_serialization.Model): """Properties of the Domain update. - :ivar tags: A set of tags. Tags of the domains resource. + :ivar tags: Tags of the domains resource. :vartype tags: dict[str, str] :ivar identity: Identity information for the resource. :vartype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -1080,7 +1070,7 @@ class DomainUpdateParameters(msrest.serialization.Model): default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :ivar inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -1119,37 +1109,43 @@ class DomainUpdateParameters(msrest.serialization.Model): flexibility to perform less operations and manage fewer resources by the user. :vartype auto_delete_topic_with_last_subscription: bool - :ivar data_residency_boundary: The data residency boundary for the domain. Possible values - include: "WithinGeopair", "WithinRegion". + :ivar data_residency_boundary: The data residency boundary for the domain. Known values are: + "WithinGeopair" and "WithinRegion". :vartype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'inbound_ip_rules': {'key': 'properties.inboundIpRules', 'type': '[InboundIpRule]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'auto_create_topic_with_first_subscription': {'key': 'properties.autoCreateTopicWithFirstSubscription', 'type': 'bool'}, - 'auto_delete_topic_with_last_subscription': {'key': 'properties.autoDeleteTopicWithLastSubscription', 'type': 'bool'}, - 'data_residency_boundary': {'key': 'properties.dataResidencyBoundary', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "inbound_ip_rules": {"key": "properties.inboundIpRules", "type": "[InboundIpRule]"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "auto_create_topic_with_first_subscription": { + "key": "properties.autoCreateTopicWithFirstSubscription", + "type": "bool", + }, + "auto_delete_topic_with_last_subscription": { + "key": "properties.autoDeleteTopicWithLastSubscription", + "type": "bool", + }, + "data_residency_boundary": {"key": "properties.dataResidencyBoundary", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - inbound_ip_rules: Optional[List["InboundIpRule"]] = None, + identity: Optional["_models.IdentityInfo"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + inbound_ip_rules: Optional[List["_models.InboundIpRule"]] = None, disable_local_auth: Optional[bool] = None, auto_create_topic_with_first_subscription: Optional[bool] = None, auto_delete_topic_with_last_subscription: Optional[bool] = None, - data_residency_boundary: Optional[Union[str, "DataResidencyBoundary"]] = None, + data_residency_boundary: Optional[Union[str, "_models.DataResidencyBoundary"]] = None, **kwargs ): """ - :keyword tags: A set of tags. Tags of the domains resource. + :keyword tags: Tags of the domains resource. :paramtype tags: dict[str, str] :keyword identity: Identity information for the resource. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -1157,7 +1153,7 @@ def __init__( default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :keyword inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -1196,11 +1192,11 @@ def __init__( flexibility to perform less operations and manage fewer resources by the user. :paramtype auto_delete_topic_with_last_subscription: bool - :keyword data_residency_boundary: The data residency boundary for the domain. Possible values - include: "WithinGeopair", "WithinRegion". + :keyword data_residency_boundary: The data residency boundary for the domain. Known values are: + "WithinGeopair" and "WithinRegion". :paramtype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ - super(DomainUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity self.public_network_access = public_network_access @@ -1218,38 +1214,32 @@ class DynamicDeliveryAttributeMapping(DeliveryAttributeMapping): :ivar name: Name of the delivery attribute or header. :vartype name: str - :ivar type: Required. Type of the delivery attribute or header name.Constant filled by server. - Possible values include: "Static", "Dynamic". + :ivar type: Type of the delivery attribute or header name. Required. Known values are: "Static" + and "Dynamic". :vartype type: str or ~azure.mgmt.eventgrid.models.DeliveryAttributeMappingType :ivar source_field: JSON path in the event which contains attribute value. :vartype source_field: str """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source_field': {'key': 'properties.sourceField', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source_field": {"key": "properties.sourceField", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - source_field: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, source_field: Optional[str] = None, **kwargs): """ :keyword name: Name of the delivery attribute or header. :paramtype name: str :keyword source_field: JSON path in the event which contains attribute value. :paramtype source_field: str """ - super(DynamicDeliveryAttributeMapping, self).__init__(name=name, **kwargs) - self.type = 'Dynamic' # type: str + super().__init__(name=name, **kwargs) + self.type = "Dynamic" # type: str self.source_field = source_field @@ -1258,9 +1248,9 @@ class EventHubEventSubscriptionDestination(EventSubscriptionDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar resource_id: The Azure Resource Id that represents the endpoint of an Event Hub destination of an event subscription. @@ -1271,20 +1261,23 @@ class EventHubEventSubscriptionDestination(EventSubscriptionDestination): """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'delivery_attribute_mappings': {'key': 'properties.deliveryAttributeMappings', 'type': '[DeliveryAttributeMapping]'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "delivery_attribute_mappings": { + "key": "properties.deliveryAttributeMappings", + "type": "[DeliveryAttributeMapping]", + }, } def __init__( self, *, resource_id: Optional[str] = None, - delivery_attribute_mappings: Optional[List["DeliveryAttributeMapping"]] = None, + delivery_attribute_mappings: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs ): """ @@ -1295,13 +1288,13 @@ def __init__( :paramtype delivery_attribute_mappings: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(EventHubEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'EventHub' # type: str + super().__init__(**kwargs) + self.endpoint_type = "EventHub" # type: str self.resource_id = resource_id self.delivery_attribute_mappings = delivery_attribute_mappings -class EventSubscription(Resource): +class EventSubscription(Resource): # pylint: disable=too-many-instance-attributes """Event Subscription. Variables are only populated by the server, and will be ignored when sending a request. @@ -1316,8 +1309,8 @@ class EventSubscription(Resource): :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData :ivar topic: Name of the topic of the event subscription. :vartype topic: str - :ivar provisioning_state: Provisioning state of the event subscription. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed", + :ivar provisioning_state: Provisioning state of the event subscription. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed", and "AwaitingManualAction". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.EventSubscriptionProvisioningState @@ -1338,8 +1331,8 @@ class EventSubscription(Resource): :vartype labels: list[str] :ivar expiration_time_utc: Expiration time of the event subscription. :vartype expiration_time_utc: ~datetime.datetime - :ivar event_delivery_schema: The event delivery schema for the event subscription. Possible - values include: "EventGridSchema", "CustomInputSchema", "CloudEventSchemaV1_0". + :ivar event_delivery_schema: The event delivery schema for the event subscription. Known values + are: "EventGridSchema", "CustomInputSchema", and "CloudEventSchemaV1_0". :vartype event_delivery_schema: str or ~azure.mgmt.eventgrid.models.EventDeliverySchema :ivar retry_policy: The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. @@ -1359,44 +1352,50 @@ class EventSubscription(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'topic': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "topic": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'topic': {'key': 'properties.topic', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'destination': {'key': 'properties.destination', 'type': 'EventSubscriptionDestination'}, - 'delivery_with_resource_identity': {'key': 'properties.deliveryWithResourceIdentity', 'type': 'DeliveryWithResourceIdentity'}, - 'filter': {'key': 'properties.filter', 'type': 'EventSubscriptionFilter'}, - 'labels': {'key': 'properties.labels', 'type': '[str]'}, - 'expiration_time_utc': {'key': 'properties.expirationTimeUtc', 'type': 'iso-8601'}, - 'event_delivery_schema': {'key': 'properties.eventDeliverySchema', 'type': 'str'}, - 'retry_policy': {'key': 'properties.retryPolicy', 'type': 'RetryPolicy'}, - 'dead_letter_destination': {'key': 'properties.deadLetterDestination', 'type': 'DeadLetterDestination'}, - 'dead_letter_with_resource_identity': {'key': 'properties.deadLetterWithResourceIdentity', 'type': 'DeadLetterWithResourceIdentity'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "topic": {"key": "properties.topic", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "destination": {"key": "properties.destination", "type": "EventSubscriptionDestination"}, + "delivery_with_resource_identity": { + "key": "properties.deliveryWithResourceIdentity", + "type": "DeliveryWithResourceIdentity", + }, + "filter": {"key": "properties.filter", "type": "EventSubscriptionFilter"}, + "labels": {"key": "properties.labels", "type": "[str]"}, + "expiration_time_utc": {"key": "properties.expirationTimeUtc", "type": "iso-8601"}, + "event_delivery_schema": {"key": "properties.eventDeliverySchema", "type": "str"}, + "retry_policy": {"key": "properties.retryPolicy", "type": "RetryPolicy"}, + "dead_letter_destination": {"key": "properties.deadLetterDestination", "type": "DeadLetterDestination"}, + "dead_letter_with_resource_identity": { + "key": "properties.deadLetterWithResourceIdentity", + "type": "DeadLetterWithResourceIdentity", + }, } def __init__( self, *, - destination: Optional["EventSubscriptionDestination"] = None, - delivery_with_resource_identity: Optional["DeliveryWithResourceIdentity"] = None, - filter: Optional["EventSubscriptionFilter"] = None, + destination: Optional["_models.EventSubscriptionDestination"] = None, + delivery_with_resource_identity: Optional["_models.DeliveryWithResourceIdentity"] = None, + filter: Optional["_models.EventSubscriptionFilter"] = None, # pylint: disable=redefined-builtin labels: Optional[List[str]] = None, expiration_time_utc: Optional[datetime.datetime] = None, - event_delivery_schema: Optional[Union[str, "EventDeliverySchema"]] = None, - retry_policy: Optional["RetryPolicy"] = None, - dead_letter_destination: Optional["DeadLetterDestination"] = None, - dead_letter_with_resource_identity: Optional["DeadLetterWithResourceIdentity"] = None, + event_delivery_schema: Optional[Union[str, "_models.EventDeliverySchema"]] = None, + retry_policy: Optional["_models.RetryPolicy"] = None, + dead_letter_destination: Optional["_models.DeadLetterDestination"] = None, + dead_letter_with_resource_identity: Optional["_models.DeadLetterWithResourceIdentity"] = None, **kwargs ): """ @@ -1417,8 +1416,8 @@ def __init__( :paramtype labels: list[str] :keyword expiration_time_utc: Expiration time of the event subscription. :paramtype expiration_time_utc: ~datetime.datetime - :keyword event_delivery_schema: The event delivery schema for the event subscription. Possible - values include: "EventGridSchema", "CustomInputSchema", "CloudEventSchemaV1_0". + :keyword event_delivery_schema: The event delivery schema for the event subscription. Known + values are: "EventGridSchema", "CustomInputSchema", and "CloudEventSchemaV1_0". :paramtype event_delivery_schema: str or ~azure.mgmt.eventgrid.models.EventDeliverySchema :keyword retry_policy: The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. @@ -1436,7 +1435,7 @@ def __init__( :paramtype dead_letter_with_resource_identity: ~azure.mgmt.eventgrid.models.DeadLetterWithResourceIdentity """ - super(EventSubscription, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.topic = None self.provisioning_state = None @@ -1451,7 +1450,7 @@ def __init__( self.dead_letter_with_resource_identity = dead_letter_with_resource_identity -class EventSubscriptionFilter(msrest.serialization.Model): +class EventSubscriptionFilter(_serialization.Model): """Filter for the Event Subscription. :ivar subject_begins_with: An optional string to filter events for an event subscription based @@ -1480,12 +1479,12 @@ class EventSubscriptionFilter(msrest.serialization.Model): """ _attribute_map = { - 'subject_begins_with': {'key': 'subjectBeginsWith', 'type': 'str'}, - 'subject_ends_with': {'key': 'subjectEndsWith', 'type': 'str'}, - 'included_event_types': {'key': 'includedEventTypes', 'type': '[str]'}, - 'is_subject_case_sensitive': {'key': 'isSubjectCaseSensitive', 'type': 'bool'}, - 'enable_advanced_filtering_on_arrays': {'key': 'enableAdvancedFilteringOnArrays', 'type': 'bool'}, - 'advanced_filters': {'key': 'advancedFilters', 'type': '[AdvancedFilter]'}, + "subject_begins_with": {"key": "subjectBeginsWith", "type": "str"}, + "subject_ends_with": {"key": "subjectEndsWith", "type": "str"}, + "included_event_types": {"key": "includedEventTypes", "type": "[str]"}, + "is_subject_case_sensitive": {"key": "isSubjectCaseSensitive", "type": "bool"}, + "enable_advanced_filtering_on_arrays": {"key": "enableAdvancedFilteringOnArrays", "type": "bool"}, + "advanced_filters": {"key": "advancedFilters", "type": "[AdvancedFilter]"}, } def __init__( @@ -1494,9 +1493,9 @@ def __init__( subject_begins_with: Optional[str] = None, subject_ends_with: Optional[str] = None, included_event_types: Optional[List[str]] = None, - is_subject_case_sensitive: Optional[bool] = False, + is_subject_case_sensitive: bool = False, enable_advanced_filtering_on_arrays: Optional[bool] = None, - advanced_filters: Optional[List["AdvancedFilter"]] = None, + advanced_filters: Optional[List["_models.AdvancedFilter"]] = None, **kwargs ): """ @@ -1524,7 +1523,7 @@ def __init__( subscriptions. :paramtype advanced_filters: list[~azure.mgmt.eventgrid.models.AdvancedFilter] """ - super(EventSubscriptionFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject_begins_with = subject_begins_with self.subject_ends_with = subject_ends_with self.included_event_types = included_event_types @@ -1533,7 +1532,7 @@ def __init__( self.advanced_filters = advanced_filters -class EventSubscriptionFullUrl(msrest.serialization.Model): +class EventSubscriptionFullUrl(_serialization.Model): """Full endpoint url of an event subscription. :ivar endpoint_url: The URL that represents the endpoint of the destination of an event @@ -1542,61 +1541,56 @@ class EventSubscriptionFullUrl(msrest.serialization.Model): """ _attribute_map = { - 'endpoint_url': {'key': 'endpointUrl', 'type': 'str'}, + "endpoint_url": {"key": "endpointUrl", "type": "str"}, } - def __init__( - self, - *, - endpoint_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, endpoint_url: Optional[str] = None, **kwargs): """ :keyword endpoint_url: The URL that represents the endpoint of the destination of an event subscription. :paramtype endpoint_url: str """ - super(EventSubscriptionFullUrl, self).__init__(**kwargs) + super().__init__(**kwargs) self.endpoint_url = endpoint_url -class EventSubscriptionIdentity(msrest.serialization.Model): +class EventSubscriptionIdentity(_serialization.Model): """The identity information with the event subscription. :ivar type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will - remove any identity. Possible values include: "SystemAssigned", "UserAssigned". + remove any identity. Known values are: "SystemAssigned" and "UserAssigned". :vartype type: str or ~azure.mgmt.eventgrid.models.EventSubscriptionIdentityType :ivar user_assigned_identity: The user identity associated with the resource. :vartype user_assigned_identity: str """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "EventSubscriptionIdentityType"]] = None, + type: Optional[Union[str, "_models.EventSubscriptionIdentityType"]] = None, user_assigned_identity: Optional[str] = None, **kwargs ): """ :keyword type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type - 'None' will remove any identity. Possible values include: "SystemAssigned", "UserAssigned". + 'None' will remove any identity. Known values are: "SystemAssigned" and "UserAssigned". :paramtype type: str or ~azure.mgmt.eventgrid.models.EventSubscriptionIdentityType :keyword user_assigned_identity: The user identity associated with the resource. :paramtype user_assigned_identity: str """ - super(EventSubscriptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.user_assigned_identity = user_assigned_identity -class EventSubscriptionsListResult(msrest.serialization.Model): +class EventSubscriptionsListResult(_serialization.Model): """Result of the List EventSubscriptions operation. :ivar value: A collection of EventSubscriptions. @@ -1606,16 +1600,12 @@ class EventSubscriptionsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[EventSubscription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EventSubscription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["EventSubscription"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.EventSubscription"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of EventSubscriptions. @@ -1623,12 +1613,12 @@ def __init__( :keyword next_link: A link for the next page of event subscriptions. :paramtype next_link: str """ - super(EventSubscriptionsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class EventSubscriptionUpdateParameters(msrest.serialization.Model): +class EventSubscriptionUpdateParameters(_serialization.Model): """Properties of the Event Subscription update. :ivar destination: Information about the destination where events have to be delivered for the @@ -1648,8 +1638,8 @@ class EventSubscriptionUpdateParameters(msrest.serialization.Model): :vartype labels: list[str] :ivar expiration_time_utc: Information about the expiration time for the event subscription. :vartype expiration_time_utc: ~datetime.datetime - :ivar event_delivery_schema: The event delivery schema for the event subscription. Possible - values include: "EventGridSchema", "CustomInputSchema", "CloudEventSchemaV1_0". + :ivar event_delivery_schema: The event delivery schema for the event subscription. Known values + are: "EventGridSchema", "CustomInputSchema", and "CloudEventSchemaV1_0". :vartype event_delivery_schema: str or ~azure.mgmt.eventgrid.models.EventDeliverySchema :ivar retry_policy: The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. @@ -1669,29 +1659,35 @@ class EventSubscriptionUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'destination': {'key': 'destination', 'type': 'EventSubscriptionDestination'}, - 'delivery_with_resource_identity': {'key': 'deliveryWithResourceIdentity', 'type': 'DeliveryWithResourceIdentity'}, - 'filter': {'key': 'filter', 'type': 'EventSubscriptionFilter'}, - 'labels': {'key': 'labels', 'type': '[str]'}, - 'expiration_time_utc': {'key': 'expirationTimeUtc', 'type': 'iso-8601'}, - 'event_delivery_schema': {'key': 'eventDeliverySchema', 'type': 'str'}, - 'retry_policy': {'key': 'retryPolicy', 'type': 'RetryPolicy'}, - 'dead_letter_destination': {'key': 'deadLetterDestination', 'type': 'DeadLetterDestination'}, - 'dead_letter_with_resource_identity': {'key': 'deadLetterWithResourceIdentity', 'type': 'DeadLetterWithResourceIdentity'}, + "destination": {"key": "destination", "type": "EventSubscriptionDestination"}, + "delivery_with_resource_identity": { + "key": "deliveryWithResourceIdentity", + "type": "DeliveryWithResourceIdentity", + }, + "filter": {"key": "filter", "type": "EventSubscriptionFilter"}, + "labels": {"key": "labels", "type": "[str]"}, + "expiration_time_utc": {"key": "expirationTimeUtc", "type": "iso-8601"}, + "event_delivery_schema": {"key": "eventDeliverySchema", "type": "str"}, + "retry_policy": {"key": "retryPolicy", "type": "RetryPolicy"}, + "dead_letter_destination": {"key": "deadLetterDestination", "type": "DeadLetterDestination"}, + "dead_letter_with_resource_identity": { + "key": "deadLetterWithResourceIdentity", + "type": "DeadLetterWithResourceIdentity", + }, } def __init__( self, *, - destination: Optional["EventSubscriptionDestination"] = None, - delivery_with_resource_identity: Optional["DeliveryWithResourceIdentity"] = None, - filter: Optional["EventSubscriptionFilter"] = None, + destination: Optional["_models.EventSubscriptionDestination"] = None, + delivery_with_resource_identity: Optional["_models.DeliveryWithResourceIdentity"] = None, + filter: Optional["_models.EventSubscriptionFilter"] = None, # pylint: disable=redefined-builtin labels: Optional[List[str]] = None, expiration_time_utc: Optional[datetime.datetime] = None, - event_delivery_schema: Optional[Union[str, "EventDeliverySchema"]] = None, - retry_policy: Optional["RetryPolicy"] = None, - dead_letter_destination: Optional["DeadLetterDestination"] = None, - dead_letter_with_resource_identity: Optional["DeadLetterWithResourceIdentity"] = None, + event_delivery_schema: Optional[Union[str, "_models.EventDeliverySchema"]] = None, + retry_policy: Optional["_models.RetryPolicy"] = None, + dead_letter_destination: Optional["_models.DeadLetterDestination"] = None, + dead_letter_with_resource_identity: Optional["_models.DeadLetterWithResourceIdentity"] = None, **kwargs ): """ @@ -1712,8 +1708,8 @@ def __init__( :paramtype labels: list[str] :keyword expiration_time_utc: Information about the expiration time for the event subscription. :paramtype expiration_time_utc: ~datetime.datetime - :keyword event_delivery_schema: The event delivery schema for the event subscription. Possible - values include: "EventGridSchema", "CustomInputSchema", "CloudEventSchemaV1_0". + :keyword event_delivery_schema: The event delivery schema for the event subscription. Known + values are: "EventGridSchema", "CustomInputSchema", and "CloudEventSchemaV1_0". :paramtype event_delivery_schema: str or ~azure.mgmt.eventgrid.models.EventDeliverySchema :keyword retry_policy: The retry policy for events. This can be used to configure maximum number of delivery attempts and time to live for events. @@ -1731,7 +1727,7 @@ def __init__( :paramtype dead_letter_with_resource_identity: ~azure.mgmt.eventgrid.models.DeadLetterWithResourceIdentity """ - super(EventSubscriptionUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.destination = destination self.delivery_with_resource_identity = delivery_with_resource_identity self.filter = filter @@ -1765,19 +1761,19 @@ class EventType(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'schema_url': {'key': 'properties.schemaUrl', 'type': 'str'}, - 'is_in_default_set': {'key': 'properties.isInDefaultSet', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "schema_url": {"key": "properties.schemaUrl", "type": "str"}, + "is_in_default_set": {"key": "properties.isInDefaultSet", "type": "bool"}, } def __init__( @@ -1799,17 +1795,17 @@ def __init__( :keyword is_in_default_set: IsInDefaultSet flag of the event type. :paramtype is_in_default_set: bool """ - super(EventType, self).__init__(**kwargs) + super().__init__(**kwargs) self.display_name = display_name self.description = description self.schema_url = schema_url self.is_in_default_set = is_in_default_set -class EventTypeInfo(msrest.serialization.Model): +class EventTypeInfo(_serialization.Model): """The event type information for Channels. - :ivar kind: The kind of event type used. Possible values include: "Inline". + :ivar kind: The kind of event type used. "Inline" :vartype kind: str or ~azure.mgmt.eventgrid.models.EventDefinitionKind :ivar inline_event_types: A collection of inline event types for the resource. The inline event type keys are of type string which represents the name of the event. @@ -1820,19 +1816,19 @@ class EventTypeInfo(msrest.serialization.Model): """ _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'inline_event_types': {'key': 'inlineEventTypes', 'type': '{InlineEventProperties}'}, + "kind": {"key": "kind", "type": "str"}, + "inline_event_types": {"key": "inlineEventTypes", "type": "{InlineEventProperties}"}, } def __init__( self, *, - kind: Optional[Union[str, "EventDefinitionKind"]] = None, - inline_event_types: Optional[Dict[str, "InlineEventProperties"]] = None, + kind: Optional[Union[str, "_models.EventDefinitionKind"]] = None, + inline_event_types: Optional[Dict[str, "_models.InlineEventProperties"]] = None, **kwargs ): """ - :keyword kind: The kind of event type used. Possible values include: "Inline". + :keyword kind: The kind of event type used. "Inline" :paramtype kind: str or ~azure.mgmt.eventgrid.models.EventDefinitionKind :keyword inline_event_types: A collection of inline event types for the resource. The inline event type keys are of type string which represents the name of the event. @@ -1841,12 +1837,12 @@ def __init__( information for every inline event type. :paramtype inline_event_types: dict[str, ~azure.mgmt.eventgrid.models.InlineEventProperties] """ - super(EventTypeInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.kind = kind self.inline_event_types = inline_event_types -class EventTypesListResult(msrest.serialization.Model): +class EventTypesListResult(_serialization.Model): """Result of the List Event Types operation. :ivar value: A collection of event types. @@ -1854,20 +1850,15 @@ class EventTypesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[EventType]'}, + "value": {"key": "value", "type": "[EventType]"}, } - def __init__( - self, - *, - value: Optional[List["EventType"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.EventType"]] = None, **kwargs): """ :keyword value: A collection of event types. :paramtype value: list[~azure.mgmt.eventgrid.models.EventType] """ - super(EventTypesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -1891,35 +1882,29 @@ class ExtensionTopic(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'system_topic': {'key': 'properties.systemTopic', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "description": {"key": "properties.description", "type": "str"}, + "system_topic": {"key": "properties.systemTopic", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - system_topic: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, system_topic: Optional[str] = None, **kwargs): """ :keyword description: Description of the extension topic. :paramtype description: str :keyword system_topic: System topic resource id which is mapped to the source. :paramtype system_topic: str """ - super(ExtensionTopic, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.description = description self.system_topic = system_topic @@ -1930,9 +1915,9 @@ class HybridConnectionEventSubscriptionDestination(EventSubscriptionDestination) All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar resource_id: The Azure Resource ID of an hybrid connection that is the destination of an event subscription. @@ -1943,20 +1928,23 @@ class HybridConnectionEventSubscriptionDestination(EventSubscriptionDestination) """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'delivery_attribute_mappings': {'key': 'properties.deliveryAttributeMappings', 'type': '[DeliveryAttributeMapping]'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "delivery_attribute_mappings": { + "key": "properties.deliveryAttributeMappings", + "type": "[DeliveryAttributeMapping]", + }, } def __init__( self, *, resource_id: Optional[str] = None, - delivery_attribute_mappings: Optional[List["DeliveryAttributeMapping"]] = None, + delivery_attribute_mappings: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs ): """ @@ -1967,18 +1955,18 @@ def __init__( :paramtype delivery_attribute_mappings: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(HybridConnectionEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'HybridConnection' # type: str + super().__init__(**kwargs) + self.endpoint_type = "HybridConnection" # type: str self.resource_id = resource_id self.delivery_attribute_mappings = delivery_attribute_mappings -class IdentityInfo(msrest.serialization.Model): +class IdentityInfo(_serialization.Model): """The identity information for the resource. :ivar type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type 'None' will - remove any identity. Possible values include: "None", "SystemAssigned", "UserAssigned", + remove any identity. Known values are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned, UserAssigned". :vartype type: str or ~azure.mgmt.eventgrid.models.IdentityType :ivar principal_id: The principal ID of resource identity. @@ -1994,26 +1982,26 @@ class IdentityInfo(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserIdentityProperties}'}, + "type": {"key": "type", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, } def __init__( self, *, - type: Optional[Union[str, "IdentityType"]] = None, + type: Optional[Union[str, "_models.IdentityType"]] = None, principal_id: Optional[str] = None, tenant_id: Optional[str] = None, - user_assigned_identities: Optional[Dict[str, "UserIdentityProperties"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, **kwargs ): """ :keyword type: The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user-assigned identities. The type - 'None' will remove any identity. Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned". + 'None' will remove any identity. Known values are: "None", "SystemAssigned", "UserAssigned", + and "SystemAssigned, UserAssigned". :paramtype type: str or ~azure.mgmt.eventgrid.models.IdentityType :keyword principal_id: The principal ID of resource identity. :paramtype principal_id: str @@ -2026,48 +2014,42 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.eventgrid.models.UserIdentityProperties] """ - super(IdentityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.principal_id = principal_id self.tenant_id = tenant_id self.user_assigned_identities = user_assigned_identities -class InboundIpRule(msrest.serialization.Model): +class InboundIpRule(_serialization.Model): """InboundIpRule. :ivar ip_mask: IP Address in CIDR notation e.g., 10.0.0.0/8. :vartype ip_mask: str - :ivar action: Action to perform based on the match or no match of the IpMask. Possible values - include: "Allow". + :ivar action: Action to perform based on the match or no match of the IpMask. "Allow" :vartype action: str or ~azure.mgmt.eventgrid.models.IpActionType """ _attribute_map = { - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "action": {"key": "action", "type": "str"}, } def __init__( - self, - *, - ip_mask: Optional[str] = None, - action: Optional[Union[str, "IpActionType"]] = None, - **kwargs + self, *, ip_mask: Optional[str] = None, action: Optional[Union[str, "_models.IpActionType"]] = None, **kwargs ): """ :keyword ip_mask: IP Address in CIDR notation e.g., 10.0.0.0/8. :paramtype ip_mask: str - :keyword action: Action to perform based on the match or no match of the IpMask. Possible - values include: "Allow". + :keyword action: Action to perform based on the match or no match of the IpMask. "Allow" :paramtype action: str or ~azure.mgmt.eventgrid.models.IpActionType """ - super(InboundIpRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_mask = ip_mask self.action = action -class InlineEventProperties(msrest.serialization.Model): +class InlineEventProperties(_serialization.Model): """Additional information about every inline event. :ivar description: The description for the inline event. @@ -2081,10 +2063,10 @@ class InlineEventProperties(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'documentation_url': {'key': 'documentationUrl', 'type': 'str'}, - 'data_schema_url': {'key': 'dataSchemaUrl', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "documentation_url": {"key": "documentationUrl", "type": "str"}, + "data_schema_url": {"key": "dataSchemaUrl", "type": "str"}, } def __init__( @@ -2106,45 +2088,38 @@ def __init__( :keyword data_schema_url: The dataSchemaUrl for the inline event. :paramtype data_schema_url: str """ - super(InlineEventProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.display_name = display_name self.documentation_url = documentation_url self.data_schema_url = data_schema_url -class InputSchemaMapping(msrest.serialization.Model): +class InputSchemaMapping(_serialization.Model): """By default, Event Grid expects events to be in the Event Grid event schema. Specifying an input schema mapping enables publishing to Event Grid using a custom input schema. Currently, the only supported type of InputSchemaMapping is 'JsonInputSchemaMapping'. - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: JsonInputSchemaMapping. + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + JsonInputSchemaMapping All required parameters must be populated in order to send to Azure. - :ivar input_schema_mapping_type: Required. Type of the custom mapping.Constant filled by - server. Possible values include: "Json". + :ivar input_schema_mapping_type: Type of the custom mapping. Required. "Json" :vartype input_schema_mapping_type: str or ~azure.mgmt.eventgrid.models.InputSchemaMappingType """ _validation = { - 'input_schema_mapping_type': {'required': True}, + "input_schema_mapping_type": {"required": True}, } _attribute_map = { - 'input_schema_mapping_type': {'key': 'inputSchemaMappingType', 'type': 'str'}, + "input_schema_mapping_type": {"key": "inputSchemaMappingType", "type": "str"}, } - _subtype_map = { - 'input_schema_mapping_type': {'Json': 'JsonInputSchemaMapping'} - } + _subtype_map = {"input_schema_mapping_type": {"Json": "JsonInputSchemaMapping"}} - def __init__( - self, - **kwargs - ): - """ - """ - super(InputSchemaMapping, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.input_schema_mapping_type = None # type: Optional[str] @@ -2153,38 +2128,33 @@ class IsNotNullAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str """ - super(IsNotNullAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'IsNotNull' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "IsNotNull" # type: str class IsNullOrUndefinedAdvancedFilter(AdvancedFilter): @@ -2192,41 +2162,36 @@ class IsNullOrUndefinedAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str """ - super(IsNullOrUndefinedAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'IsNullOrUndefined' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "IsNullOrUndefined" # type: str -class JsonField(msrest.serialization.Model): +class JsonField(_serialization.Model): """This is used to express the source of an input schema mapping for a single target field in the Event Grid Event schema. This is currently used in the mappings for the 'id', 'topic' and 'eventtime' properties. This represents a field in the input event schema. :ivar source_field: Name of a field in the input event schema that's to be used as the source @@ -2235,50 +2200,39 @@ class JsonField(msrest.serialization.Model): """ _attribute_map = { - 'source_field': {'key': 'sourceField', 'type': 'str'}, + "source_field": {"key": "sourceField", "type": "str"}, } - def __init__( - self, - *, - source_field: Optional[str] = None, - **kwargs - ): + def __init__(self, *, source_field: Optional[str] = None, **kwargs): """ :keyword source_field: Name of a field in the input event schema that's to be used as the source of a mapping. :paramtype source_field: str """ - super(JsonField, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_field = source_field -class JsonFieldWithDefault(msrest.serialization.Model): +class JsonFieldWithDefault(_serialization.Model): """This is used to express the source of an input schema mapping for a single target field -in the Event Grid Event schema. This is currently used in the mappings for the 'subject', -'eventtype' and 'dataversion' properties. This represents a field in the input event schema -along with a default value to be used, and at least one of these two properties should be provided. - - :ivar source_field: Name of a field in the input event schema that's to be used as the source - of a mapping. - :vartype source_field: str - :ivar default_value: The default value to be used for mapping when a SourceField is not - provided or if there's no property with the specified name in the published JSON event payload. - :vartype default_value: str + in the Event Grid Event schema. This is currently used in the mappings for the 'subject', + 'eventtype' and 'dataversion' properties. This represents a field in the input event schema + along with a default value to be used, and at least one of these two properties should be provided. + + :ivar source_field: Name of a field in the input event schema that's to be used as the source + of a mapping. + :vartype source_field: str + :ivar default_value: The default value to be used for mapping when a SourceField is not + provided or if there's no property with the specified name in the published JSON event payload. + :vartype default_value: str """ _attribute_map = { - 'source_field': {'key': 'sourceField', 'type': 'str'}, - 'default_value': {'key': 'defaultValue', 'type': 'str'}, + "source_field": {"key": "sourceField", "type": "str"}, + "default_value": {"key": "defaultValue", "type": "str"}, } - def __init__( - self, - *, - source_field: Optional[str] = None, - default_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, source_field: Optional[str] = None, default_value: Optional[str] = None, **kwargs): """ :keyword source_field: Name of a field in the input event schema that's to be used as the source of a mapping. @@ -2287,7 +2241,7 @@ def __init__( provided or if there's no property with the specified name in the published JSON event payload. :paramtype default_value: str """ - super(JsonFieldWithDefault, self).__init__(**kwargs) + super().__init__(**kwargs) self.source_field = source_field self.default_value = default_value @@ -2297,8 +2251,7 @@ class JsonInputSchemaMapping(InputSchemaMapping): All required parameters must be populated in order to send to Azure. - :ivar input_schema_mapping_type: Required. Type of the custom mapping.Constant filled by - server. Possible values include: "Json". + :ivar input_schema_mapping_type: Type of the custom mapping. Required. "Json" :vartype input_schema_mapping_type: str or ~azure.mgmt.eventgrid.models.InputSchemaMappingType :ivar id: The mapping information for the Id property of the Event Grid Event. :vartype id: ~azure.mgmt.eventgrid.models.JsonField @@ -2316,28 +2269,28 @@ class JsonInputSchemaMapping(InputSchemaMapping): """ _validation = { - 'input_schema_mapping_type': {'required': True}, + "input_schema_mapping_type": {"required": True}, } _attribute_map = { - 'input_schema_mapping_type': {'key': 'inputSchemaMappingType', 'type': 'str'}, - 'id': {'key': 'properties.id', 'type': 'JsonField'}, - 'topic': {'key': 'properties.topic', 'type': 'JsonField'}, - 'event_time': {'key': 'properties.eventTime', 'type': 'JsonField'}, - 'event_type': {'key': 'properties.eventType', 'type': 'JsonFieldWithDefault'}, - 'subject': {'key': 'properties.subject', 'type': 'JsonFieldWithDefault'}, - 'data_version': {'key': 'properties.dataVersion', 'type': 'JsonFieldWithDefault'}, + "input_schema_mapping_type": {"key": "inputSchemaMappingType", "type": "str"}, + "id": {"key": "properties.id", "type": "JsonField"}, + "topic": {"key": "properties.topic", "type": "JsonField"}, + "event_time": {"key": "properties.eventTime", "type": "JsonField"}, + "event_type": {"key": "properties.eventType", "type": "JsonFieldWithDefault"}, + "subject": {"key": "properties.subject", "type": "JsonFieldWithDefault"}, + "data_version": {"key": "properties.dataVersion", "type": "JsonFieldWithDefault"}, } def __init__( self, *, - id: Optional["JsonField"] = None, - topic: Optional["JsonField"] = None, - event_time: Optional["JsonField"] = None, - event_type: Optional["JsonFieldWithDefault"] = None, - subject: Optional["JsonFieldWithDefault"] = None, - data_version: Optional["JsonFieldWithDefault"] = None, + id: Optional["_models.JsonField"] = None, # pylint: disable=redefined-builtin + topic: Optional["_models.JsonField"] = None, + event_time: Optional["_models.JsonField"] = None, + event_type: Optional["_models.JsonFieldWithDefault"] = None, + subject: Optional["_models.JsonFieldWithDefault"] = None, + data_version: Optional["_models.JsonFieldWithDefault"] = None, **kwargs ): """ @@ -2357,8 +2310,8 @@ def __init__( Event. :paramtype data_version: ~azure.mgmt.eventgrid.models.JsonFieldWithDefault """ - super(JsonInputSchemaMapping, self).__init__(**kwargs) - self.input_schema_mapping_type = 'Json' # type: str + super().__init__(**kwargs) + self.input_schema_mapping_type = "Json" # type: str self.id = id self.topic = topic self.event_time = event_time @@ -2372,12 +2325,12 @@ class NumberGreaterThanAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2386,30 +2339,24 @@ class NumberGreaterThanAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "float"}, } - def __init__( - self, - *, - key: Optional[str] = None, - value: Optional[float] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, value: Optional[float] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword value: The filter value. :paramtype value: float """ - super(NumberGreaterThanAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberGreaterThan' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberGreaterThan" # type: str self.value = value @@ -2418,12 +2365,12 @@ class NumberGreaterThanOrEqualsAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2432,30 +2379,24 @@ class NumberGreaterThanOrEqualsAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "float"}, } - def __init__( - self, - *, - key: Optional[str] = None, - value: Optional[float] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, value: Optional[float] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword value: The filter value. :paramtype value: float """ - super(NumberGreaterThanOrEqualsAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberGreaterThanOrEquals' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberGreaterThanOrEquals" # type: str self.value = value @@ -2464,12 +2405,12 @@ class NumberInAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2478,30 +2419,24 @@ class NumberInAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[float]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[float]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[float]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[float]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[float] """ - super(NumberInAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberIn' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberIn" # type: str self.values = values @@ -2510,12 +2445,12 @@ class NumberInRangeAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2524,30 +2459,24 @@ class NumberInRangeAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[[float]]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[[float]]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[List[float]]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[List[float]]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[list[float]] """ - super(NumberInRangeAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberInRange' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberInRange" # type: str self.values = values @@ -2556,12 +2485,12 @@ class NumberLessThanAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2570,30 +2499,24 @@ class NumberLessThanAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "float"}, } - def __init__( - self, - *, - key: Optional[str] = None, - value: Optional[float] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, value: Optional[float] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword value: The filter value. :paramtype value: float """ - super(NumberLessThanAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberLessThan' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberLessThan" # type: str self.value = value @@ -2602,12 +2525,12 @@ class NumberLessThanOrEqualsAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2616,30 +2539,24 @@ class NumberLessThanOrEqualsAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "float"}, } - def __init__( - self, - *, - key: Optional[str] = None, - value: Optional[float] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, value: Optional[float] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword value: The filter value. :paramtype value: float """ - super(NumberLessThanOrEqualsAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberLessThanOrEquals' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberLessThanOrEquals" # type: str self.value = value @@ -2648,12 +2565,12 @@ class NumberNotInAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2662,30 +2579,24 @@ class NumberNotInAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[float]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[float]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[float]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[float]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[float] """ - super(NumberNotInAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberNotIn' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberNotIn" # type: str self.values = values @@ -2694,12 +2605,12 @@ class NumberNotInRangeAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -2708,34 +2619,28 @@ class NumberNotInRangeAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[[float]]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[[float]]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[List[float]]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[List[float]]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[list[float]] """ - super(NumberNotInRangeAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'NumberNotInRange' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "NumberNotInRange" # type: str self.values = values -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Represents an operation returned by the GetOperations request. :ivar name: Name of the operation. @@ -2748,25 +2653,25 @@ class Operation(msrest.serialization.Model): or not. :vartype is_data_action: bool :ivar properties: Properties of the operation. - :vartype properties: any + :vartype properties: JSON """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationInfo'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'properties': {'key': 'properties', 'type': 'object'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationInfo"}, + "origin": {"key": "origin", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "properties": {"key": "properties", "type": "object"}, } def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationInfo"] = None, + display: Optional["_models.OperationInfo"] = None, origin: Optional[str] = None, is_data_action: Optional[bool] = None, - properties: Optional[Any] = None, + properties: Optional[JSON] = None, **kwargs ): """ @@ -2780,9 +2685,9 @@ def __init__( action or not. :paramtype is_data_action: bool :keyword properties: Properties of the operation. - :paramtype properties: any + :paramtype properties: JSON """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin @@ -2790,7 +2695,7 @@ def __init__( self.properties = properties -class OperationInfo(msrest.serialization.Model): +class OperationInfo(_serialization.Model): """Information about an operation. :ivar provider: Name of the provider. @@ -2804,10 +2709,10 @@ class OperationInfo(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2829,14 +2734,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationsListResult(msrest.serialization.Model): +class OperationsListResult(_serialization.Model): """Result of the List Operations operation. :ivar value: A collection of operations. @@ -2844,24 +2749,19 @@ class OperationsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: A collection of operations. :paramtype value: list[~azure.mgmt.eventgrid.models.Operation] """ - super(OperationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Partner(msrest.serialization.Model): +class Partner(_serialization.Model): """Information about the partner. :ivar partner_registration_immutable_id: The immutableId of the corresponding partner @@ -2880,9 +2780,9 @@ class Partner(msrest.serialization.Model): """ _attribute_map = { - 'partner_registration_immutable_id': {'key': 'partnerRegistrationImmutableId', 'type': 'str'}, - 'partner_name': {'key': 'partnerName', 'type': 'str'}, - 'authorization_expiration_time_in_utc': {'key': 'authorizationExpirationTimeInUtc', 'type': 'iso-8601'}, + "partner_registration_immutable_id": {"key": "partnerRegistrationImmutableId", "type": "str"}, + "partner_name": {"key": "partnerName", "type": "str"}, + "authorization_expiration_time_in_utc": {"key": "authorizationExpirationTimeInUtc", "type": "iso-8601"}, } def __init__( @@ -2908,13 +2808,13 @@ def __init__( specified in PartnerConfiguration or 7 if this value is not specified. :paramtype authorization_expiration_time_in_utc: ~datetime.datetime """ - super(Partner, self).__init__(**kwargs) + super().__init__(**kwargs) self.partner_registration_immutable_id = partner_registration_immutable_id self.partner_name = partner_name self.authorization_expiration_time_in_utc = authorization_expiration_time_in_utc -class PartnerAuthorization(msrest.serialization.Model): +class PartnerAuthorization(_serialization.Model): """The partner authorization details. :ivar default_maximum_expiration_time_in_days: Time used to validate the authorization @@ -2926,15 +2826,15 @@ class PartnerAuthorization(msrest.serialization.Model): """ _attribute_map = { - 'default_maximum_expiration_time_in_days': {'key': 'defaultMaximumExpirationTimeInDays', 'type': 'int'}, - 'authorized_partners_list': {'key': 'authorizedPartnersList', 'type': '[Partner]'}, + "default_maximum_expiration_time_in_days": {"key": "defaultMaximumExpirationTimeInDays", "type": "int"}, + "authorized_partners_list": {"key": "authorizedPartnersList", "type": "[Partner]"}, } def __init__( self, *, default_maximum_expiration_time_in_days: Optional[int] = None, - authorized_partners_list: Optional[List["Partner"]] = None, + authorized_partners_list: Optional[List["_models.Partner"]] = None, **kwargs ): """ @@ -2945,7 +2845,7 @@ def __init__( :keyword authorized_partners_list: The list of authorized partners. :paramtype authorized_partners_list: list[~azure.mgmt.eventgrid.models.Partner] """ - super(PartnerAuthorization, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_maximum_expiration_time_in_days = default_maximum_expiration_time_in_days self.authorized_partners_list = authorized_partners_list @@ -2965,32 +2865,32 @@ class PartnerConfiguration(Resource): :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData :ivar location: Location of the resource. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar partner_authorization: The details of authorized partners. :vartype partner_authorization: ~azure.mgmt.eventgrid.models.PartnerAuthorization - :ivar provisioning_state: Provisioning state of the partner configuration. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the partner configuration. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.PartnerConfigurationProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'partner_authorization': {'key': 'properties.partnerAuthorization', 'type': 'PartnerAuthorization'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "partner_authorization": {"key": "properties.partnerAuthorization", "type": "PartnerAuthorization"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -2998,23 +2898,23 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - partner_authorization: Optional["PartnerAuthorization"] = None, - provisioning_state: Optional[Union[str, "PartnerConfigurationProvisioningState"]] = None, + partner_authorization: Optional["_models.PartnerAuthorization"] = None, + provisioning_state: Optional[Union[str, "_models.PartnerConfigurationProvisioningState"]] = None, **kwargs ): """ :keyword location: Location of the resource. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword partner_authorization: The details of authorized partners. :paramtype partner_authorization: ~azure.mgmt.eventgrid.models.PartnerAuthorization - :keyword provisioning_state: Provisioning state of the partner configuration. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :keyword provisioning_state: Provisioning state of the partner configuration. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.eventgrid.models.PartnerConfigurationProvisioningState """ - super(PartnerConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.location = location self.tags = tags @@ -3022,7 +2922,7 @@ def __init__( self.provisioning_state = provisioning_state -class PartnerConfigurationsListResult(msrest.serialization.Model): +class PartnerConfigurationsListResult(_serialization.Model): """Result of the List partner configurations operation. :ivar value: A collection of partner configurations. @@ -3032,16 +2932,12 @@ class PartnerConfigurationsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PartnerConfiguration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PartnerConfiguration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PartnerConfiguration"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PartnerConfiguration"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of partner configurations. @@ -3049,15 +2945,15 @@ def __init__( :keyword next_link: A link for the next page of partner configurations. :paramtype next_link: str """ - super(PartnerConfigurationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PartnerConfigurationUpdateParameters(msrest.serialization.Model): +class PartnerConfigurationUpdateParameters(_serialization.Model): """Properties of the partner configuration update. - :ivar tags: A set of tags. Tags of the partner configuration resource. + :ivar tags: Tags of the partner configuration resource. :vartype tags: dict[str, str] :ivar default_maximum_expiration_time_in_days: The default time used to validate the maximum expiration time for each authorized partners in days. Allowed values ar between 1 and 365 days. @@ -3065,8 +2961,11 @@ class PartnerConfigurationUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'default_maximum_expiration_time_in_days': {'key': 'properties.defaultMaximumExpirationTimeInDays', 'type': 'int'}, + "tags": {"key": "tags", "type": "{str}"}, + "default_maximum_expiration_time_in_days": { + "key": "properties.defaultMaximumExpirationTimeInDays", + "type": "int", + }, } def __init__( @@ -3077,18 +2976,18 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Tags of the partner configuration resource. + :keyword tags: Tags of the partner configuration resource. :paramtype tags: dict[str, str] :keyword default_maximum_expiration_time_in_days: The default time used to validate the maximum expiration time for each authorized partners in days. Allowed values ar between 1 and 365 days. :paramtype default_maximum_expiration_time_in_days: int """ - super(PartnerConfigurationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.default_maximum_expiration_time_in_days = default_maximum_expiration_time_in_days -class PartnerDetails(msrest.serialization.Model): +class PartnerDetails(_serialization.Model): """Information about the partner. :ivar description: This is short description about the partner. The length of this description @@ -3104,9 +3003,9 @@ class PartnerDetails(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'long_description': {'key': 'longDescription', 'type': 'str'}, - 'setup_uri': {'key': 'setupUri', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "long_description": {"key": "longDescription", "type": "str"}, + "setup_uri": {"key": "setupUri", "type": "str"}, } def __init__( @@ -3129,13 +3028,13 @@ def __init__( integration on an event source. :paramtype setup_uri: str """ - super(PartnerDetails, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.long_description = long_description self.setup_uri = setup_uri -class PartnerNamespace(TrackedResource): +class PartnerNamespace(TrackedResource): # pylint: disable=too-many-instance-attributes """EventGrid Partner Namespace. Variables are only populated by the server, and will be ignored when sending a request. @@ -3148,17 +3047,17 @@ class PartnerNamespace(TrackedResource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar system_data: The system metadata relating to Partner Namespace resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData :ivar private_endpoint_connections: :vartype private_endpoint_connections: list[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] - :ivar provisioning_state: Provisioning state of the partner namespace. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the partner namespace. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.PartnerNamespaceProvisioningState :ivar partner_registration_fully_qualified_id: The fully qualified ARM Id of the partner @@ -3172,7 +3071,7 @@ class PartnerNamespace(TrackedResource): default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :ivar inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -3184,38 +3083,44 @@ class PartnerNamespace(TrackedResource): :ivar partner_topic_routing_mode: This determines if events published to this partner namespace should use the source attribute in the event payload or use the channel name in the header when matching to the partner topic. If none is - specified, source attribute routing will be used to match the partner topic. Possible values - include: "SourceEventAttribute", "ChannelNameHeader". Default value: "SourceEventAttribute". + specified, source attribute routing will be used to match the partner topic. Known values are: + "SourceEventAttribute" and "ChannelNameHeader". :vartype partner_topic_routing_mode: str or ~azure.mgmt.eventgrid.models.PartnerTopicRoutingMode """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'endpoint': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "endpoint": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'partner_registration_fully_qualified_id': {'key': 'properties.partnerRegistrationFullyQualifiedId', 'type': 'str'}, - 'endpoint': {'key': 'properties.endpoint', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'inbound_ip_rules': {'key': 'properties.inboundIpRules', 'type': '[InboundIpRule]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'partner_topic_routing_mode': {'key': 'properties.partnerTopicRoutingMode', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "partner_registration_fully_qualified_id": { + "key": "properties.partnerRegistrationFullyQualifiedId", + "type": "str", + }, + "endpoint": {"key": "properties.endpoint", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "inbound_ip_rules": {"key": "properties.inboundIpRules", "type": "[InboundIpRule]"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "partner_topic_routing_mode": {"key": "properties.partnerTopicRoutingMode", "type": "str"}, } def __init__( @@ -3224,16 +3129,16 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, partner_registration_fully_qualified_id: Optional[str] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - inbound_ip_rules: Optional[List["InboundIpRule"]] = None, - disable_local_auth: Optional[bool] = False, - partner_topic_routing_mode: Optional[Union[str, "PartnerTopicRoutingMode"]] = "SourceEventAttribute", + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + inbound_ip_rules: Optional[List["_models.InboundIpRule"]] = None, + disable_local_auth: bool = False, + partner_topic_routing_mode: Union[str, "_models.PartnerTopicRoutingMode"] = "SourceEventAttribute", **kwargs ): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword partner_registration_fully_qualified_id: The fully qualified ARM Id of the partner registration that should be associated with this partner namespace. This takes the following @@ -3244,7 +3149,7 @@ def __init__( default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :keyword inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -3256,12 +3161,12 @@ def __init__( :keyword partner_topic_routing_mode: This determines if events published to this partner namespace should use the source attribute in the event payload or use the channel name in the header when matching to the partner topic. If none is - specified, source attribute routing will be used to match the partner topic. Possible values - include: "SourceEventAttribute", "ChannelNameHeader". Default value: "SourceEventAttribute". + specified, source attribute routing will be used to match the partner topic. Known values are: + "SourceEventAttribute" and "ChannelNameHeader". :paramtype partner_topic_routing_mode: str or ~azure.mgmt.eventgrid.models.PartnerTopicRoutingMode """ - super(PartnerNamespace, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.system_data = None self.private_endpoint_connections = None self.provisioning_state = None @@ -3273,38 +3178,33 @@ def __init__( self.partner_topic_routing_mode = partner_topic_routing_mode -class PartnerNamespaceRegenerateKeyRequest(msrest.serialization.Model): +class PartnerNamespaceRegenerateKeyRequest(_serialization.Model): """PartnerNamespace regenerate shared access key request. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. Key name to regenerate (key1 or key2). + :ivar key_name: Key name to regenerate (key1 or key2). Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. Key name to regenerate (key1 or key2). + :keyword key_name: Key name to regenerate (key1 or key2). Required. :paramtype key_name: str """ - super(PartnerNamespaceRegenerateKeyRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class PartnerNamespaceSharedAccessKeys(msrest.serialization.Model): +class PartnerNamespaceSharedAccessKeys(_serialization.Model): """Shared access keys of the partner namespace. :ivar key1: Shared access key1 for the partner namespace. @@ -3314,29 +3214,23 @@ class PartnerNamespaceSharedAccessKeys(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'str'}, - 'key2': {'key': 'key2', 'type': 'str'}, + "key1": {"key": "key1", "type": "str"}, + "key2": {"key": "key2", "type": "str"}, } - def __init__( - self, - *, - key1: Optional[str] = None, - key2: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[str] = None, key2: Optional[str] = None, **kwargs): """ :keyword key1: Shared access key1 for the partner namespace. :paramtype key1: str :keyword key2: Shared access key2 for the partner namespace. :paramtype key2: str """ - super(PartnerNamespaceSharedAccessKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class PartnerNamespacesListResult(msrest.serialization.Model): +class PartnerNamespacesListResult(_serialization.Model): """Result of the List Partner Namespaces operation. :ivar value: A collection of partner namespaces. @@ -3346,16 +3240,12 @@ class PartnerNamespacesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PartnerNamespace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PartnerNamespace]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PartnerNamespace"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PartnerNamespace"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of partner namespaces. @@ -3363,21 +3253,21 @@ def __init__( :keyword next_link: A link for the next page of partner namespaces. :paramtype next_link: str """ - super(PartnerNamespacesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PartnerNamespaceUpdateParameters(msrest.serialization.Model): +class PartnerNamespaceUpdateParameters(_serialization.Model): """Properties of the Partner Namespace update. - :ivar tags: A set of tags. Tags of the Partner Namespace. + :ivar tags: Tags of the Partner Namespace. :vartype tags: dict[str, str] :ivar public_network_access: This determines if traffic is allowed over public network. By default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :ivar inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -3389,29 +3279,29 @@ class PartnerNamespaceUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'inbound_ip_rules': {'key': 'properties.inboundIpRules', 'type': '[InboundIpRule]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, + "tags": {"key": "tags", "type": "{str}"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "inbound_ip_rules": {"key": "properties.inboundIpRules", "type": "[InboundIpRule]"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - inbound_ip_rules: Optional[List["InboundIpRule"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + inbound_ip_rules: Optional[List["_models.InboundIpRule"]] = None, disable_local_auth: Optional[bool] = None, **kwargs ): """ - :keyword tags: A set of tags. Tags of the Partner Namespace. + :keyword tags: Tags of the Partner Namespace. :paramtype tags: dict[str, str] :keyword public_network_access: This determines if traffic is allowed over public network. By default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :keyword inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -3421,7 +3311,7 @@ def __init__( if user is allowed to publish to the partner namespace. :paramtype disable_local_auth: bool """ - super(PartnerNamespaceUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.public_network_access = public_network_access self.inbound_ip_rules = inbound_ip_rules @@ -3441,14 +3331,14 @@ class PartnerRegistration(TrackedResource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar system_data: The system metadata relating to Partner Registration resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData - :ivar provisioning_state: Provisioning state of the partner registration. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the partner registration. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.PartnerRegistrationProvisioningState :ivar partner_registration_immutable_id: The immutableId of the corresponding partner @@ -3459,23 +3349,23 @@ class PartnerRegistration(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'partner_registration_immutable_id': {'key': 'properties.partnerRegistrationImmutableId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "partner_registration_immutable_id": {"key": "properties.partnerRegistrationImmutableId", "type": "str"}, } def __init__( @@ -3487,9 +3377,9 @@ def __init__( **kwargs ): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword partner_registration_immutable_id: The immutableId of the corresponding partner registration. @@ -3497,13 +3387,13 @@ def __init__( version. :paramtype partner_registration_immutable_id: str """ - super(PartnerRegistration, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.system_data = None self.provisioning_state = None self.partner_registration_immutable_id = partner_registration_immutable_id -class PartnerRegistrationsListResult(msrest.serialization.Model): +class PartnerRegistrationsListResult(_serialization.Model): """Result of the List Partner Registrations operation. :ivar value: A collection of partner registrations. @@ -3513,16 +3403,12 @@ class PartnerRegistrationsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PartnerRegistration]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PartnerRegistration]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PartnerRegistration"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PartnerRegistration"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of partner registrations. @@ -3530,37 +3416,32 @@ def __init__( :keyword next_link: A link for the next page of partner registrations. :paramtype next_link: str """ - super(PartnerRegistrationsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PartnerRegistrationUpdateParameters(msrest.serialization.Model): +class PartnerRegistrationUpdateParameters(_serialization.Model): """Properties of the Partner Registration update. - :ivar tags: A set of tags. Tags of the partner registration resource. + :ivar tags: Tags of the partner registration resource. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Tags of the partner registration resource. + :keyword tags: Tags of the partner registration resource. :paramtype tags: dict[str, str] """ - super(PartnerRegistrationUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class PartnerTopic(TrackedResource): +class PartnerTopic(TrackedResource): # pylint: disable=too-many-instance-attributes """Event Grid Partner Topic. Variables are only populated by the server, and will be ignored when sending a request. @@ -3573,9 +3454,9 @@ class PartnerTopic(TrackedResource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar system_data: The system metadata relating to Partner Topic resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData @@ -3593,12 +3474,12 @@ class PartnerTopic(TrackedResource): expires while the partner topic is still never activated, the partner topic and corresponding event channel are deleted. :vartype expiration_time_if_not_activated_utc: ~datetime.datetime - :ivar provisioning_state: Provisioning state of the partner topic. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed", + :ivar provisioning_state: Provisioning state of the partner topic. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed", and "IdleDueToMirroredChannelResourceDeletion". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.PartnerTopicProvisioningState - :ivar activation_state: Activation state of the partner topic. Possible values include: - "NeverActivated", "Activated", "Deactivated". + :ivar activation_state: Activation state of the partner topic. Known values are: + "NeverActivated", "Activated", and "Deactivated". :vartype activation_state: str or ~azure.mgmt.eventgrid.models.PartnerTopicActivationState :ivar partner_topic_friendly_description: Friendly description about the topic. This can be set by the publisher/partner to show custom description for the customer partner topic. @@ -3611,30 +3492,33 @@ class PartnerTopic(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, - 'partner_registration_immutable_id': {'key': 'properties.partnerRegistrationImmutableId', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'event_type_info': {'key': 'properties.eventTypeInfo', 'type': 'EventTypeInfo'}, - 'expiration_time_if_not_activated_utc': {'key': 'properties.expirationTimeIfNotActivatedUtc', 'type': 'iso-8601'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'activation_state': {'key': 'properties.activationState', 'type': 'str'}, - 'partner_topic_friendly_description': {'key': 'properties.partnerTopicFriendlyDescription', 'type': 'str'}, - 'message_for_activation': {'key': 'properties.messageForActivation', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, + "partner_registration_immutable_id": {"key": "properties.partnerRegistrationImmutableId", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "event_type_info": {"key": "properties.eventTypeInfo", "type": "EventTypeInfo"}, + "expiration_time_if_not_activated_utc": { + "key": "properties.expirationTimeIfNotActivatedUtc", + "type": "iso-8601", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "activation_state": {"key": "properties.activationState", "type": "str"}, + "partner_topic_friendly_description": {"key": "properties.partnerTopicFriendlyDescription", "type": "str"}, + "message_for_activation": {"key": "properties.messageForActivation", "type": "str"}, } def __init__( @@ -3642,20 +3526,20 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, + identity: Optional["_models.IdentityInfo"] = None, partner_registration_immutable_id: Optional[str] = None, source: Optional[str] = None, - event_type_info: Optional["EventTypeInfo"] = None, + event_type_info: Optional["_models.EventTypeInfo"] = None, expiration_time_if_not_activated_utc: Optional[datetime.datetime] = None, - activation_state: Optional[Union[str, "PartnerTopicActivationState"]] = None, + activation_state: Optional[Union[str, "_models.PartnerTopicActivationState"]] = None, partner_topic_friendly_description: Optional[str] = None, message_for_activation: Optional[str] = None, **kwargs ): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword identity: Identity information for the Partner Topic resource. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -3671,8 +3555,8 @@ def __init__( timer expires while the partner topic is still never activated, the partner topic and corresponding event channel are deleted. :paramtype expiration_time_if_not_activated_utc: ~datetime.datetime - :keyword activation_state: Activation state of the partner topic. Possible values include: - "NeverActivated", "Activated", "Deactivated". + :keyword activation_state: Activation state of the partner topic. Known values are: + "NeverActivated", "Activated", and "Deactivated". :paramtype activation_state: str or ~azure.mgmt.eventgrid.models.PartnerTopicActivationState :keyword partner_topic_friendly_description: Friendly description about the topic. This can be set by the publisher/partner to show custom description for the customer partner topic. @@ -3683,7 +3567,7 @@ def __init__( approval process by the subscriber. :paramtype message_for_activation: str """ - super(PartnerTopic, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.system_data = None self.identity = identity self.partner_registration_immutable_id = partner_registration_immutable_id @@ -3696,7 +3580,7 @@ def __init__( self.message_for_activation = message_for_activation -class PartnerTopicInfo(msrest.serialization.Model): +class PartnerTopicInfo(_serialization.Model): """Properties of the corresponding partner topic of a Channel. :ivar azure_subscription_id: Azure subscription ID of the subscriber. The partner topic @@ -3722,11 +3606,11 @@ class PartnerTopicInfo(msrest.serialization.Model): """ _attribute_map = { - 'azure_subscription_id': {'key': 'azureSubscriptionId', 'type': 'str'}, - 'resource_group_name': {'key': 'resourceGroupName', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'event_type_info': {'key': 'eventTypeInfo', 'type': 'EventTypeInfo'}, - 'source': {'key': 'source', 'type': 'str'}, + "azure_subscription_id": {"key": "azureSubscriptionId", "type": "str"}, + "resource_group_name": {"key": "resourceGroupName", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "event_type_info": {"key": "eventTypeInfo", "type": "EventTypeInfo"}, + "source": {"key": "source", "type": "str"}, } def __init__( @@ -3735,7 +3619,7 @@ def __init__( azure_subscription_id: Optional[str] = None, resource_group_name: Optional[str] = None, name: Optional[str] = None, - event_type_info: Optional["EventTypeInfo"] = None, + event_type_info: Optional["_models.EventTypeInfo"] = None, source: Optional[str] = None, **kwargs ): @@ -3761,7 +3645,7 @@ def __init__( created partner topic. :paramtype source: str """ - super(PartnerTopicInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.azure_subscription_id = azure_subscription_id self.resource_group_name = resource_group_name self.name = name @@ -3769,7 +3653,7 @@ def __init__( self.source = source -class PartnerTopicsListResult(msrest.serialization.Model): +class PartnerTopicsListResult(_serialization.Model): """Result of the List Partner Topics operation. :ivar value: A collection of partner topics. @@ -3779,16 +3663,12 @@ class PartnerTopicsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PartnerTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PartnerTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PartnerTopic"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PartnerTopic"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of partner topics. @@ -3796,44 +3676,40 @@ def __init__( :keyword next_link: A link for the next page of partner topics. :paramtype next_link: str """ - super(PartnerTopicsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PartnerTopicUpdateParameters(msrest.serialization.Model): +class PartnerTopicUpdateParameters(_serialization.Model): """Properties of the Partner Topic update. - :ivar tags: A set of tags. Tags of the Partner Topic resource. + :ivar tags: Tags of the Partner Topic resource. :vartype tags: dict[str, str] :ivar identity: Identity information for the Partner Topic resource. :vartype identity: ~azure.mgmt.eventgrid.models.IdentityInfo """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, identity: Optional["_models.IdentityInfo"] = None, **kwargs ): """ - :keyword tags: A set of tags. Tags of the Partner Topic resource. + :keyword tags: Tags of the Partner Topic resource. :paramtype tags: dict[str, str] :keyword identity: Identity information for the Partner Topic resource. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo """ - super(PartnerTopicUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity -class PartnerUpdateTopicInfo(msrest.serialization.Model): +class PartnerUpdateTopicInfo(_serialization.Model): """Update properties for the corresponding partner topic of a channel. :ivar event_type_info: Event type info for the partner topic. @@ -3841,24 +3717,19 @@ class PartnerUpdateTopicInfo(msrest.serialization.Model): """ _attribute_map = { - 'event_type_info': {'key': 'eventTypeInfo', 'type': 'EventTypeInfo'}, + "event_type_info": {"key": "eventTypeInfo", "type": "EventTypeInfo"}, } - def __init__( - self, - *, - event_type_info: Optional["EventTypeInfo"] = None, - **kwargs - ): + def __init__(self, *, event_type_info: Optional["_models.EventTypeInfo"] = None, **kwargs): """ :keyword event_type_info: Event type info for the partner topic. :paramtype event_type_info: ~azure.mgmt.eventgrid.models.EventTypeInfo """ - super(PartnerUpdateTopicInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.event_type_info = event_type_info -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """PrivateEndpoint information. :ivar id: The ARM identifier for Private Endpoint. @@ -3866,20 +3737,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: The ARM identifier for Private Endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -3900,34 +3766,37 @@ class PrivateEndpointConnection(Resource): :vartype group_ids: list[str] :ivar private_link_service_connection_state: Details about the state of the connection. :vartype private_link_service_connection_state: ~azure.mgmt.eventgrid.models.ConnectionState - :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the Private Endpoint Connection. Known values + are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.ResourceProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'group_ids': {'key': 'properties.groupIds', 'type': '[str]'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'ConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "group_ids": {"key": "properties.groupIds", "type": "[str]"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "ConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, group_ids: Optional[List[str]] = None, - private_link_service_connection_state: Optional["ConnectionState"] = None, - provisioning_state: Optional[Union[str, "ResourceProvisioningState"]] = None, + private_link_service_connection_state: Optional["_models.ConnectionState"] = None, + provisioning_state: Optional[Union[str, "_models.ResourceProvisioningState"]] = None, **kwargs ): """ @@ -3937,18 +3806,18 @@ def __init__( :paramtype group_ids: list[str] :keyword private_link_service_connection_state: Details about the state of the connection. :paramtype private_link_service_connection_state: ~azure.mgmt.eventgrid.models.ConnectionState - :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Possible - values include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :keyword provisioning_state: Provisioning state of the Private Endpoint Connection. Known + values are: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.eventgrid.models.ResourceProvisioningState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.group_ids = group_ids self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = provisioning_state -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """Result of the list of all private endpoint connections operation. :ivar value: A collection of private endpoint connection resources. @@ -3958,14 +3827,14 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -3975,12 +3844,12 @@ def __init__( :keyword next_link: A link for the next page of private endpoint connection resources. :paramtype next_link: str """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkResource(msrest.serialization.Model): +class PrivateLinkResource(_serialization.Model): """Information of the private link resource. :ivar id: Fully qualified identifier of the resource. @@ -4000,19 +3869,19 @@ class PrivateLinkResource(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin name: Optional[str] = None, type: Optional[str] = None, group_id: Optional[str] = None, @@ -4037,7 +3906,7 @@ def __init__( :keyword required_zone_names: :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.name = name self.type = type @@ -4047,7 +3916,7 @@ def __init__( self.required_zone_names = required_zone_names -class PrivateLinkResourcesListResult(msrest.serialization.Model): +class PrivateLinkResourcesListResult(_serialization.Model): """Result of the List private link resources operation. :ivar value: A collection of private link resources. @@ -4057,16 +3926,12 @@ class PrivateLinkResourcesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of private link resources. @@ -4074,12 +3939,12 @@ def __init__( :keyword next_link: A link for the next page of private link resources. :paramtype next_link: str """ - super(PrivateLinkResourcesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class RetryPolicy(msrest.serialization.Model): +class RetryPolicy(_serialization.Model): """Information about the retry policy for an event subscription. :ivar max_delivery_attempts: Maximum number of delivery retry attempts for events. @@ -4089,24 +3954,18 @@ class RetryPolicy(msrest.serialization.Model): """ _attribute_map = { - 'max_delivery_attempts': {'key': 'maxDeliveryAttempts', 'type': 'int'}, - 'event_time_to_live_in_minutes': {'key': 'eventTimeToLiveInMinutes', 'type': 'int'}, + "max_delivery_attempts": {"key": "maxDeliveryAttempts", "type": "int"}, + "event_time_to_live_in_minutes": {"key": "eventTimeToLiveInMinutes", "type": "int"}, } - def __init__( - self, - *, - max_delivery_attempts: Optional[int] = 30, - event_time_to_live_in_minutes: Optional[int] = 1440, - **kwargs - ): + def __init__(self, *, max_delivery_attempts: int = 30, event_time_to_live_in_minutes: int = 1440, **kwargs): """ :keyword max_delivery_attempts: Maximum number of delivery retry attempts for events. :paramtype max_delivery_attempts: int :keyword event_time_to_live_in_minutes: Time To Live (in minutes) for events. :paramtype event_time_to_live_in_minutes: int """ - super(RetryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.max_delivery_attempts = max_delivery_attempts self.event_time_to_live_in_minutes = event_time_to_live_in_minutes @@ -4116,9 +3975,9 @@ class ServiceBusQueueEventSubscriptionDestination(EventSubscriptionDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar resource_id: The Azure Resource Id that represents the endpoint of the Service Bus destination of an event subscription. @@ -4129,20 +3988,23 @@ class ServiceBusQueueEventSubscriptionDestination(EventSubscriptionDestination): """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'delivery_attribute_mappings': {'key': 'properties.deliveryAttributeMappings', 'type': '[DeliveryAttributeMapping]'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "delivery_attribute_mappings": { + "key": "properties.deliveryAttributeMappings", + "type": "[DeliveryAttributeMapping]", + }, } def __init__( self, *, resource_id: Optional[str] = None, - delivery_attribute_mappings: Optional[List["DeliveryAttributeMapping"]] = None, + delivery_attribute_mappings: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs ): """ @@ -4153,8 +4015,8 @@ def __init__( :paramtype delivery_attribute_mappings: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(ServiceBusQueueEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'ServiceBusQueue' # type: str + super().__init__(**kwargs) + self.endpoint_type = "ServiceBusQueue" # type: str self.resource_id = resource_id self.delivery_attribute_mappings = delivery_attribute_mappings @@ -4164,9 +4026,9 @@ class ServiceBusTopicEventSubscriptionDestination(EventSubscriptionDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar resource_id: The Azure Resource Id that represents the endpoint of the Service Bus Topic destination of an event subscription. @@ -4177,20 +4039,23 @@ class ServiceBusTopicEventSubscriptionDestination(EventSubscriptionDestination): """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'delivery_attribute_mappings': {'key': 'properties.deliveryAttributeMappings', 'type': '[DeliveryAttributeMapping]'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "delivery_attribute_mappings": { + "key": "properties.deliveryAttributeMappings", + "type": "[DeliveryAttributeMapping]", + }, } def __init__( self, *, resource_id: Optional[str] = None, - delivery_attribute_mappings: Optional[List["DeliveryAttributeMapping"]] = None, + delivery_attribute_mappings: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs ): """ @@ -4201,8 +4066,8 @@ def __init__( :paramtype delivery_attribute_mappings: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(ServiceBusTopicEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'ServiceBusTopic' # type: str + super().__init__(**kwargs) + self.endpoint_type = "ServiceBusTopic" # type: str self.resource_id = resource_id self.delivery_attribute_mappings = delivery_attribute_mappings @@ -4214,8 +4079,8 @@ class StaticDeliveryAttributeMapping(DeliveryAttributeMapping): :ivar name: Name of the delivery attribute or header. :vartype name: str - :ivar type: Required. Type of the delivery attribute or header name.Constant filled by server. - Possible values include: "Static", "Dynamic". + :ivar type: Type of the delivery attribute or header name. Required. Known values are: "Static" + and "Dynamic". :vartype type: str or ~azure.mgmt.eventgrid.models.DeliveryAttributeMappingType :ivar value: Value of the delivery attribute. :vartype value: str @@ -4224,24 +4089,17 @@ class StaticDeliveryAttributeMapping(DeliveryAttributeMapping): """ _validation = { - 'type': {'required': True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'value': {'key': 'properties.value', 'type': 'str'}, - 'is_secret': {'key': 'properties.isSecret', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "value": {"key": "properties.value", "type": "str"}, + "is_secret": {"key": "properties.isSecret", "type": "bool"}, } - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - is_secret: Optional[bool] = False, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, is_secret: bool = False, **kwargs): """ :keyword name: Name of the delivery attribute or header. :paramtype name: str @@ -4250,8 +4108,8 @@ def __init__( :keyword is_secret: Boolean flag to tell if the attribute contains sensitive information . :paramtype is_secret: bool """ - super(StaticDeliveryAttributeMapping, self).__init__(name=name, **kwargs) - self.type = 'Static' # type: str + super().__init__(name=name, **kwargs) + self.type = "Static" # type: str self.value = value self.is_secret = is_secret @@ -4261,8 +4119,8 @@ class StorageBlobDeadLetterDestination(DeadLetterDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the dead letter destination.Constant - filled by server. Possible values include: "StorageBlob". + :ivar endpoint_type: Type of the endpoint for the dead letter destination. Required. + "StorageBlob" :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.DeadLetterEndPointType :ivar resource_id: The Azure Resource ID of the storage account that is the destination of the deadletter events. @@ -4273,22 +4131,16 @@ class StorageBlobDeadLetterDestination(DeadLetterDestination): """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'blob_container_name': {'key': 'properties.blobContainerName', 'type': 'str'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "blob_container_name": {"key": "properties.blobContainerName", "type": "str"}, } - def __init__( - self, - *, - resource_id: Optional[str] = None, - blob_container_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resource_id: Optional[str] = None, blob_container_name: Optional[str] = None, **kwargs): """ :keyword resource_id: The Azure Resource ID of the storage account that is the destination of the deadletter events. @@ -4297,8 +4149,8 @@ def __init__( the deadletter events. :paramtype blob_container_name: str """ - super(StorageBlobDeadLetterDestination, self).__init__(**kwargs) - self.endpoint_type = 'StorageBlob' # type: str + super().__init__(**kwargs) + self.endpoint_type = "StorageBlob" # type: str self.resource_id = resource_id self.blob_container_name = blob_container_name @@ -4308,9 +4160,9 @@ class StorageQueueEventSubscriptionDestination(EventSubscriptionDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar resource_id: The Azure Resource ID of the storage account that contains the queue that is the destination of an event subscription. @@ -4319,18 +4171,18 @@ class StorageQueueEventSubscriptionDestination(EventSubscriptionDestination): of an event subscription. :vartype queue_name: str :ivar queue_message_time_to_live_in_seconds: Storage queue message time to live in seconds. - :vartype queue_message_time_to_live_in_seconds: long + :vartype queue_message_time_to_live_in_seconds: int """ _validation = { - 'endpoint_type': {'required': True}, + "endpoint_type": {"required": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'queue_name': {'key': 'properties.queueName', 'type': 'str'}, - 'queue_message_time_to_live_in_seconds': {'key': 'properties.queueMessageTimeToLiveInSeconds', 'type': 'long'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "resource_id": {"key": "properties.resourceId", "type": "str"}, + "queue_name": {"key": "properties.queueName", "type": "str"}, + "queue_message_time_to_live_in_seconds": {"key": "properties.queueMessageTimeToLiveInSeconds", "type": "int"}, } def __init__( @@ -4349,10 +4201,10 @@ def __init__( destination of an event subscription. :paramtype queue_name: str :keyword queue_message_time_to_live_in_seconds: Storage queue message time to live in seconds. - :paramtype queue_message_time_to_live_in_seconds: long + :paramtype queue_message_time_to_live_in_seconds: int """ - super(StorageQueueEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'StorageQueue' # type: str + super().__init__(**kwargs) + self.endpoint_type = "StorageQueue" # type: str self.resource_id = resource_id self.queue_name = queue_name self.queue_message_time_to_live_in_seconds = queue_message_time_to_live_in_seconds @@ -4363,12 +4215,12 @@ class StringBeginsWithAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4377,30 +4229,24 @@ class StringBeginsWithAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringBeginsWithAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringBeginsWith' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringBeginsWith" # type: str self.values = values @@ -4409,12 +4255,12 @@ class StringContainsAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4423,30 +4269,24 @@ class StringContainsAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringContainsAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringContains' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringContains" # type: str self.values = values @@ -4455,12 +4295,12 @@ class StringEndsWithAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4469,30 +4309,24 @@ class StringEndsWithAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringEndsWithAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringEndsWith' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringEndsWith" # type: str self.values = values @@ -4501,12 +4335,12 @@ class StringInAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4515,30 +4349,24 @@ class StringInAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringInAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringIn' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringIn" # type: str self.values = values @@ -4547,12 +4375,12 @@ class StringNotBeginsWithAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4561,30 +4389,24 @@ class StringNotBeginsWithAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringNotBeginsWithAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringNotBeginsWith' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringNotBeginsWith" # type: str self.values = values @@ -4593,12 +4415,12 @@ class StringNotContainsAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4607,30 +4429,24 @@ class StringNotContainsAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringNotContainsAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringNotContains' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringNotContains" # type: str self.values = values @@ -4639,12 +4455,12 @@ class StringNotEndsWithAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4653,30 +4469,24 @@ class StringNotEndsWithAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringNotEndsWithAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringNotEndsWith' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringNotEndsWith" # type: str self.values = values @@ -4685,12 +4495,12 @@ class StringNotInAdvancedFilter(AdvancedFilter): All required parameters must be populated in order to send to Azure. - :ivar operator_type: Required. The operator type used for filtering, e.g., NumberIn, - StringContains, BoolEquals and others.Constant filled by server. Possible values include: - "NumberIn", "NumberNotIn", "NumberLessThan", "NumberGreaterThan", "NumberLessThanOrEquals", - "NumberGreaterThanOrEquals", "BoolEquals", "StringIn", "StringNotIn", "StringBeginsWith", - "StringEndsWith", "StringContains", "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", - "StringNotEndsWith", "StringNotContains", "IsNullOrUndefined", "IsNotNull". + :ivar operator_type: The operator type used for filtering, e.g., NumberIn, StringContains, + BoolEquals and others. Required. Known values are: "NumberIn", "NumberNotIn", "NumberLessThan", + "NumberGreaterThan", "NumberLessThanOrEquals", "NumberGreaterThanOrEquals", "BoolEquals", + "StringIn", "StringNotIn", "StringBeginsWith", "StringEndsWith", "StringContains", + "NumberInRange", "NumberNotInRange", "StringNotBeginsWith", "StringNotEndsWith", + "StringNotContains", "IsNullOrUndefined", and "IsNotNull". :vartype operator_type: str or ~azure.mgmt.eventgrid.models.AdvancedFilterOperatorType :ivar key: The field/property in the event based on which you want to filter. :vartype key: str @@ -4699,89 +4509,83 @@ class StringNotInAdvancedFilter(AdvancedFilter): """ _validation = { - 'operator_type': {'required': True}, + "operator_type": {"required": True}, } _attribute_map = { - 'operator_type': {'key': 'operatorType', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + "operator_type": {"key": "operatorType", "type": "str"}, + "key": {"key": "key", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, } - def __init__( - self, - *, - key: Optional[str] = None, - values: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, key: Optional[str] = None, values: Optional[List[str]] = None, **kwargs): """ :keyword key: The field/property in the event based on which you want to filter. :paramtype key: str :keyword values: The set of filter values. :paramtype values: list[str] """ - super(StringNotInAdvancedFilter, self).__init__(key=key, **kwargs) - self.operator_type = 'StringNotIn' # type: str + super().__init__(key=key, **kwargs) + self.operator_type = "StringNotIn" # type: str self.values = values -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.eventgrid.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.eventgrid.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.eventgrid.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.eventgrid.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4790,7 +4594,7 @@ def __init__( self.last_modified_at = last_modified_at -class SystemTopic(TrackedResource): +class SystemTopic(TrackedResource): # pylint: disable=too-many-instance-attributes """EventGrid System Topic. Variables are only populated by the server, and will be ignored when sending a request. @@ -4803,16 +4607,16 @@ class SystemTopic(TrackedResource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar identity: Identity information for the resource. :vartype identity: ~azure.mgmt.eventgrid.models.IdentityInfo :ivar system_data: The system metadata relating to System Topic resource. :vartype system_data: ~azure.mgmt.eventgrid.models.SystemData - :ivar provisioning_state: Provisioning state of the system topic. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the system topic. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.ResourceProvisioningState :ivar source: Source for the system topic. :vartype source: str @@ -4823,27 +4627,27 @@ class SystemTopic(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'metric_resource_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "metric_resource_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'topic_type': {'key': 'properties.topicType', 'type': 'str'}, - 'metric_resource_id': {'key': 'properties.metricResourceId', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "topic_type": {"key": "properties.topicType", "type": "str"}, + "metric_resource_id": {"key": "properties.metricResourceId", "type": "str"}, } def __init__( @@ -4851,15 +4655,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, + identity: Optional["_models.IdentityInfo"] = None, source: Optional[str] = None, topic_type: Optional[str] = None, **kwargs ): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword identity: Identity information for the resource. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -4868,7 +4672,7 @@ def __init__( :keyword topic_type: TopicType for the system topic. :paramtype topic_type: str """ - super(SystemTopic, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.identity = identity self.system_data = None self.provisioning_state = None @@ -4877,7 +4681,7 @@ def __init__( self.metric_resource_id = None -class SystemTopicsListResult(msrest.serialization.Model): +class SystemTopicsListResult(_serialization.Model): """Result of the List System topics operation. :ivar value: A collection of system Topics. @@ -4887,16 +4691,12 @@ class SystemTopicsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SystemTopic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SystemTopic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["SystemTopic"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SystemTopic"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of system Topics. @@ -4904,44 +4704,40 @@ def __init__( :keyword next_link: A link for the next page of topics. :paramtype next_link: str """ - super(SystemTopicsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SystemTopicUpdateParameters(msrest.serialization.Model): +class SystemTopicUpdateParameters(_serialization.Model): """Properties of the System Topic update. - :ivar tags: A set of tags. Tags of the system topic. + :ivar tags: Tags of the system topic. :vartype tags: dict[str, str] :ivar identity: Resource identity information. :vartype identity: ~azure.mgmt.eventgrid.models.IdentityInfo """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, } def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, - **kwargs + self, *, tags: Optional[Dict[str, str]] = None, identity: Optional["_models.IdentityInfo"] = None, **kwargs ): """ - :keyword tags: A set of tags. Tags of the system topic. + :keyword tags: Tags of the system topic. :paramtype tags: dict[str, str] :keyword identity: Resource identity information. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo """ - super(SystemTopicUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity -class Topic(TrackedResource): +class Topic(TrackedResource): # pylint: disable=too-many-instance-attributes """EventGrid Topic. Variables are only populated by the server, and will be ignored when sending a request. @@ -4954,9 +4750,9 @@ class Topic(TrackedResource): :vartype name: str :ivar type: Type of the resource. :vartype type: str - :ivar location: Required. Location of the resource. + :ivar location: Location of the resource. Required. :vartype location: str - :ivar tags: A set of tags. Tags of the resource. + :ivar tags: Tags of the resource. :vartype tags: dict[str, str] :ivar identity: Identity information for the resource. :vartype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -4965,13 +4761,13 @@ class Topic(TrackedResource): :ivar private_endpoint_connections: :vartype private_endpoint_connections: list[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] - :ivar provisioning_state: Provisioning state of the topic. Possible values include: "Creating", - "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the topic. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.TopicProvisioningState :ivar endpoint: Endpoint for the topic. :vartype endpoint: str :ivar input_schema: This determines the format that Event Grid should expect for incoming - events published to the topic. Possible values include: "EventGridSchema", "CustomEventSchema", + events published to the topic. Known values are: "EventGridSchema", "CustomEventSchema", and "CloudEventSchemaV1_0". :vartype input_schema: str or ~azure.mgmt.eventgrid.models.InputSchema :ivar input_schema_mapping: This enables publishing using custom event schemas. An @@ -4984,7 +4780,7 @@ class Topic(TrackedResource): default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :ivar inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -4993,41 +4789,44 @@ class Topic(TrackedResource): is false. When the property is set to true, only AAD token will be used to authenticate if user is allowed to publish to the topic. :vartype disable_local_auth: bool - :ivar data_residency_boundary: Data Residency Boundary of the resource. Possible values - include: "WithinGeopair", "WithinRegion". + :ivar data_residency_boundary: Data Residency Boundary of the resource. Known values are: + "WithinGeopair" and "WithinRegion". :vartype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'endpoint': {'readonly': True}, - 'metric_resource_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "system_data": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "endpoint": {"readonly": True}, + "metric_resource_id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'endpoint': {'key': 'properties.endpoint', 'type': 'str'}, - 'input_schema': {'key': 'properties.inputSchema', 'type': 'str'}, - 'input_schema_mapping': {'key': 'properties.inputSchemaMapping', 'type': 'InputSchemaMapping'}, - 'metric_resource_id': {'key': 'properties.metricResourceId', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'inbound_ip_rules': {'key': 'properties.inboundIpRules', 'type': '[InboundIpRule]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'data_residency_boundary': {'key': 'properties.dataResidencyBoundary', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "endpoint": {"key": "properties.endpoint", "type": "str"}, + "input_schema": {"key": "properties.inputSchema", "type": "str"}, + "input_schema_mapping": {"key": "properties.inputSchemaMapping", "type": "InputSchemaMapping"}, + "metric_resource_id": {"key": "properties.metricResourceId", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "inbound_ip_rules": {"key": "properties.inboundIpRules", "type": "[InboundIpRule]"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "data_residency_boundary": {"key": "properties.dataResidencyBoundary", "type": "str"}, } def __init__( @@ -5035,24 +4834,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, - input_schema: Optional[Union[str, "InputSchema"]] = None, - input_schema_mapping: Optional["InputSchemaMapping"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - inbound_ip_rules: Optional[List["InboundIpRule"]] = None, - disable_local_auth: Optional[bool] = False, - data_residency_boundary: Optional[Union[str, "DataResidencyBoundary"]] = None, + identity: Optional["_models.IdentityInfo"] = None, + input_schema: Optional[Union[str, "_models.InputSchema"]] = None, + input_schema_mapping: Optional["_models.InputSchemaMapping"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + inbound_ip_rules: Optional[List["_models.InboundIpRule"]] = None, + disable_local_auth: bool = False, + data_residency_boundary: Optional[Union[str, "_models.DataResidencyBoundary"]] = None, **kwargs ): """ - :keyword location: Required. Location of the resource. + :keyword location: Location of the resource. Required. :paramtype location: str - :keyword tags: A set of tags. Tags of the resource. + :keyword tags: Tags of the resource. :paramtype tags: dict[str, str] :keyword identity: Identity information for the resource. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo :keyword input_schema: This determines the format that Event Grid should expect for incoming - events published to the topic. Possible values include: "EventGridSchema", "CustomEventSchema", + events published to the topic. Known values are: "EventGridSchema", "CustomEventSchema", and "CloudEventSchemaV1_0". :paramtype input_schema: str or ~azure.mgmt.eventgrid.models.InputSchema :keyword input_schema_mapping: This enables publishing using custom event schemas. An @@ -5063,7 +4862,7 @@ def __init__( default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :keyword inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -5072,11 +4871,11 @@ def __init__( value is false. When the property is set to true, only AAD token will be used to authenticate if user is allowed to publish to the topic. :paramtype disable_local_auth: bool - :keyword data_residency_boundary: Data Residency Boundary of the resource. Possible values - include: "WithinGeopair", "WithinRegion". + :keyword data_residency_boundary: Data Residency Boundary of the resource. Known values are: + "WithinGeopair" and "WithinRegion". :paramtype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ - super(Topic, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.identity = identity self.system_data = None self.private_endpoint_connections = None @@ -5091,38 +4890,33 @@ def __init__( self.data_residency_boundary = data_residency_boundary -class TopicRegenerateKeyRequest(msrest.serialization.Model): +class TopicRegenerateKeyRequest(_serialization.Model): """Topic regenerate share access key request. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. Key name to regenerate key1 or key2. + :ivar key_name: Key name to regenerate key1 or key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. Key name to regenerate key1 or key2. + :keyword key_name: Key name to regenerate key1 or key2. Required. :paramtype key_name: str """ - super(TopicRegenerateKeyRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class TopicSharedAccessKeys(msrest.serialization.Model): +class TopicSharedAccessKeys(_serialization.Model): """Shared access keys of the Topic. :ivar key1: Shared access key1 for the topic. @@ -5132,29 +4926,23 @@ class TopicSharedAccessKeys(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'str'}, - 'key2': {'key': 'key2', 'type': 'str'}, + "key1": {"key": "key1", "type": "str"}, + "key2": {"key": "key2", "type": "str"}, } - def __init__( - self, - *, - key1: Optional[str] = None, - key2: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[str] = None, key2: Optional[str] = None, **kwargs): """ :keyword key1: Shared access key1 for the topic. :paramtype key1: str :keyword key2: Shared access key2 for the topic. :paramtype key2: str """ - super(TopicSharedAccessKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class TopicsListResult(msrest.serialization.Model): +class TopicsListResult(_serialization.Model): """Result of the List Topics operation. :ivar value: A collection of Topics. @@ -5164,29 +4952,23 @@ class TopicsListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Topic]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Topic]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Topic"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Topic"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: A collection of Topics. :paramtype value: list[~azure.mgmt.eventgrid.models.Topic] :keyword next_link: A link for the next page of topics. :paramtype next_link: str """ - super(TopicsListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class TopicTypeInfo(Resource): +class TopicTypeInfo(Resource): # pylint: disable=too-many-instance-attributes """Properties of a topic type info. Variables are only populated by the server, and will be ignored when sending a request. @@ -5203,11 +4985,11 @@ class TopicTypeInfo(Resource): :vartype display_name: str :ivar description: Description of the topic type. :vartype description: str - :ivar resource_region_type: Region type of the resource. Possible values include: - "RegionalResource", "GlobalResource". + :ivar resource_region_type: Region type of the resource. Known values are: "RegionalResource" + and "GlobalResource". :vartype resource_region_type: str or ~azure.mgmt.eventgrid.models.ResourceRegionType - :ivar provisioning_state: Provisioning state of the topic type. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the topic type. Known values are: "Creating", + "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.TopicTypeProvisioningState :ivar supported_locations: List of locations supported by this topic type. :vartype supported_locations: list[str] @@ -5219,23 +5001,23 @@ class TopicTypeInfo(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'provider': {'key': 'properties.provider', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'resource_region_type': {'key': 'properties.resourceRegionType', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'supported_locations': {'key': 'properties.supportedLocations', 'type': '[str]'}, - 'source_resource_format': {'key': 'properties.sourceResourceFormat', 'type': 'str'}, - 'supported_scopes_for_source': {'key': 'properties.supportedScopesForSource', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "provider": {"key": "properties.provider", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "description": {"key": "properties.description", "type": "str"}, + "resource_region_type": {"key": "properties.resourceRegionType", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "supported_locations": {"key": "properties.supportedLocations", "type": "[str]"}, + "source_resource_format": {"key": "properties.sourceResourceFormat", "type": "str"}, + "supported_scopes_for_source": {"key": "properties.supportedScopesForSource", "type": "[str]"}, } def __init__( @@ -5244,11 +5026,11 @@ def __init__( provider: Optional[str] = None, display_name: Optional[str] = None, description: Optional[str] = None, - resource_region_type: Optional[Union[str, "ResourceRegionType"]] = None, - provisioning_state: Optional[Union[str, "TopicTypeProvisioningState"]] = None, + resource_region_type: Optional[Union[str, "_models.ResourceRegionType"]] = None, + provisioning_state: Optional[Union[str, "_models.TopicTypeProvisioningState"]] = None, supported_locations: Optional[List[str]] = None, source_resource_format: Optional[str] = None, - supported_scopes_for_source: Optional[List[Union[str, "TopicTypeSourceScope"]]] = None, + supported_scopes_for_source: Optional[List[Union[str, "_models.TopicTypeSourceScope"]]] = None, **kwargs ): """ @@ -5258,11 +5040,11 @@ def __init__( :paramtype display_name: str :keyword description: Description of the topic type. :paramtype description: str - :keyword resource_region_type: Region type of the resource. Possible values include: - "RegionalResource", "GlobalResource". + :keyword resource_region_type: Region type of the resource. Known values are: + "RegionalResource" and "GlobalResource". :paramtype resource_region_type: str or ~azure.mgmt.eventgrid.models.ResourceRegionType - :keyword provisioning_state: Provisioning state of the topic type. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :keyword provisioning_state: Provisioning state of the topic type. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.eventgrid.models.TopicTypeProvisioningState :keyword supported_locations: List of locations supported by this topic type. :paramtype supported_locations: list[str] @@ -5272,7 +5054,7 @@ def __init__( :paramtype supported_scopes_for_source: list[str or ~azure.mgmt.eventgrid.models.TopicTypeSourceScope] """ - super(TopicTypeInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.display_name = display_name self.description = description @@ -5283,7 +5065,7 @@ def __init__( self.supported_scopes_for_source = supported_scopes_for_source -class TopicTypesListResult(msrest.serialization.Model): +class TopicTypesListResult(_serialization.Model): """Result of the List Topic Types operation. :ivar value: A collection of topic types. @@ -5291,27 +5073,22 @@ class TopicTypesListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[TopicTypeInfo]'}, + "value": {"key": "value", "type": "[TopicTypeInfo]"}, } - def __init__( - self, - *, - value: Optional[List["TopicTypeInfo"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.TopicTypeInfo"]] = None, **kwargs): """ :keyword value: A collection of topic types. :paramtype value: list[~azure.mgmt.eventgrid.models.TopicTypeInfo] """ - super(TopicTypesListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class TopicUpdateParameters(msrest.serialization.Model): +class TopicUpdateParameters(_serialization.Model): """Properties of the Topic update. - :ivar tags: A set of tags. Tags of the Topic resource. + :ivar tags: Tags of the Topic resource. :vartype tags: dict[str, str] :ivar identity: Topic resource identity information. :vartype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -5319,7 +5096,7 @@ class TopicUpdateParameters(msrest.serialization.Model): default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :ivar inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -5328,33 +5105,33 @@ class TopicUpdateParameters(msrest.serialization.Model): is false. When the property is set to true, only AAD token will be used to authenticate if user is allowed to publish to the topic. :vartype disable_local_auth: bool - :ivar data_residency_boundary: The data residency boundary for the topic. Possible values - include: "WithinGeopair", "WithinRegion". + :ivar data_residency_boundary: The data residency boundary for the topic. Known values are: + "WithinGeopair" and "WithinRegion". :vartype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'IdentityInfo'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'inbound_ip_rules': {'key': 'properties.inboundIpRules', 'type': '[InboundIpRule]'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'data_residency_boundary': {'key': 'properties.dataResidencyBoundary', 'type': 'str'}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "IdentityInfo"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "inbound_ip_rules": {"key": "properties.inboundIpRules", "type": "[InboundIpRule]"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "data_residency_boundary": {"key": "properties.dataResidencyBoundary", "type": "str"}, } def __init__( self, *, tags: Optional[Dict[str, str]] = None, - identity: Optional["IdentityInfo"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - inbound_ip_rules: Optional[List["InboundIpRule"]] = None, + identity: Optional["_models.IdentityInfo"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + inbound_ip_rules: Optional[List["_models.InboundIpRule"]] = None, disable_local_auth: Optional[bool] = None, - data_residency_boundary: Optional[Union[str, "DataResidencyBoundary"]] = None, + data_residency_boundary: Optional[Union[str, "_models.DataResidencyBoundary"]] = None, **kwargs ): """ - :keyword tags: A set of tags. Tags of the Topic resource. + :keyword tags: Tags of the Topic resource. :paramtype tags: dict[str, str] :keyword identity: Topic resource identity information. :paramtype identity: ~azure.mgmt.eventgrid.models.IdentityInfo @@ -5362,7 +5139,7 @@ def __init__( default it is enabled. You can further restrict to specific IPs by configuring :code:``. Possible values include: "Enabled", "Disabled". + />`. Known values are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.eventgrid.models.PublicNetworkAccess :keyword inbound_ip_rules: This can be used to restrict traffic from specific IPs instead of all IPs. Note: These are considered only if PublicNetworkAccess is enabled. @@ -5371,11 +5148,11 @@ def __init__( value is false. When the property is set to true, only AAD token will be used to authenticate if user is allowed to publish to the topic. :paramtype disable_local_auth: bool - :keyword data_residency_boundary: The data residency boundary for the topic. Possible values - include: "WithinGeopair", "WithinRegion". + :keyword data_residency_boundary: The data residency boundary for the topic. Known values are: + "WithinGeopair" and "WithinRegion". :paramtype data_residency_boundary: str or ~azure.mgmt.eventgrid.models.DataResidencyBoundary """ - super(TopicUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.identity = identity self.public_network_access = public_network_access @@ -5384,7 +5161,7 @@ def __init__( self.data_residency_boundary = data_residency_boundary -class UserIdentityProperties(msrest.serialization.Model): +class UserIdentityProperties(_serialization.Model): """The information about the user identity. :ivar principal_id: The principal id of user assigned identity. @@ -5394,24 +5171,18 @@ class UserIdentityProperties(msrest.serialization.Model): """ _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - *, - principal_id: Optional[str] = None, - client_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, principal_id: Optional[str] = None, client_id: Optional[str] = None, **kwargs): """ :keyword principal_id: The principal id of user assigned identity. :paramtype principal_id: str :keyword client_id: The client id of user assigned identity. :paramtype client_id: str """ - super(UserIdentityProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = principal_id self.client_id = client_id @@ -5437,29 +5208,29 @@ class VerifiedPartner(Resource): :vartype partner_display_name: str :ivar partner_topic_details: Details of the partner topic scenario. :vartype partner_topic_details: ~azure.mgmt.eventgrid.models.PartnerDetails - :ivar provisioning_state: Provisioning state of the verified partner. Possible values include: - "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :ivar provisioning_state: Provisioning state of the verified partner. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.eventgrid.models.VerifiedPartnerProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'partner_registration_immutable_id': {'key': 'properties.partnerRegistrationImmutableId', 'type': 'str'}, - 'organization_name': {'key': 'properties.organizationName', 'type': 'str'}, - 'partner_display_name': {'key': 'properties.partnerDisplayName', 'type': 'str'}, - 'partner_topic_details': {'key': 'properties.partnerTopicDetails', 'type': 'PartnerDetails'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "partner_registration_immutable_id": {"key": "properties.partnerRegistrationImmutableId", "type": "str"}, + "organization_name": {"key": "properties.organizationName", "type": "str"}, + "partner_display_name": {"key": "properties.partnerDisplayName", "type": "str"}, + "partner_topic_details": {"key": "properties.partnerTopicDetails", "type": "PartnerDetails"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5468,8 +5239,8 @@ def __init__( partner_registration_immutable_id: Optional[str] = None, organization_name: Optional[str] = None, partner_display_name: Optional[str] = None, - partner_topic_details: Optional["PartnerDetails"] = None, - provisioning_state: Optional[Union[str, "VerifiedPartnerProvisioningState"]] = None, + partner_topic_details: Optional["_models.PartnerDetails"] = None, + provisioning_state: Optional[Union[str, "_models.VerifiedPartnerProvisioningState"]] = None, **kwargs ): """ @@ -5482,12 +5253,12 @@ def __init__( :paramtype partner_display_name: str :keyword partner_topic_details: Details of the partner topic scenario. :paramtype partner_topic_details: ~azure.mgmt.eventgrid.models.PartnerDetails - :keyword provisioning_state: Provisioning state of the verified partner. Possible values - include: "Creating", "Updating", "Deleting", "Succeeded", "Canceled", "Failed". + :keyword provisioning_state: Provisioning state of the verified partner. Known values are: + "Creating", "Updating", "Deleting", "Succeeded", "Canceled", and "Failed". :paramtype provisioning_state: str or ~azure.mgmt.eventgrid.models.VerifiedPartnerProvisioningState """ - super(VerifiedPartner, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.partner_registration_immutable_id = partner_registration_immutable_id self.organization_name = organization_name @@ -5496,7 +5267,7 @@ def __init__( self.provisioning_state = provisioning_state -class VerifiedPartnersListResult(msrest.serialization.Model): +class VerifiedPartnersListResult(_serialization.Model): """Result of the List verified partners operation. :ivar value: A collection of verified partners. @@ -5506,16 +5277,12 @@ class VerifiedPartnersListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[VerifiedPartner]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[VerifiedPartner]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["VerifiedPartner"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.VerifiedPartner"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: A collection of verified partners. @@ -5523,7 +5290,7 @@ def __init__( :keyword next_link: A link for the next page of verified partners if any. :paramtype next_link: str """ - super(VerifiedPartnersListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -5535,9 +5302,9 @@ class WebHookEventSubscriptionDestination(EventSubscriptionDestination): All required parameters must be populated in order to send to Azure. - :ivar endpoint_type: Required. Type of the endpoint for the event subscription - destination.Constant filled by server. Possible values include: "WebHook", "EventHub", - "StorageQueue", "HybridConnection", "ServiceBusQueue", "ServiceBusTopic", "AzureFunction". + :ivar endpoint_type: Type of the endpoint for the event subscription destination. Required. + Known values are: "WebHook", "EventHub", "StorageQueue", "HybridConnection", "ServiceBusQueue", + "ServiceBusTopic", and "AzureFunction". :vartype endpoint_type: str or ~azure.mgmt.eventgrid.models.EndpointType :ivar endpoint_url: The URL that represents the endpoint of the destination of an event subscription. @@ -5561,30 +5328,36 @@ class WebHookEventSubscriptionDestination(EventSubscriptionDestination): """ _validation = { - 'endpoint_type': {'required': True}, - 'endpoint_base_url': {'readonly': True}, + "endpoint_type": {"required": True}, + "endpoint_base_url": {"readonly": True}, } _attribute_map = { - 'endpoint_type': {'key': 'endpointType', 'type': 'str'}, - 'endpoint_url': {'key': 'properties.endpointUrl', 'type': 'str'}, - 'endpoint_base_url': {'key': 'properties.endpointBaseUrl', 'type': 'str'}, - 'max_events_per_batch': {'key': 'properties.maxEventsPerBatch', 'type': 'int'}, - 'preferred_batch_size_in_kilobytes': {'key': 'properties.preferredBatchSizeInKilobytes', 'type': 'int'}, - 'azure_active_directory_tenant_id': {'key': 'properties.azureActiveDirectoryTenantId', 'type': 'str'}, - 'azure_active_directory_application_id_or_uri': {'key': 'properties.azureActiveDirectoryApplicationIdOrUri', 'type': 'str'}, - 'delivery_attribute_mappings': {'key': 'properties.deliveryAttributeMappings', 'type': '[DeliveryAttributeMapping]'}, + "endpoint_type": {"key": "endpointType", "type": "str"}, + "endpoint_url": {"key": "properties.endpointUrl", "type": "str"}, + "endpoint_base_url": {"key": "properties.endpointBaseUrl", "type": "str"}, + "max_events_per_batch": {"key": "properties.maxEventsPerBatch", "type": "int"}, + "preferred_batch_size_in_kilobytes": {"key": "properties.preferredBatchSizeInKilobytes", "type": "int"}, + "azure_active_directory_tenant_id": {"key": "properties.azureActiveDirectoryTenantId", "type": "str"}, + "azure_active_directory_application_id_or_uri": { + "key": "properties.azureActiveDirectoryApplicationIdOrUri", + "type": "str", + }, + "delivery_attribute_mappings": { + "key": "properties.deliveryAttributeMappings", + "type": "[DeliveryAttributeMapping]", + }, } def __init__( self, *, endpoint_url: Optional[str] = None, - max_events_per_batch: Optional[int] = 1, - preferred_batch_size_in_kilobytes: Optional[int] = 64, + max_events_per_batch: int = 1, + preferred_batch_size_in_kilobytes: int = 64, azure_active_directory_tenant_id: Optional[str] = None, azure_active_directory_application_id_or_uri: Optional[str] = None, - delivery_attribute_mappings: Optional[List["DeliveryAttributeMapping"]] = None, + delivery_attribute_mappings: Optional[List["_models.DeliveryAttributeMapping"]] = None, **kwargs ): """ @@ -5606,8 +5379,8 @@ def __init__( :paramtype delivery_attribute_mappings: list[~azure.mgmt.eventgrid.models.DeliveryAttributeMapping] """ - super(WebHookEventSubscriptionDestination, self).__init__(**kwargs) - self.endpoint_type = 'WebHook' # type: str + super().__init__(**kwargs) + self.endpoint_type = "WebHook" # type: str self.endpoint_url = endpoint_url self.endpoint_base_url = None self.max_events_per_batch = max_events_per_batch diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_patch.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/__init__.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/__init__.py index 74227e25aa0d..c04bd7bb5725 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/__init__.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/__init__.py @@ -28,26 +28,32 @@ from ._topic_types_operations import TopicTypesOperations from ._verified_partners_operations import VerifiedPartnersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ChannelsOperations', - 'DomainsOperations', - 'DomainTopicsOperations', - 'TopicEventSubscriptionsOperations', - 'DomainEventSubscriptionsOperations', - 'EventSubscriptionsOperations', - 'DomainTopicEventSubscriptionsOperations', - 'SystemTopicEventSubscriptionsOperations', - 'PartnerTopicEventSubscriptionsOperations', - 'Operations', - 'TopicsOperations', - 'PartnerConfigurationsOperations', - 'PartnerNamespacesOperations', - 'PartnerRegistrationsOperations', - 'PartnerTopicsOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'SystemTopicsOperations', - 'ExtensionTopicsOperations', - 'TopicTypesOperations', - 'VerifiedPartnersOperations', + "ChannelsOperations", + "DomainsOperations", + "DomainTopicsOperations", + "TopicEventSubscriptionsOperations", + "DomainEventSubscriptionsOperations", + "EventSubscriptionsOperations", + "DomainTopicEventSubscriptionsOperations", + "SystemTopicEventSubscriptionsOperations", + "PartnerTopicEventSubscriptionsOperations", + "Operations", + "TopicsOperations", + "PartnerConfigurationsOperations", + "PartnerNamespacesOperations", + "PartnerRegistrationsOperations", + "PartnerTopicsOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "SystemTopicsOperations", + "ExtensionTopicsOperations", + "TopicTypesOperations", + "VerifiedPartnersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_channels_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_channels_operations.py index 2b1fdf80324c..0855efec756d 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_channels_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_channels_operations.py @@ -6,354 +6,380 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, channel_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), - "channelName": _SERIALIZER.url("channel_name", channel_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), + "channelName": _SERIALIZER.url("channel_name", channel_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, channel_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), - "channelName": _SERIALIZER.url("channel_name", channel_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), + "channelName": _SERIALIZER.url("channel_name", channel_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, partner_namespace_name: str, channel_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), - "channelName": _SERIALIZER.url("channel_name", channel_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), + "channelName": _SERIALIZER.url("channel_name", channel_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, channel_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), - "channelName": _SERIALIZER.url("channel_name", channel_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), + "channelName": _SERIALIZER.url("channel_name", channel_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_partner_namespace_request( - subscription_id: str, resource_group_name: str, partner_namespace_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_full_url_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, channel_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), - "channelName": _SERIALIZER.url("channel_name", channel_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), + "channelName": _SERIALIZER.url("channel_name", channel_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ChannelsOperations(object): - """ChannelsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ChannelsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`channels` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any - ) -> "_models.Channel": + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any + ) -> _models.Channel: """Get a channel. Get properties of a channel. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Channel, or the result of cls(response) + :return: Channel or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Channel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Channel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Channel] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Channel', pipeline_response) + deserialized = self._deserialize("Channel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_info: _models.Channel, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Channel: + """Create or update a channel. + + Synchronously creates or updates a new channel with the specified parameters. + + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_info: Channel information. Required. + :type channel_info: ~azure.mgmt.eventgrid.models.Channel + :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: Channel or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.Channel + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Channel: + """Create or update a channel. + + Synchronously creates or updates a new channel with the specified parameters. + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_info: Channel information. Required. + :type channel_info: IO + :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: Channel or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.Channel + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -361,55 +387,68 @@ def create_or_update( resource_group_name: str, partner_namespace_name: str, channel_name: str, - channel_info: "_models.Channel", + channel_info: Union[_models.Channel, IO], **kwargs: Any - ) -> "_models.Channel": + ) -> _models.Channel: """Create or update a channel. Synchronously creates or updates a new channel with the specified parameters. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_name: str - :param channel_info: Channel information. - :type channel_info: ~azure.mgmt.eventgrid.models.Channel + :param channel_info: Channel information. Is either a model type or a IO type. Required. + :type channel_info: ~azure.mgmt.eventgrid.models.Channel 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 - :return: Channel, or the result of cls(response) + :return: Channel or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Channel - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Channel"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Channel] - _json = self._serialize.body(channel_info, 'Channel') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(channel_info, (IO, bytes)): + _content = channel_info + else: + _json = self._serialize.body(channel_info, "Channel") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -417,51 +456,47 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('Channel', pipeline_response) + deserialized = self._deserialize("Channel", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('Channel', pipeline_response) + deserialized = self._deserialize("Channel", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -471,26 +506,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a channel. Delete an existing channel. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_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. @@ -502,53 +533,59 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - @distributed_trace + @overload def update( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, partner_namespace_name: str, channel_name: str, - channel_update_parameters: "_models.ChannelUpdateParameters", + channel_update_parameters: _models.ChannelUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Update a Channel. @@ -556,47 +593,125 @@ def update( # pylint: disable=inconsistent-return-statements Synchronously updates a channel with the specified parameters. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the channel. + :param channel_name: Name of the channel. Required. :type channel_name: str - :param channel_update_parameters: Channel update information. + :param channel_update_parameters: Channel update information. Required. :type channel_update_parameters: ~azure.mgmt.eventgrid.models.ChannelUpdateParameters + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Update a Channel. + + Synchronously updates a channel with the specified parameters. + + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_update_parameters: Channel update information. Required. + :type channel_update_parameters: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + partner_namespace_name: str, + channel_name: str, + channel_update_parameters: Union[_models.ChannelUpdateParameters, IO], + **kwargs: Any + ) -> None: + """Update a Channel. + + Synchronously updates a channel with the specified parameters. + + :param resource_group_name: The name of the resource group within the partners subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param channel_name: Name of the channel. Required. + :type channel_name: str + :param channel_update_parameters: Channel update information. Is either a model type or a IO + type. Required. + :type channel_update_parameters: ~azure.mgmt.eventgrid.models.ChannelUpdateParameters 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(channel_update_parameters, 'ChannelUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(channel_update_parameters, (IO, bytes)): + _content = channel_update_parameters + else: + _json = self._serialize.body(channel_update_parameters, "ChannelUpdateParameters") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -606,8 +721,7 @@ def update( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}"} # type: ignore @distributed_trace def list_by_partner_namespace( @@ -617,14 +731,15 @@ def list_by_partner_namespace( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.ChannelsListResult"]: + ) -> Iterable["_models.Channel"]: """List channels. List all the channels in a partner namespace. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -639,45 +754,44 @@ def list_by_partner_namespace( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ChannelsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.ChannelsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Channel or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.Channel] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ChannelsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChannelsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_partner_namespace_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_partner_namespace.metadata['url'], + api_version=api_version, + template_url=self.list_by_partner_namespace.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_partner_namespace_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - partner_namespace_name=partner_namespace_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -691,10 +805,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -704,72 +816,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_partner_namespace.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels"} # type: ignore + list_by_partner_namespace.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels"} # type: ignore @distributed_trace def get_full_url( - self, - resource_group_name: str, - partner_namespace_name: str, - channel_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, partner_namespace_name: str, channel_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of partner destination channel. Get the full endpoint URL of a partner destination channel. :param resource_group_name: The name of the resource group within the partners subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param channel_name: Name of the Channel. + :param channel_name: Name of the Channel. Required. :type channel_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, channel_name=channel_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/channels/{channelName}/getFullUrl"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_event_subscriptions_operations.py index 0a5f5c6178a6..a64e369e4de4 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_event_subscriptions_operations.py @@ -6,497 +6,459 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_delivery_attributes_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, domain_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, domain_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, domain_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, domain_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, domain_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_full_url_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, domain_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, domain_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DomainEventSubscriptionsOperations(object): - """DomainEventSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DomainEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`domain_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_delivery_attributes( - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription for domain. Get all delivery attributes for an event subscription for domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain topic. + :param domain_name: Name of the domain topic. Required. :type domain_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a domain. Get properties of an event subscription of a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the partner topic. + :param domain_name: Name of the partner topic. Required. :type domain_name: str :param event_subscription_name: Name of the event subscription to be found. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters only. + Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -504,18 +466,105 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription to a domain. + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain topic. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription to a domain. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain topic. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -523,24 +572,28 @@ def begin_create_or_update( resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Create or update an event subscription to a domain. Asynchronously creates a new event subscription or updates an existing event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain topic. + :param domain_name: Name of the domain topic. Required. :type domain_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -552,84 +605,84 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -639,28 +692,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete an event subscription for a domain. Delete an existing event subscription for a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :param event_subscription_name: Name of the event subscription to be deleted. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -672,98 +721,193 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _update_initial( self, resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update an event subscription for a domain. + + Update an existing event subscription for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + domain_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update an event subscription for a domain. + Update an existing event subscription for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -771,22 +915,27 @@ def begin_update( resource_group_name: str, domain_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Update an event subscription for a domain. Update an existing event subscription for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -798,115 +947,115 @@ def begin_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace def get_full_url( - self, - resource_group_name: str, - domain_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, domain_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription for domain. Get the full endpoint URL for an event subscription for domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain topic. + :param domain_name: Name of the domain topic. Required. :type domain_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list( @@ -916,14 +1065,15 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all event subscriptions for a specific domain. List all event subscriptions that have been created for a specific topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -938,46 +1088,44 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -991,10 +1139,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1004,8 +1150,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/eventSubscriptions"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topic_event_subscriptions_operations.py index 47e849cb87ba..ea1115531c3c 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topic_event_subscriptions_operations.py @@ -6,412 +6,390 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, +def build_create_or_update_request( resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_full_url_request( - subscription_id: str, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, domain_name: str, topic_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_delivery_attributes_request( - subscription_id: str, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DomainTopicEventSubscriptionsOperations(object): - """DomainTopicEventSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DomainTopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`domain_topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get a nested event subscription for domain topic. Get properties of a nested event subscription for a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _create_or_update_initial( self, @@ -419,39 +397,48 @@ def _create_or_update_initial( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -459,18 +446,111 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update a nested event subscription to a domain topic. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the top level domain. Required. + :type domain_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update a nested event subscription to a domain topic. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the top level domain. Required. + :type domain_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -479,26 +559,30 @@ def begin_create_or_update( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Create or update a nested event subscription to a domain topic. Asynchronously creates a new event subscription or updates an existing event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -510,19 +594,19 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, @@ -530,67 +614,66 @@ def begin_create_or_update( event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -600,31 +683,26 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a nested event subscription for a domain topic. Delete a nested existing event subscription for a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be deleted. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -636,46 +714,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _update_initial( self, @@ -683,54 +765,151 @@ def _update_initial( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update a nested event subscription for a domain topic. + + Update an existing event subscription for a domain topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + domain_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update a nested event subscription for a domain topic. + + Update an existing event subscription for a domain topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -739,24 +918,29 @@ def begin_update( domain_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Update a nested event subscription for a domain topic. Update an existing event subscription for a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -768,19 +952,19 @@ def begin_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, @@ -788,100 +972,99 @@ def begin_update( event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace def get_full_url( - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of a nested event subscription for domain topic. Get the full endpoint URL for a nested event subscription for domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list( @@ -892,16 +1075,17 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all nested event subscriptions for a specific domain topic. List all event subscriptions that have been created for a specific domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -916,48 +1100,45 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - topic_name=topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -971,10 +1152,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -984,76 +1163,70 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions"} # type: ignore @distributed_trace def get_delivery_attributes( - self, - resource_group_name: str, - domain_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, domain_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription for domain topic. Get all delivery attributes for an event subscription for domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topics_operations.py index 8abf1e0182f8..6c14bf1b239c 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domain_topics_operations.py @@ -6,329 +6,306 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any + resource_group_name: str, domain_name: str, domain_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "domainTopicName": _SERIALIZER.url("domain_topic_name", domain_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "domainTopicName": _SERIALIZER.url("domain_topic_name", domain_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, domain_name: str, domain_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "domainTopicName": _SERIALIZER.url("domain_topic_name", domain_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "domainTopicName": _SERIALIZER.url("domain_topic_name", domain_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, domain_name: str, domain_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "domainTopicName": _SERIALIZER.url("domain_topic_name", domain_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "domainTopicName": _SERIALIZER.url("domain_topic_name", domain_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_by_domain_request( - subscription_id: str, resource_group_name: str, domain_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DomainTopicsOperations(object): - """DomainTopicsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class DomainTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`domain_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any - ) -> "_models.DomainTopic": + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any + ) -> _models.DomainTopic: """Get a domain topic. Get properties of a domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_topic_name: Name of the topic. + :param domain_topic_name: Name of the topic. Required. :type domain_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DomainTopic, or the result of cls(response) + :return: DomainTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DomainTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainTopic', pipeline_response) + deserialized = self._deserialize("DomainTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any - ) -> "_models.DomainTopic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any + ) -> _models.DomainTopic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopic] + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._create_or_update_initial.metadata['url'], + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainTopic', pipeline_response) + deserialized = self._deserialize("DomainTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore @distributed_trace def begin_create_or_update( - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any - ) -> LROPoller["_models.DomainTopic"]: + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any + ) -> LROPoller[_models.DomainTopic]: """Create or update a domain topic. Asynchronously creates or updates a new domain topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_topic_name: Name of the domain topic. + :param domain_topic_name: Name of the domain topic. Required. :type domain_topic_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. @@ -341,81 +318,81 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either DomainTopic or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.DomainTopic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopic] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('DomainTopic', pipeline_response) + deserialized = self._deserialize("DomainTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -425,26 +402,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - domain_topic_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, domain_name: str, domain_topic_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a domain topic. Delete existing domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_topic_name: Name of the domain topic. + :param domain_topic_name: Name of the domain topic. Required. :type domain_topic_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. @@ -456,45 +429,49 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_topic_name=domain_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{domainTopicName}"} # type: ignore @distributed_trace def list_by_domain( @@ -504,14 +481,15 @@ def list_by_domain( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.DomainTopicsListResult"]: + ) -> Iterable["_models.DomainTopic"]: """List domain topics. List all the topics in a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Domain name. + :param domain_name: Domain name. Required. :type domain_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -526,46 +504,44 @@ def list_by_domain( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DomainTopicsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.DomainTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DomainTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.DomainTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_domain_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_domain.metadata['url'], + api_version=api_version, + template_url=self.list_by_domain.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_domain_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -579,10 +555,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -592,8 +566,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_domain.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics"} # type: ignore + list_by_domain.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domains_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domains_operations.py index de15cf374e82..25f28d16bcc8 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domains_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_domains_operations.py @@ -6,493 +6,447 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, domain_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - domain_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/domains") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_shared_access_keys_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - **kwargs: Any + resource_group_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - subscription_id: str, - resource_group_name: str, - domain_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, domain_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class DomainsOperations(object): - """DomainsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.Domain": + def get(self, resource_group_name: str, domain_name: str, **kwargs: Any) -> _models.Domain: """Get a domain. Get properties of a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Domain, or the result of cls(response) + :return: Domain or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Domain - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Domain] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - domain_name: str, - domain_info: "_models.Domain", - **kwargs: Any - ) -> "_models.Domain": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_info, 'Domain') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, domain_name: str, domain_info: Union[_models.Domain, IO], **kwargs: Any + ) -> _models.Domain: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Domain] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_info, (IO, bytes)): + _content = domain_info + else: + _json = self._serialize.body(domain_info, "Domain") + + request = build_create_or_update_request( resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, domain_name: str, - domain_info: "_models.Domain", + domain_info: _models.Domain, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Domain"]: + ) -> LROPoller[_models.Domain]: """Create or update a domain. Asynchronously creates or updates a new domain with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_info: Domain information. + :param domain_info: Domain information. Required. :type domain_info: ~azure.mgmt.eventgrid.models.Domain + :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 @@ -503,81 +457,150 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either Domain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Domain] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + domain_name: str, + domain_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Domain]: + """Create or update a domain. + + Asynchronously creates or updates a new domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_info: Domain information. Required. + :type domain_info: IO + :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 Domain or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, domain_name: str, domain_info: Union[_models.Domain, IO], **kwargs: Any + ) -> LROPoller[_models.Domain]: + """Create or update a domain. + + Asynchronously creates or updates a new domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_info: Domain information. Is either a model type or a IO type. Required. + :type domain_info: ~azure.mgmt.eventgrid.models.Domain 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. + :return: An instance of LROPoller that returns either Domain or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Domain] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_info=domain_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any + self, resource_group_name: str, domain_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -587,23 +610,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, domain_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a domain. Delete existing domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_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. @@ -615,80 +633,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore def _update_initial( self, resource_group_name: str, domain_name: str, - domain_update_parameters: "_models.DomainUpdateParameters", + domain_update_parameters: Union[_models.DomainUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.Domain"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Domain"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(domain_update_parameters, 'DomainUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.Domain]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Domain]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(domain_update_parameters, (IO, bytes)): + _content = domain_update_parameters + else: + _json = self._serialize.body(domain_update_parameters, "DomainUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -697,34 +728,112 @@ def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + domain_name: str, + domain_update_parameters: _models.DomainUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a domain. + + Asynchronously updates a domain with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_update_parameters: Domain update information. Required. + :type domain_update_parameters: ~azure.mgmt.eventgrid.models.DomainUpdateParameters + :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 Domain or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + domain_name: str, + domain_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a domain. + + Asynchronously updates a domain with the specified parameters. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param domain_update_parameters: Domain update information. Required. + :type domain_update_parameters: IO + :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 Domain or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, domain_name: str, - domain_update_parameters: "_models.DomainUpdateParameters", + domain_update_parameters: Union[_models.DomainUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Domain"]: + ) -> LROPoller[None]: """Update a domain. Asynchronously updates a domain with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param domain_update_parameters: Domain update information. - :type domain_update_parameters: ~azure.mgmt.eventgrid.models.DomainUpdateParameters + :param domain_update_parameters: Domain update information. Is either a model type or a IO + type. Required. + :type domain_update_parameters: ~azure.mgmt.eventgrid.models.DomainUpdateParameters 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 @@ -735,58 +844,58 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Domain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Domain] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Domain"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, domain_name=domain_name, domain_update_parameters=domain_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Domain', pipeline_response) + deserialized = self._deserialize("Domain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DomainsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.Domain"]: """List domains under an Azure subscription. List all the domains under an Azure subscription. @@ -804,41 +913,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DomainsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.DomainsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Domain or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -852,10 +962,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -865,25 +973,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/domains"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/domains"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.DomainsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.Domain"]: """List domains under a resource group. List all the domains under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -898,43 +1001,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DomainsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.DomainsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Domain or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.Domain] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -948,10 +1051,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -961,135 +1062,204 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains"} # type: ignore @distributed_trace def list_shared_access_keys( - self, - resource_group_name: str, - domain_name: str, - **kwargs: Any - ) -> "_models.DomainSharedAccessKeys": + self, resource_group_name: str, domain_name: str, **kwargs: Any + ) -> _models.DomainSharedAccessKeys: """List keys for a domain. List the two keys used to publish to a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DomainSharedAccessKeys, or the result of cls(response) + :return: DomainSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainSharedAccessKeys] - request = build_list_shared_access_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_shared_access_keys.metadata['url'], + template_url=self.list_shared_access_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("DomainSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_shared_access_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys"} # type: ignore + list_shared_access_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/listKeys"} # type: ignore + + @overload + def regenerate_key( + self, + resource_group_name: str, + domain_name: str, + regenerate_key_request: _models.DomainRegenerateKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DomainSharedAccessKeys: + """Regenerate key for a domain. + + Regenerate a shared access key for a domain. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.DomainRegenerateKeyRequest + :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: DomainSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + domain_name: str, + regenerate_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DomainSharedAccessKeys: + """Regenerate key for a domain. + + Regenerate a shared access key for a domain. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param domain_name: Name of the domain. Required. + :type domain_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: IO + :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: DomainSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_key( self, resource_group_name: str, domain_name: str, - regenerate_key_request: "_models.DomainRegenerateKeyRequest", + regenerate_key_request: Union[_models.DomainRegenerateKeyRequest, IO], **kwargs: Any - ) -> "_models.DomainSharedAccessKeys": + ) -> _models.DomainSharedAccessKeys: """Regenerate key for a domain. Regenerate a shared access key for a domain. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the domain. + :param domain_name: Name of the domain. Required. :type domain_name: str - :param regenerate_key_request: Request body to regenerate key. - :type regenerate_key_request: ~azure.mgmt.eventgrid.models.DomainRegenerateKeyRequest + :param regenerate_key_request: Request body to regenerate key. Is either a model type or a IO + type. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.DomainRegenerateKeyRequest 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 - :return: DomainSharedAccessKeys, or the result of cls(response) + :return: DomainSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DomainSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DomainSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DomainSharedAccessKeys] - _json = self._serialize.body(regenerate_key_request, 'DomainRegenerateKeyRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_request, (IO, bytes)): + _content = regenerate_key_request + else: + _json = self._serialize.body(regenerate_key_request, "DomainRegenerateKeyRequest") request = build_regenerate_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DomainSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("DomainSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/regenerateKey"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_event_subscriptions_operations.py index bdbd83affea9..d986fcd02edc 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_event_subscriptions_operations.py @@ -6,699 +6,619 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - scope: str, - event_subscription_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_request(scope: str, event_subscription_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - scope: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_create_or_update_request(scope: str, event_subscription_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - scope: str, - event_subscription_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str +def build_delete_request(scope: str, event_subscription_name: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - scope: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_update_request(scope: str, event_subscription_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}") + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}" + ) path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_full_url_request( - scope: str, - event_subscription_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_full_url_request(scope: str, event_subscription_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl" + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_global_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_global_by_subscription_for_topic_type_request( - subscription_id: str, topic_type_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_global_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_global_by_resource_group_for_topic_type_request( - subscription_id: str, resource_group_name: str, topic_type_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_regional_by_subscription_request( - subscription_id: str, - location: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + location: str, subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_regional_by_resource_group_request( - subscription_id: str, resource_group_name: str, location: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_regional_by_subscription_for_topic_type_request( - subscription_id: str, location: str, topic_type_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), - "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_regional_by_resource_group_for_topic_type_request( - subscription_id: str, resource_group_name: str, location: str, topic_type_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "location": _SERIALIZER.url("location", location, 'str'), - "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "location": _SERIALIZER.url("location", location, "str"), + "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_request( - subscription_id: str, resource_group_name: str, provider_namespace: str, resource_type_name: str, resource_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), - "resourceTypeName": _SERIALIZER.url("resource_type_name", resource_type_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, "str"), + "resourceTypeName": _SERIALIZER.url("resource_type_name", resource_type_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_domain_topic_request( - subscription_id: str, resource_group_name: str, domain_name: str, topic_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "domainName": _SERIALIZER.url("domain_name", domain_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "domainName": _SERIALIZER.url("domain_name", domain_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_delivery_attributes_request( - scope: str, - event_subscription_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_delivery_attributes_request(scope: str, event_subscription_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes", + ) # pylint: disable=line-too-long path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str", skip_quote=True), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class EventSubscriptionsOperations(object): - """EventSubscriptionsOperations operations. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class EventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + def get(self, scope: str, event_subscription_name: str, **kwargs: Any) -> _models.EventSubscription: """Get an event subscription. Get properties of an event subscription. @@ -710,112 +630,216 @@ def get( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _create_or_update_initial( self, scope: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + def begin_create_or_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription. + + Asynchronously creates a new event subscription or updates an existing event subscription based + on the specified scope. + + :param scope: The identifier of the resource to which the event subscription needs to be + created or updated. The scope can be a subscription, or a resource group, or a top level + resource belonging to a resource provider namespace, or an EventGrid topic. For example, use + '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription. Event subscription names must + be between 3 and 64 characters in length and should use alphanumeric letters only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription. + + Asynchronously creates a new event subscription or updates an existing event subscription based + on the specified scope. + + :param scope: The identifier of the resource to which the event subscription needs to be + created or updated. The scope can be a subscription, or a resource group, or a top level + resource belonging to a resource provider namespace, or an EventGrid topic. For example, use + '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription. Event subscription names must + be between 3 and 64 characters in length and should use alphanumeric letters only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, scope: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Create or update an event subscription. Asynchronously creates a new event subscription or updates an existing event subscription based @@ -829,14 +853,17 @@ def begin_create_or_update( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str :param event_subscription_name: Name of the event subscription. Event subscription names must - be between 3 and 64 characters in length and should use alphanumeric letters only. + be between 3 and 64 characters in length and should use alphanumeric letters only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -848,80 +875,81 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore scope=scope, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - scope: str, - event_subscription_name: str, - **kwargs: Any + self, scope: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_delete_request_initial( + request = build_delete_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -931,16 +959,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, scope: str, event_subscription_name: str, **kwargs: Any) -> LROPoller[None]: """Delete an event subscription. Delete an existing event subscription. @@ -952,9 +974,9 @@ def begin_delete( # pylint: disable=inconsistent-return-statements '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_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. @@ -966,103 +988,204 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _update_initial( self, scope: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + def begin_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update an event subscription. + + Asynchronously updates an existing event subscription. + + :param scope: The scope of existing event subscription. The scope can be a subscription, or a + resource group, or a top level resource belonging to a resource provider namespace, or an + EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + scope: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update an event subscription. + + Asynchronously updates an existing event subscription. + :param scope: The scope of existing event subscription. The scope can be a subscription, or a + resource group, or a top level resource belonging to a resource provider namespace, or an + EventGrid topic. For example, use '/subscriptions/{subscriptionId}/' for a subscription, + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' + for a resource, and + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' + for an EventGrid topic. Required. + :type scope: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, scope: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Update an event subscription. Asynchronously updates an existing event subscription. @@ -1074,13 +1197,17 @@ def begin_update( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -1092,58 +1219,56 @@ def begin_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore scope=scope, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def get_full_url( - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + def get_full_url(self, scope: str, event_subscription_name: str, **kwargs: Any) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription. Get the full endpoint URL for an event subscription. @@ -1155,61 +1280,58 @@ def get_full_url( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list_global_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.EventSubscription"]: """Get an aggregated list of all global event subscriptions under an Azure subscription. List all aggregated global event subscriptions under a specific Azure subscription. @@ -1227,42 +1349,42 @@ def list_global_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_global_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_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) # type: ignore else: - - request = build_list_global_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1276,10 +1398,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1289,25 +1409,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_global_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_global_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def list_global_by_subscription_for_topic_type( - self, - topic_type_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + self, topic_type_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.EventSubscription"]: """List all global event subscriptions for a topic type. List all global event subscriptions under an Azure subscription for a topic type. - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1322,44 +1436,43 @@ def list_global_by_subscription_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_global_by_subscription_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_subscription_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_global_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1373,10 +1486,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1386,25 +1497,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_global_by_subscription_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_global_by_subscription_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_global_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.EventSubscription"]: """List all global event subscriptions under an Azure subscription and resource group. List all global event subscriptions under a specific Azure subscription and resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1419,44 +1525,43 @@ def list_global_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_global_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_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) # type: ignore else: - - request = build_list_global_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1470,10 +1575,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1483,11 +1586,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_global_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_global_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def list_global_by_resource_group_for_topic_type( @@ -1497,14 +1598,15 @@ def list_global_by_resource_group_for_topic_type( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all global event subscriptions under a resource group for a topic type. List all global event subscriptions under a resource group for a specific topic type. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1519,46 +1621,44 @@ def list_global_by_resource_group_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_global_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_global_by_resource_group_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_global_by_resource_group_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_global_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1572,10 +1672,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1585,25 +1683,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_global_by_resource_group_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_global_by_resource_group_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_subscription( - self, - location: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + self, location: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription. List all event subscriptions from the given location under a specific Azure subscription. - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1618,44 +1710,43 @@ def list_regional_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_subscription_request( - subscription_id=self._config.subscription_id, location=location, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_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) # type: ignore else: - - request = build_list_regional_by_subscription_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1669,10 +1760,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1682,11 +1771,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_regional_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore + list_regional_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_resource_group( @@ -1696,15 +1783,16 @@ def list_regional_by_resource_group( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription and resource group. List all event subscriptions from the given location under a specific Azure subscription and resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1719,46 +1807,44 @@ def list_regional_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, location=location, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_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) # type: ignore else: - - request = build_list_regional_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - location=location, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1772,10 +1858,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1785,11 +1869,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_regional_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore + list_regional_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_subscription_for_topic_type( @@ -1799,15 +1881,15 @@ def list_regional_by_subscription_for_topic_type( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription for a topic type. List all event subscriptions from the given location under a specific Azure subscription and topic type. - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1822,46 +1904,44 @@ def list_regional_by_subscription_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, location=location, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_subscription_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_subscription_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_regional_by_subscription_for_topic_type_request( - subscription_id=self._config.subscription_id, - location=location, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1875,10 +1955,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1888,11 +1966,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_regional_by_subscription_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_regional_by_subscription_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_regional_by_resource_group_for_topic_type( @@ -1903,7 +1979,7 @@ def list_regional_by_resource_group_for_topic_type( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all regional event subscriptions under an Azure subscription and resource group for a topic type. @@ -1911,10 +1987,11 @@ def list_regional_by_resource_group_for_topic_type( resource group and topic type. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param location: Name of the location. + :param location: Name of the location. Required. :type location: str - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -1929,48 +2006,45 @@ def list_regional_by_resource_group_for_topic_type( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_regional_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, location=location, topic_type_name=topic_type_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_regional_by_resource_group_for_topic_type.metadata['url'], + api_version=api_version, + template_url=self.list_regional_by_resource_group_for_topic_type.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_regional_by_resource_group_for_topic_type_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - location=location, - topic_type_name=topic_type_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1984,10 +2058,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1997,11 +2069,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_regional_by_resource_group_for_topic_type.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore + list_regional_by_resource_group_for_topic_type.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/locations/{location}/topicTypes/{topicTypeName}/eventSubscriptions"} # type: ignore @distributed_trace def list_by_resource( @@ -2013,18 +2083,19 @@ def list_by_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all event subscriptions. List all event subscriptions that have been created for a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param provider_namespace: Namespace of the provider of the topic. + :param provider_namespace: Namespace of the provider of the topic. Required. :type provider_namespace: str - :param resource_type_name: Name of the resource type. + :param resource_type_name: Name of the resource type. Required. :type resource_type_name: str - :param resource_name: Name of the resource. + :param resource_name: Name of the resource. Required. :type resource_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -2039,50 +2110,46 @@ def list_by_resource( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provider_namespace=provider_namespace, resource_type_name=resource_type_name, resource_name=resource_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - provider_namespace=provider_namespace, - resource_type_name=resource_type_name, - resource_name=resource_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2096,10 +2163,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2109,11 +2174,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def list_by_domain_topic( @@ -2124,16 +2187,17 @@ def list_by_domain_topic( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all event subscriptions for a specific domain topic. List all event subscriptions that have been created for a specific domain topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param domain_name: Name of the top level domain. + :param domain_name: Name of the top level domain. Required. :type domain_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -2148,48 +2212,45 @@ def list_by_domain_topic( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_domain_topic_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, domain_name=domain_name, topic_name=topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_domain_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_domain_topic.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_domain_topic_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - domain_name=domain_name, - topic_name=topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -2203,10 +2264,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -2216,19 +2275,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_domain_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore + list_by_domain_topic.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}/providers/Microsoft.EventGrid/eventSubscriptions"} # type: ignore @distributed_trace def get_delivery_attributes( - self, - scope: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, scope: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription. Get all delivery attributes for an event subscription. @@ -2240,50 +2294,50 @@ def get_delivery_attributes( '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' for a resource, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}' - for an EventGrid topic. + for an EventGrid topic. Required. :type scope: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( scope=scope, event_subscription_name=event_subscription_name, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_extension_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_extension_topics_operations.py index a7a47e39621b..8450357f9a6b 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_extension_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_extension_topics_operations.py @@ -8,82 +8,76 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import 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 .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - scope: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_request(scope: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.EventGrid/extensionTopics/default") path_format_arguments = { - "scope": _SERIALIZER.url("scope", scope, 'str'), + "scope": _SERIALIZER.url("scope", scope, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ExtensionTopicsOperations(object): - """ExtensionTopicsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ExtensionTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`extension_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - scope: str, - **kwargs: Any - ) -> "_models.ExtensionTopic": + def get(self, scope: str, **kwargs: Any) -> _models.ExtensionTopic: """Get properties of an extension topic. Get the properties of an extension topic. @@ -93,47 +87,47 @@ def get( provider namespace. For example, use '/subscriptions/{subscriptionId}/' for a subscription, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for a resource group, and '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}' - for Azure resource. + for Azure resource. Required. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ExtensionTopic, or the result of cls(response) + :return: ExtensionTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.ExtensionTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExtensionTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExtensionTopic] - request = build_get_request( scope=scope, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ExtensionTopic', pipeline_response) + deserialized = self._deserialize("ExtensionTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{scope}/providers/Microsoft.EventGrid/extensionTopics/default"} # type: ignore - + get.metadata = {"url": "/{scope}/providers/Microsoft.EventGrid/extensionTopics/default"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_operations.py index eeee64d2c0d1..b1893e7f0292 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_operations.py @@ -7,112 +7,112 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import 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 .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.EventGrid/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationsListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """List available operations. List the available operations supported by the Microsoft.EventGrid resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.OperationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,10 +126,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,8 +137,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.EventGrid/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.EventGrid/operations"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_configurations_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_configurations_operations.py index 71b38266bb02..faf8639c503d 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_configurations_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_configurations_operations.py @@ -6,442 +6,385 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_request(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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_create_or_update_request(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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str +def build_delete_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_update_request(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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_list_by_resource_group_request(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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_authorize_partner_request( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_authorize_partner_request(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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_unauthorize_partner_request( - subscription_id: str, - resource_group_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_unauthorize_partner_request(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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class PartnerConfigurationsOperations(object): - """PartnerConfigurationsOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PartnerConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`partner_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - **kwargs: Any - ) -> "_models.PartnerConfiguration": + def get(self, resource_group_name: str, **kwargs: Any) -> _models.PartnerConfiguration: """Get a partner configuration. Get properties of a partner configuration. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerConfiguration, or the result of cls(response) + :return: PartnerConfiguration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, - partner_configuration_info: "_models.PartnerConfiguration", + partner_configuration_info: Union[_models.PartnerConfiguration, IO], **kwargs: Any - ) -> "_models.PartnerConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_configuration_info, 'PartnerConfiguration') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PartnerConfiguration: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_configuration_info, (IO, bytes)): + _content = partner_configuration_info + else: + _json = self._serialize.body(partner_configuration_info, "PartnerConfiguration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -449,34 +392,108 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_configuration_info: _models.PartnerConfiguration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerConfiguration]: + """Create or update a partner configuration. + + Synchronously creates or updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_info: Partner configuration information. Required. + :type partner_configuration_info: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :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 PartnerConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_configuration_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerConfiguration]: + """Create or update a partner configuration. + + Synchronously creates or updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_info: Partner configuration information. Required. + :type partner_configuration_info: IO + :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 PartnerConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, - partner_configuration_info: "_models.PartnerConfiguration", + partner_configuration_info: Union[_models.PartnerConfiguration, IO], **kwargs: Any - ) -> LROPoller["_models.PartnerConfiguration"]: + ) -> LROPoller[_models.PartnerConfiguration]: """Create or update a partner configuration. Synchronously creates or updates a partner configuration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_configuration_info: Partner configuration information. - :type partner_configuration_info: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :param partner_configuration_info: Partner configuration information. Is either a model type or + a IO type. Required. + :type partner_configuration_info: ~azure.mgmt.eventgrid.models.PartnerConfiguration 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 @@ -488,78 +505,80 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either PartnerConfiguration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_configuration_info=partner_configuration_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -569,20 +588,16 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a partner configuration. Delete existing partner configuration. :param resource_group_name: The name of the resource group within the user's subscription. + 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. @@ -594,77 +609,92 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore def _update_initial( self, resource_group_name: str, - partner_configuration_update_parameters: "_models.PartnerConfigurationUpdateParameters", + partner_configuration_update_parameters: Union[_models.PartnerConfigurationUpdateParameters, IO], **kwargs: Any - ) -> "_models.PartnerConfiguration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_configuration_update_parameters, 'PartnerConfigurationUpdateParameters') + ) -> _models.PartnerConfiguration: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_configuration_update_parameters, (IO, bytes)): + _content = partner_configuration_update_parameters + else: + _json = self._serialize.body( + partner_configuration_update_parameters, "PartnerConfigurationUpdateParameters" + ) - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -672,35 +702,41 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore - @distributed_trace + @overload def begin_update( self, resource_group_name: str, - partner_configuration_update_parameters: "_models.PartnerConfigurationUpdateParameters", + partner_configuration_update_parameters: _models.PartnerConfigurationUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PartnerConfiguration"]: + ) -> LROPoller[_models.PartnerConfiguration]: """Update a partner configuration. Synchronously updates a partner configuration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param partner_configuration_update_parameters: Partner configuration update information. + Required. :type partner_configuration_update_parameters: ~azure.mgmt.eventgrid.models.PartnerConfigurationUpdateParameters + :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 @@ -712,98 +748,172 @@ def begin_update( :return: An instance of LROPoller that returns either PartnerConfiguration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + partner_configuration_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerConfiguration]: + """Update a partner configuration. + + Synchronously updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_update_parameters: Partner configuration update information. + Required. + :type partner_configuration_update_parameters: IO + :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 PartnerConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + partner_configuration_update_parameters: Union[_models.PartnerConfigurationUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.PartnerConfiguration]: + """Update a partner configuration. + + Synchronously updates a partner configuration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_configuration_update_parameters: Partner configuration update information. Is + either a model type or a IO type. Required. + :type partner_configuration_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerConfigurationUpdateParameters 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. + :return: An instance of LROPoller that returns either PartnerConfiguration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_configuration_update_parameters=partner_configuration_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.PartnerConfigurationsListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.PartnerConfiguration"]: """List partner configurations under a resource group. List all the partner configurations under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerConfigurationsListResult or the result of + :return: An iterator like instance of either PartnerConfiguration or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerConfigurationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfigurationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfigurationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -817,10 +927,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -830,19 +938,14 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerConfigurationsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerConfiguration"]: """List partner configurations under an Azure subscription. List all the partner configurations under an Azure subscription. @@ -860,43 +963,43 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerConfigurationsListResult or the result of + :return: An iterator like instance of either PartnerConfiguration or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerConfigurationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerConfiguration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfigurationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfigurationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -910,10 +1013,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -923,134 +1024,250 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerConfigurations"} # type: ignore - @distributed_trace + @overload def authorize_partner( self, resource_group_name: str, - partner_info: "_models.Partner", + partner_info: _models.Partner, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PartnerConfiguration": + ) -> _models.PartnerConfiguration: """Authorize a partner. Authorize a single partner either by partner registration immutable Id or by partner name. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_info: The information of the partner to be authorized. + :param partner_info: The information of the partner to be authorized. Required. :type partner_info: ~azure.mgmt.eventgrid.models.Partner + :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: PartnerConfiguration, or the result of cls(response) + :return: PartnerConfiguration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def authorize_partner( + self, resource_group_name: str, partner_info: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PartnerConfiguration: + """Authorize a partner. + + Authorize a single partner either by partner registration immutable Id or by partner name. - _json = self._serialize.body(partner_info, 'Partner') + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be authorized. Required. + :type partner_info: IO + :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: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def authorize_partner( + self, resource_group_name: str, partner_info: Union[_models.Partner, IO], **kwargs: Any + ) -> _models.PartnerConfiguration: + """Authorize a partner. + + Authorize a single partner either by partner registration immutable Id or by partner name. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be authorized. Is either a model type or + a IO type. Required. + :type partner_info: ~azure.mgmt.eventgrid.models.Partner 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 + :return: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_info, (IO, bytes)): + _content = partner_info + else: + _json = self._serialize.body(partner_info, "Partner") request = build_authorize_partner_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.authorize_partner.metadata['url'], + content=_content, + template_url=self.authorize_partner.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - authorize_partner.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner"} # type: ignore + authorize_partner.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/authorizePartner"} # type: ignore - - @distributed_trace + @overload def unauthorize_partner( self, resource_group_name: str, - partner_info: "_models.Partner", + partner_info: _models.Partner, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.PartnerConfiguration": + ) -> _models.PartnerConfiguration: """Unauthorize a partner. Unauthorize a single partner either by partner registration immutable Id or by partner name. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_info: The information of the partner to be unauthorized. + :param partner_info: The information of the partner to be unauthorized. Required. :type partner_info: ~azure.mgmt.eventgrid.models.Partner + :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: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def unauthorize_partner( + self, resource_group_name: str, partner_info: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.PartnerConfiguration: + """Unauthorize a partner. + + Unauthorize a single partner either by partner registration immutable Id or by partner name. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be unauthorized. Required. + :type partner_info: IO + :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: PartnerConfiguration or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def unauthorize_partner( + self, resource_group_name: str, partner_info: Union[_models.Partner, IO], **kwargs: Any + ) -> _models.PartnerConfiguration: + """Unauthorize a partner. + + Unauthorize a single partner either by partner registration immutable Id or by partner name. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_info: The information of the partner to be unauthorized. Is either a model type + or a IO type. Required. + :type partner_info: ~azure.mgmt.eventgrid.models.Partner 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 - :return: PartnerConfiguration, or the result of cls(response) + :return: PartnerConfiguration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerConfiguration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerConfiguration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerConfiguration] - _json = self._serialize.body(partner_info, 'Partner') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_info, (IO, bytes)): + _content = partner_info + else: + _json = self._serialize.body(partner_info, "Partner") request = build_unauthorize_partner_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.unauthorize_partner.metadata['url'], + content=_content, + template_url=self.unauthorize_partner.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerConfiguration', pipeline_response) + deserialized = self._deserialize("PartnerConfiguration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - unauthorize_partner.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner"} # type: ignore - + unauthorize_partner.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerConfigurations/default/unauthorizePartner"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_namespaces_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_namespaces_operations.py index 2ade07c786df..a3fbdd91b5fb 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_namespaces_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_namespaces_operations.py @@ -6,493 +6,528 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, partner_namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, partner_namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, partner_namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerNamespaces") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_shared_access_keys_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - subscription_id: str, - resource_group_name: str, - partner_namespace_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, partner_namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerNamespaceName": _SERIALIZER.url("partner_namespace_name", partner_namespace_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class PartnerNamespacesOperations(object): - """PartnerNamespacesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PartnerNamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`partner_namespaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any - ) -> "_models.PartnerNamespace": + def get(self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any) -> _models.PartnerNamespace: """Get a partner namespace. Get properties of a partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerNamespace, or the result of cls(response) + :return: PartnerNamespace or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespace - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespace] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_info: "_models.PartnerNamespace", + partner_namespace_info: Union[_models.PartnerNamespace, IO], **kwargs: Any - ) -> "_models.PartnerNamespace": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_namespace_info, 'PartnerNamespace') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PartnerNamespace: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespace] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_namespace_info, (IO, bytes)): + _content = partner_namespace_info + else: + _json = self._serialize.body(partner_namespace_info, "PartnerNamespace") + + request = build_create_or_update_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_info: _models.PartnerNamespace, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerNamespace]: + """Create a partner namespace. + + Asynchronously creates a new partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_info: PartnerNamespace information. Required. + :type partner_namespace_info: ~azure.mgmt.eventgrid.models.PartnerNamespace + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerNamespace]: + """Create a partner namespace. + + Asynchronously creates a new partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_info: PartnerNamespace information. Required. + :type partner_namespace_info: IO + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_info: "_models.PartnerNamespace", + partner_namespace_info: Union[_models.PartnerNamespace, IO], **kwargs: Any - ) -> LROPoller["_models.PartnerNamespace"]: + ) -> LROPoller[_models.PartnerNamespace]: """Create a partner namespace. Asynchronously creates a new partner namespace with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param partner_namespace_info: PartnerNamespace information. - :type partner_namespace_info: ~azure.mgmt.eventgrid.models.PartnerNamespace + :param partner_namespace_info: PartnerNamespace information. Is either a model type or a IO + type. Required. + :type partner_namespace_info: ~azure.mgmt.eventgrid.models.PartnerNamespace 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 @@ -504,81 +539,82 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either PartnerNamespace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespace] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, partner_namespace_info=partner_namespace_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any + self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -588,23 +624,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a partner namespace. Delete existing partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_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. @@ -616,80 +647,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore def _update_initial( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_update_parameters: "_models.PartnerNamespaceUpdateParameters", + partner_namespace_update_parameters: Union[_models.PartnerNamespaceUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.PartnerNamespace"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PartnerNamespace"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_namespace_update_parameters, 'PartnerNamespaceUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.PartnerNamespace]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PartnerNamespace]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_namespace_update_parameters, (IO, bytes)): + _content = partner_namespace_update_parameters + else: + _json = self._serialize.body(partner_namespace_update_parameters, "PartnerNamespaceUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -698,35 +742,116 @@ def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_update_parameters: _models.PartnerNamespaceUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a partner namespace. + + Asynchronously updates a partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_update_parameters: Partner namespace update information. Required. + :type partner_namespace_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerNamespaceUpdateParameters + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + partner_namespace_name: str, + partner_namespace_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a partner namespace. + + Asynchronously updates a partner namespace with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param partner_namespace_update_parameters: Partner namespace update information. Required. + :type partner_namespace_update_parameters: IO + :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 PartnerNamespace or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, partner_namespace_name: str, - partner_namespace_update_parameters: "_models.PartnerNamespaceUpdateParameters", + partner_namespace_update_parameters: Union[_models.PartnerNamespaceUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.PartnerNamespace"]: + ) -> LROPoller[None]: """Update a partner namespace. Asynchronously updates a partner namespace with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param partner_namespace_update_parameters: Partner namespace update information. + :param partner_namespace_update_parameters: Partner namespace update information. Is either a + model type or a IO type. Required. :type partner_namespace_update_parameters: - ~azure.mgmt.eventgrid.models.PartnerNamespaceUpdateParameters + ~azure.mgmt.eventgrid.models.PartnerNamespaceUpdateParameters 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 @@ -738,58 +863,58 @@ def begin_update( :return: An instance of LROPoller that returns either PartnerNamespace or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerNamespace] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespace"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, partner_namespace_update_parameters=partner_namespace_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerNamespace', pipeline_response) + deserialized = self._deserialize("PartnerNamespace", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerNamespacesListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerNamespace"]: """List partner namespaces under an Azure subscription. List all the partner namespaces under an Azure subscription. @@ -807,42 +932,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerNamespacesListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespacesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespacesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespacesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -856,10 +981,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -869,25 +992,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerNamespacesListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerNamespace"]: """List partner namespaces under a resource group. List all the partner namespaces under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -902,44 +1020,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerNamespacesListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespacesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerNamespace or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerNamespace] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespacesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespacesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -953,10 +1070,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -966,135 +1081,205 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces"} # type: ignore @distributed_trace def list_shared_access_keys( - self, - resource_group_name: str, - partner_namespace_name: str, - **kwargs: Any - ) -> "_models.PartnerNamespaceSharedAccessKeys": + self, resource_group_name: str, partner_namespace_name: str, **kwargs: Any + ) -> _models.PartnerNamespaceSharedAccessKeys: """List keys for a partner namespace. List the two keys used to publish to a partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerNamespaceSharedAccessKeys, or the result of cls(response) + :return: PartnerNamespaceSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespaceSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespaceSharedAccessKeys] - request = build_list_shared_access_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_shared_access_keys.metadata['url'], + template_url=self.list_shared_access_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespaceSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("PartnerNamespaceSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_shared_access_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys"} # type: ignore + list_shared_access_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/listKeys"} # type: ignore + + @overload + def regenerate_key( + self, + resource_group_name: str, + partner_namespace_name: str, + regenerate_key_request: _models.PartnerNamespaceRegenerateKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerNamespaceSharedAccessKeys: + """Regenerate key for a partner namespace. + + Regenerate a shared access key for a partner namespace. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.PartnerNamespaceRegenerateKeyRequest + :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: PartnerNamespaceSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + partner_namespace_name: str, + regenerate_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerNamespaceSharedAccessKeys: + """Regenerate key for a partner namespace. + + Regenerate a shared access key for a partner namespace. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_namespace_name: Name of the partner namespace. Required. + :type partner_namespace_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: IO + :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: PartnerNamespaceSharedAccessKeys or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def regenerate_key( self, resource_group_name: str, partner_namespace_name: str, - regenerate_key_request: "_models.PartnerNamespaceRegenerateKeyRequest", + regenerate_key_request: Union[_models.PartnerNamespaceRegenerateKeyRequest, IO], **kwargs: Any - ) -> "_models.PartnerNamespaceSharedAccessKeys": + ) -> _models.PartnerNamespaceSharedAccessKeys: """Regenerate key for a partner namespace. Regenerate a shared access key for a partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_namespace_name: Name of the partner namespace. + :param partner_namespace_name: Name of the partner namespace. Required. :type partner_namespace_name: str - :param regenerate_key_request: Request body to regenerate key. + :param regenerate_key_request: Request body to regenerate key. Is either a model type or a IO + type. Required. :type regenerate_key_request: ~azure.mgmt.eventgrid.models.PartnerNamespaceRegenerateKeyRequest + 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 - :return: PartnerNamespaceSharedAccessKeys, or the result of cls(response) + :return: PartnerNamespaceSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerNamespaceSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerNamespaceSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerNamespaceSharedAccessKeys] - _json = self._serialize.body(regenerate_key_request, 'PartnerNamespaceRegenerateKeyRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_request, (IO, bytes)): + _content = regenerate_key_request + else: + _json = self._serialize.body(regenerate_key_request, "PartnerNamespaceRegenerateKeyRequest") request = build_regenerate_key_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_namespace_name=partner_namespace_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerNamespaceSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("PartnerNamespaceSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerNamespaces/{partnerNamespaceName}/regenerateKey"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_registrations_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_registrations_operations.py index 0bcaa54bc385..d80269d2d451 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_registrations_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_registrations_operations.py @@ -6,379 +6,353 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any + resource_group_name: str, partner_registration_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - partner_registration_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, partner_registration_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any + +def build_delete_request( + resource_group_name: str, partner_registration_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - partner_registration_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, partner_registration_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerRegistrationName": _SERIALIZER.url("partner_registration_name", partner_registration_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -class PartnerRegistrationsOperations(object): - """PartnerRegistrationsOperations operations. + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. +class PartnerRegistrationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`partner_registrations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any - ) -> "_models.PartnerRegistration": + self, resource_group_name: str, partner_registration_name: str, **kwargs: Any + ) -> _models.PartnerRegistration: """Get a partner registration. Gets a partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerRegistration, or the result of cls(response) + :return: PartnerRegistration or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerRegistration - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistration] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, partner_registration_name: str, - partner_registration_info: "_models.PartnerRegistration", + partner_registration_info: Union[_models.PartnerRegistration, IO], **kwargs: Any - ) -> "_models.PartnerRegistration": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_registration_info, 'PartnerRegistration') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PartnerRegistration: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistration] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_registration_info, (IO, bytes)): + _content = partner_registration_info + else: + _json = self._serialize.body(partner_registration_info, "PartnerRegistration") + + request = build_create_or_update_request( resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -386,37 +360,117 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_info: _models.PartnerRegistration, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerRegistration]: + """Create a partner registration. + + Creates a new partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_info: PartnerRegistration information. Required. + :type partner_registration_info: ~azure.mgmt.eventgrid.models.PartnerRegistration + :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 PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PartnerRegistration]: + """Create a partner registration. + + Creates a new partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_info: PartnerRegistration information. Required. + :type partner_registration_info: IO + :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 PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, partner_registration_name: str, - partner_registration_info: "_models.PartnerRegistration", + partner_registration_info: Union[_models.PartnerRegistration, IO], **kwargs: Any - ) -> LROPoller["_models.PartnerRegistration"]: + ) -> LROPoller[_models.PartnerRegistration]: """Create a partner registration. Creates a new partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_name: str - :param partner_registration_info: PartnerRegistration information. - :type partner_registration_info: ~azure.mgmt.eventgrid.models.PartnerRegistration + :param partner_registration_info: PartnerRegistration information. Is either a model type or a + IO type. Required. + :type partner_registration_info: ~azure.mgmt.eventgrid.models.PartnerRegistration 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 @@ -428,81 +482,82 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either PartnerRegistration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistration] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, partner_registration_info=partner_registration_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any + self, resource_group_name: str, partner_registration_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -512,23 +567,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_registration_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, partner_registration_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a partner registration. Deletes a partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_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. @@ -540,80 +590,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore def _update_initial( self, resource_group_name: str, partner_registration_name: str, - partner_registration_update_parameters: "_models.PartnerRegistrationUpdateParameters", + partner_registration_update_parameters: Union[_models.PartnerRegistrationUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.PartnerRegistration"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PartnerRegistration"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(partner_registration_update_parameters, 'PartnerRegistrationUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.PartnerRegistration]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PartnerRegistration]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_registration_update_parameters, (IO, bytes)): + _content = partner_registration_update_parameters + else: + _json = self._serialize.body(partner_registration_update_parameters, "PartnerRegistrationUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -622,35 +685,41 @@ def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore - - @distributed_trace + @overload def begin_update( self, resource_group_name: str, partner_registration_name: str, - partner_registration_update_parameters: "_models.PartnerRegistrationUpdateParameters", + partner_registration_update_parameters: _models.PartnerRegistrationUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PartnerRegistration"]: + ) -> LROPoller[None]: """Update a partner registration. Updates a partner registration with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_registration_name: Name of the partner registration. + :param partner_registration_name: Name of the partner registration. Required. :type partner_registration_name: str :param partner_registration_update_parameters: Partner registration update information. + Required. :type partner_registration_update_parameters: ~azure.mgmt.eventgrid.models.PartnerRegistrationUpdateParameters + :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 @@ -662,58 +731,135 @@ def begin_update( :return: An instance of LROPoller that returns either PartnerRegistration or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistration"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a partner registration. + + Updates a partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_update_parameters: Partner registration update information. + Required. + :type partner_registration_update_parameters: IO + :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 PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + partner_registration_name: str, + partner_registration_update_parameters: Union[_models.PartnerRegistrationUpdateParameters, IO], + **kwargs: Any + ) -> LROPoller[None]: + """Update a partner registration. + + Updates a partner registration with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_registration_name: Name of the partner registration. Required. + :type partner_registration_name: str + :param partner_registration_update_parameters: Partner registration update information. Is + either a model type or a IO type. Required. + :type partner_registration_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerRegistrationUpdateParameters 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. + :return: An instance of LROPoller that returns either PartnerRegistration or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_registration_name=partner_registration_name, partner_registration_update_parameters=partner_registration_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PartnerRegistration', pipeline_response) + deserialized = self._deserialize("PartnerRegistration", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations/{partnerRegistrationName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerRegistrationsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerRegistration"]: """List partner registrations under an Azure subscription. List all the partner registrations under an Azure subscription. @@ -731,43 +877,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerRegistrationsListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistrationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerRegistration or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistrationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistrationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -781,10 +926,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -794,25 +937,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerRegistrationsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerRegistration"]: """List partner registrations under a resource group. List all the partner registrations under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -827,45 +965,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerRegistrationsListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistrationsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerRegistration or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerRegistration] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerRegistrationsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerRegistrationsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -879,10 +1015,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -892,8 +1026,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerRegistrations"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topic_event_subscriptions_operations.py index 5733d0acd6be..71d8d520d753 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topic_event_subscriptions_operations.py @@ -6,433 +6,398 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, partner_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, partner_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, partner_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_full_url_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_partner_topic_request( - subscription_id: str, resource_group_name: str, partner_topic_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_delivery_attributes_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PartnerTopicEventSubscriptionsOperations(object): - """PartnerTopicEventSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PartnerTopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`partner_topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a partner topic. Get properties of an event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be found. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters only. + Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -440,18 +405,107 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription of a partner topic. + + Asynchronously creates or updates an event subscription of a partner topic with the specified + parameters. Existing event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription of a partner topic. + + Asynchronously creates or updates an event subscription of a partner topic with the specified + parameters. Existing event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -459,25 +513,29 @@ def begin_create_or_update( resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Create or update an event subscription of a partner topic. Asynchronously creates or updates an event subscription of a partner topic with the specified parameters. Existing event subscriptions will be updated with this API. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -489,84 +547,84 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -576,28 +634,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete an event subscription of a partner topic. Delete an existing event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -609,98 +663,197 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _update_initial( self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update event subscription of a partner topic. + + Update an existing event subscription of a partner topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + partner_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update event subscription of a partner topic. + + Update an existing event subscription of a partner topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -708,24 +861,29 @@ def begin_update( resource_group_name: str, partner_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Update event subscription of a partner topic. Update an existing event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -737,117 +895,117 @@ def begin_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace def get_full_url( - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription of a partner topic. Get the full endpoint URL for an event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list_by_partner_topic( @@ -857,14 +1015,15 @@ def list_by_partner_topic( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List event subscriptions of a partner topic. List event subscriptions that belong to a specific partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -879,46 +1038,44 @@ def list_by_partner_topic( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_partner_topic_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_partner_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_partner_topic.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_partner_topic_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - partner_topic_name=partner_topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -932,10 +1089,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -945,74 +1100,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_partner_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions"} # type: ignore + list_by_partner_topic.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions"} # type: ignore @distributed_trace def get_delivery_attributes( - self, - resource_group_name: str, - partner_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, partner_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription of a partner topic. Get all delivery attributes for an event subscription of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topics_operations.py index 2b249f091f95..5b063377f766 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_partner_topics_operations.py @@ -6,467 +6,492 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, partner_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerTopics") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_activate_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deactivate_request( - subscription_id: str, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any + resource_group_name: str, partner_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "partnerTopicName": _SERIALIZER.url("partner_topic_name", partner_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PartnerTopicsOperations(object): - """PartnerTopicsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class PartnerTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`partner_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> "_models.PartnerTopic": + def get(self, resource_group_name: str, partner_topic_name: str, **kwargs: Any) -> _models.PartnerTopic: """Get a partner topic. Get properties of a partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_info: _models.PartnerTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerTopic: + """Create a partner topic. + + Asynchronously creates a new partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_info: Partner Topic information. Required. + :type partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerTopic + :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: PartnerTopic or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PartnerTopic: + """Create a partner topic. + + Asynchronously creates a new partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_info: Partner Topic information. Required. + :type partner_topic_info: IO + :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: PartnerTopic or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( self, resource_group_name: str, partner_topic_name: str, - partner_topic_info: "_models.PartnerTopic", + partner_topic_info: Union[_models.PartnerTopic, IO], **kwargs: Any - ) -> "_models.PartnerTopic": + ) -> _models.PartnerTopic: """Create a partner topic. Asynchronously creates a new partner topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str - :param partner_topic_info: Partner Topic information. - :type partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerTopic + :param partner_topic_info: Partner Topic information. Is either a model type or a IO type. + Required. + :type partner_topic_info: ~azure.mgmt.eventgrid.models.PartnerTopic 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 - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - _json = self._serialize.body(partner_topic_info, 'PartnerTopic') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_topic_info, (IO, bytes)): + _content = partner_topic_info + else: + _json = self._serialize.body(partner_topic_info, "PartnerTopic") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -474,49 +499,46 @@ def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any + self, resource_group_name: str, partner_topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -526,23 +548,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, partner_topic_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a partner topic. Delete existing partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_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. @@ -554,97 +571,176 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, partner_topic_name: str, - partner_topic_update_parameters: "_models.PartnerTopicUpdateParameters", + partner_topic_update_parameters: _models.PartnerTopicUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> Optional["_models.PartnerTopic"]: + ) -> Optional[_models.PartnerTopic]: """Update a partner topic. Asynchronously updates a partner topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str - :param partner_topic_update_parameters: PartnerTopic update information. + :param partner_topic_update_parameters: PartnerTopic update information. Required. :type partner_topic_update_parameters: ~azure.mgmt.eventgrid.models.PartnerTopicUpdateParameters + :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: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or None or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic or None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PartnerTopic"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Optional[_models.PartnerTopic]: + """Update a partner topic. - _json = self._serialize.body(partner_topic_update_parameters, 'PartnerTopicUpdateParameters') + Asynchronously updates a partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_update_parameters: PartnerTopic update information. Required. + :type partner_topic_update_parameters: IO + :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: PartnerTopic or None or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + partner_topic_name: str, + partner_topic_update_parameters: Union[_models.PartnerTopicUpdateParameters, IO], + **kwargs: Any + ) -> Optional[_models.PartnerTopic]: + """Update a partner topic. + + Asynchronously updates a partner topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param partner_topic_name: Name of the partner topic. Required. + :type partner_topic_name: str + :param partner_topic_update_parameters: PartnerTopic update information. Is either a model type + or a IO type. Required. + :type partner_topic_update_parameters: + ~azure.mgmt.eventgrid.models.PartnerTopicUpdateParameters 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 + :return: PartnerTopic or None or the result of cls(response) + :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic or None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PartnerTopic]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(partner_topic_update_parameters, (IO, bytes)): + _content = partner_topic_update_parameters + else: + _json = self._serialize.body(partner_topic_update_parameters, "PartnerTopicUpdateParameters") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -653,23 +749,19 @@ def update( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerTopicsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerTopic"]: """List partner topics under an Azure subscription. List all the partner topics under an Azure subscription. @@ -687,42 +779,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerTopicsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -736,10 +828,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -749,25 +839,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.PartnerTopicsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.PartnerTopic"]: """List partner topics under a resource group. List all the partner topics under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -782,44 +867,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PartnerTopicsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PartnerTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PartnerTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -833,10 +917,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -846,128 +928,118 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics"} # type: ignore @distributed_trace - def activate( - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> "_models.PartnerTopic": + def activate(self, resource_group_name: str, partner_topic_name: str, **kwargs: Any) -> _models.PartnerTopic: """Activate a partner topic. Activate a newly created partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - request = build_activate_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.activate.metadata['url'], + template_url=self.activate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - activate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate"} # type: ignore - + activate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/activate"} # type: ignore @distributed_trace - def deactivate( - self, - resource_group_name: str, - partner_topic_name: str, - **kwargs: Any - ) -> "_models.PartnerTopic": + def deactivate(self, resource_group_name: str, partner_topic_name: str, **kwargs: Any) -> _models.PartnerTopic: """Deactivate a partner topic. Deactivate specific partner topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param partner_topic_name: Name of the partner topic. + :param partner_topic_name: Name of the partner topic. Required. :type partner_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PartnerTopic, or the result of cls(response) + :return: PartnerTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PartnerTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PartnerTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PartnerTopic] - request = build_deactivate_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, partner_topic_name=partner_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.deactivate.metadata['url'], + template_url=self.deactivate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PartnerTopic', pipeline_response) + deserialized = self._deserialize("PartnerTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - deactivate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate"} # type: ignore - + deactivate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/partnerTopics/{partnerTopicName}/deactivate"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_patch.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_endpoint_connections_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_endpoint_connections_operations.py index 3e4b623b28ee..7a4a0a2cce59 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_endpoint_connections_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_endpoint_connections_operations.py @@ -6,216 +6,215 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "parentType": _SERIALIZER.url("parent_type", parent_type, 'str'), - "parentName": _SERIALIZER.url("parent_name", parent_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentType": _SERIALIZER.url("parent_type", parent_type, "str"), + "parentName": _SERIALIZER.url("parent_name", parent_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, +def build_update_request( resource_group_name: str, parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "parentType": _SERIALIZER.url("parent_type", parent_type, 'str'), - "parentName": _SERIALIZER.url("parent_name", parent_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentType": _SERIALIZER.url("parent_type", parent_type, "str"), + "parentName": _SERIALIZER.url("parent_name", parent_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, +def build_delete_request( resource_group_name: str, parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "parentType": _SERIALIZER.url("parent_type", parent_type, 'str'), - "parentName": _SERIALIZER.url("parent_name", parent_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentType": _SERIALIZER.url("parent_type", parent_type, "str"), + "parentName": _SERIALIZER.url("parent_name", parent_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_list_by_resource_request( - subscription_id: str, resource_group_name: str, parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "parentType": _SERIALIZER.url("parent_type", parent_type, 'str'), - "parentName": _SERIALIZER.url("parent_name", parent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentType": _SERIALIZER.url("parent_type", parent_type, "str"), + "parentName": _SERIALIZER.url("parent_name", parent_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -225,68 +224,70 @@ def get( parent_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Get a specific private endpoint connection. Get a specific private endpoint connection under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param private_endpoint_connection_name: The name of the private endpoint connection - connection. + connection. Required. :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _update_initial( self, @@ -294,39 +295,48 @@ def _update_initial( parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.PrivateEndpointConnection: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") + + request = build_update_request( resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -334,18 +344,113 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], + parent_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update a specific private endpoint connection. + + Update a specific private endpoint connection under a topic, domain or partner namespace. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param parent_type: The type of the parent resource. This can be either \'topics\', + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. + :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType + :param parent_name: The name of the parent resource (namely, either, the topic name, domain + name, or partner namespace name). Required. + :type parent_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection + connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection object to update. Required. + :type private_endpoint_connection: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], + parent_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Update a specific private endpoint connection. + + Update a specific private endpoint connection under a topic, domain or partner namespace. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param parent_type: The type of the parent resource. This can be either \'topics\', + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. + :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType + :param parent_name: The name of the parent resource (namely, either, the topic name, domain + name, or partner namespace name). Required. + :type parent_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection + connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection object to update. Required. + :type private_endpoint_connection: IO + :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 PrivateEndpointConnection or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -354,26 +459,32 @@ def begin_update( parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], parent_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Update a specific private endpoint connection. Update a specific private endpoint connection under a topic, domain or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param private_endpoint_connection_name: The name of the private endpoint connection - connection. + connection. Required. :type private_endpoint_connection_name: str - :param private_endpoint_connection: The private endpoint connection object to update. - :type private_endpoint_connection: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection + :param private_endpoint_connection: The private endpoint connection object to update. Is either + a model type or a IO type. Required. + :type private_endpoint_connection: ~azure.mgmt.eventgrid.models.PrivateEndpointConnection 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 @@ -385,19 +496,19 @@ def begin_update( :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, @@ -405,32 +516,35 @@ def begin_update( private_endpoint_connection=private_endpoint_connection, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements self, @@ -440,32 +554,33 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements private_endpoint_connection_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -475,11 +590,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements + def begin_delete( self, resource_group_name: str, parent_type: Union[str, "_models.PrivateEndpointConnectionsParentType"], @@ -492,15 +606,17 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Delete a specific private endpoint connection under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param private_endpoint_connection_name: The name of the private endpoint connection - connection. + connection. Required. :type private_endpoint_connection_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. @@ -512,46 +628,50 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_endpoint_connection_name=private_endpoint_connection_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def list_by_resource( @@ -562,18 +682,20 @@ def list_by_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable["_models.PrivateEndpointConnection"]: """Lists all private endpoint connections under a resource. Get all private endpoint connections under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Known values are: "topics", "domains", and + "partnerNamespaces". Required. :type parent_type: str or ~azure.mgmt.eventgrid.models.PrivateEndpointConnectionsParentType :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -588,49 +710,46 @@ def list_by_resource( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result - of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - parent_type=parent_type, - parent_name=parent_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -644,10 +763,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -657,8 +774,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections"} # type: ignore + list_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateEndpointConnections"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_link_resources_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_link_resources_operations.py index 85faf1213ff0..1ee36cb0699c 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_link_resources_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_private_link_resources_operations.py @@ -7,130 +7,133 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import 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 .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, resource_group_name: str, parent_type: str, parent_name: str, private_link_resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources/{privateLinkResourceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources/{privateLinkResourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "parentType": _SERIALIZER.url("parent_type", parent_type, 'str'), - "parentName": _SERIALIZER.url("parent_name", parent_name, 'str'), - "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentType": _SERIALIZER.url("parent_type", parent_type, "str"), + "parentName": _SERIALIZER.url("parent_name", parent_name, "str"), + "privateLinkResourceName": _SERIALIZER.url("private_link_resource_name", private_link_resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_request( - subscription_id: str, resource_group_name: str, parent_type: str, parent_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "parentType": _SERIALIZER.url("parent_type", parent_type, 'str'), - "parentName": _SERIALIZER.url("parent_name", parent_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "parentType": _SERIALIZER.url("parent_type", parent_type, "str"), + "parentName": _SERIALIZER.url("parent_name", parent_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -140,67 +143,68 @@ def get( parent_name: str, private_link_resource_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResource": + ) -> _models.PrivateLinkResource: """Get a private link resource. Get properties of a private link resource. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Required. :type parent_type: str :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str - :param private_link_resource_name: The name of private link resource. + :param private_link_resource_name: The name of private link resource. Required. :type private_link_resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResource, or the result of cls(response) + :return: PrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.PrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResource"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, private_link_resource_name=private_link_resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResource', pipeline_response) + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources/{privateLinkResourceName}"} # type: ignore @distributed_trace def list_by_resource( @@ -211,18 +215,19 @@ def list_by_resource( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourcesListResult"]: + ) -> Iterable["_models.PrivateLinkResource"]: """List private link resources under specific topic, domain, or partner namespace. List all the private link resources under a topic, domain, or partner namespace. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param parent_type: The type of the parent resource. This can be either \'topics\', - \'domains\', or \'partnerNamespaces\'. + \'domains\', or \'partnerNamespaces\'. Required. :type parent_type: str :param parent_name: The name of the parent resource (namely, either, the topic name, domain - name, or partner namespace name). + name, or partner namespace name). Required. :type parent_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -237,49 +242,45 @@ def list_by_resource( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourcesListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PrivateLinkResourcesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourcesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourcesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, parent_type=parent_type, parent_name=parent_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - parent_type=parent_type, - parent_name=parent_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -293,10 +294,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -306,8 +305,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources"} # type: ignore + list_by_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/{parentType}/{parentName}/privateLinkResources"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topic_event_subscriptions_operations.py index 55bb30e1d363..dc82c91e68ed 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topic_event_subscriptions_operations.py @@ -6,449 +6,502 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, system_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, system_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, system_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, system_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_full_url_request( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, system_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_system_topic_request( - subscription_id: str, resource_group_name: str, system_topic_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_delivery_attributes_request( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, system_topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SystemTopicEventSubscriptionsOperations(object): - """SystemTopicEventSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class SystemTopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`system_topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a system topic. Get an event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription for a system topic. + + Asynchronously creates or updates an event subscription with the specified parameters. Existing + event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription for a system topic. + + Asynchronously creates or updates an event subscription with the specified parameters. Existing + event subscriptions will be updated with this API. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -456,25 +509,29 @@ def begin_create_or_update( resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Create or update an event subscription for a system topic. Asynchronously creates or updates an event subscription with the specified parameters. Existing event subscriptions will be updated with this API. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -486,84 +543,84 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -573,28 +630,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete an event subscription of a system topic. Delete an existing event subscription of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -606,98 +659,197 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _update_initial( self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + @overload + def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update event subscription of a system topic. + + Update an existing event subscription of a system topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update event subscription of a system topic. + + Update an existing event subscription of a system topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -705,24 +857,29 @@ def begin_update( resource_group_name: str, system_topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Update event subscription of a system topic. Update an existing event subscription of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -734,117 +891,117 @@ def begin_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace def get_full_url( - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription of a system topic. Get the full endpoint URL for an event subscription of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list_by_system_topic( @@ -854,14 +1011,15 @@ def list_by_system_topic( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List event subscriptions of a system topic. List event subscriptions that belong to a specific system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -876,46 +1034,44 @@ def list_by_system_topic( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_system_topic_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_system_topic.metadata['url'], + api_version=api_version, + template_url=self.list_by_system_topic.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_system_topic_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - system_topic_name=system_topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -929,10 +1085,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -942,74 +1096,69 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_system_topic.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions"} # type: ignore + list_by_system_topic.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions"} # type: ignore @distributed_trace def get_delivery_attributes( - self, - resource_group_name: str, - system_topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, system_topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription. Get all delivery attributes for an event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topics_operations.py index edbbac027289..0233c3303102 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_system_topics_operations.py @@ -6,379 +6,349 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any + resource_group_name: str, system_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, system_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, system_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - system_topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, system_topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "systemTopicName": _SERIALIZER.url("system_topic_name", system_topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/systemTopics") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class SystemTopicsOperations(object): - """SystemTopicsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SystemTopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`system_topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any - ) -> "_models.SystemTopic": + def get(self, resource_group_name: str, system_topic_name: str, **kwargs: Any) -> _models.SystemTopic: """Get a system topic. Get properties of a system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SystemTopic, or the result of cls(response) + :return: SystemTopic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.SystemTopic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, system_topic_name: str, - system_topic_info: "_models.SystemTopic", + system_topic_info: Union[_models.SystemTopic, IO], **kwargs: Any - ) -> "_models.SystemTopic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(system_topic_info, 'SystemTopic') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.SystemTopic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(system_topic_info, (IO, bytes)): + _content = system_topic_info + else: + _json = self._serialize.body(system_topic_info, "SystemTopic") + + request = build_create_or_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -386,37 +356,117 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_info: _models.SystemTopic, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SystemTopic]: + """Create a system topic. + + Asynchronously creates a new system topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_info: System Topic information. Required. + :type system_topic_info: ~azure.mgmt.eventgrid.models.SystemTopic + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SystemTopic]: + """Create a system topic. + + Asynchronously creates a new system topic with the specified parameters. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_info: System Topic information. Required. + :type system_topic_info: IO + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, system_topic_name: str, - system_topic_info: "_models.SystemTopic", + system_topic_info: Union[_models.SystemTopic, IO], **kwargs: Any - ) -> LROPoller["_models.SystemTopic"]: + ) -> LROPoller[_models.SystemTopic]: """Create a system topic. Asynchronously creates a new system topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str - :param system_topic_info: System Topic information. - :type system_topic_info: ~azure.mgmt.eventgrid.models.SystemTopic + :param system_topic_info: System Topic information. Is either a model type or a IO type. + Required. + :type system_topic_info: ~azure.mgmt.eventgrid.models.SystemTopic 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 @@ -428,81 +478,82 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SystemTopic or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.SystemTopic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, system_topic_info=system_topic_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any + self, resource_group_name: str, system_topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -512,23 +563,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - system_topic_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, system_topic_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a system topic. Delete existing system topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_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. @@ -540,80 +586,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore def _update_initial( self, resource_group_name: str, system_topic_name: str, - system_topic_update_parameters: "_models.SystemTopicUpdateParameters", + system_topic_update_parameters: Union[_models.SystemTopicUpdateParameters, IO], **kwargs: Any - ) -> "_models.SystemTopic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(system_topic_update_parameters, 'SystemTopicUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.SystemTopic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(system_topic_update_parameters, (IO, bytes)): + _content = system_topic_update_parameters + else: + _json = self._serialize.body(system_topic_update_parameters, "SystemTopicUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, system_topic_name=system_topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -621,37 +680,118 @@ def _update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_update_parameters: _models.SystemTopicUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SystemTopic]: + """Update a system topic. + + Asynchronously updates a system topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_update_parameters: SystemTopic update information. Required. + :type system_topic_update_parameters: ~azure.mgmt.eventgrid.models.SystemTopicUpdateParameters + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_update( + self, + resource_group_name: str, + system_topic_name: str, + system_topic_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SystemTopic]: + """Update a system topic. + + Asynchronously updates a system topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param system_topic_name: Name of the system topic. Required. + :type system_topic_name: str + :param system_topic_update_parameters: SystemTopic update information. Required. + :type system_topic_update_parameters: IO + :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 SystemTopic or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, system_topic_name: str, - system_topic_update_parameters: "_models.SystemTopicUpdateParameters", + system_topic_update_parameters: Union[_models.SystemTopicUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.SystemTopic"]: + ) -> LROPoller[_models.SystemTopic]: """Update a system topic. Asynchronously updates a system topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param system_topic_name: Name of the system topic. + :param system_topic_name: Name of the system topic. Required. :type system_topic_name: str - :param system_topic_update_parameters: SystemTopic update information. + :param system_topic_update_parameters: SystemTopic update information. Is either a model type + or a IO type. Required. :type system_topic_update_parameters: ~azure.mgmt.eventgrid.models.SystemTopicUpdateParameters + 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 @@ -663,58 +803,58 @@ def begin_update( :return: An instance of LROPoller that returns either SystemTopic or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.SystemTopic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopic] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, system_topic_name=system_topic_name, system_topic_update_parameters=system_topic_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SystemTopic', pipeline_response) + deserialized = self._deserialize("SystemTopic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics/{systemTopicName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.SystemTopicsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.SystemTopic"]: """List system topics under an Azure subscription. List all the system topics under an Azure subscription. @@ -732,42 +872,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SystemTopicsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.SystemTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SystemTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -781,10 +921,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -794,25 +932,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.SystemTopicsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.SystemTopic"]: """List system topics under a resource group. List all the system topics under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -827,44 +960,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SystemTopicsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.SystemTopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SystemTopic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.SystemTopic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SystemTopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.SystemTopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -878,10 +1010,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -891,8 +1021,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/systemTopics"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_event_subscriptions_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_event_subscriptions_operations.py index 269a22aadb3c..585a5e71ba6b 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_event_subscriptions_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_event_subscriptions_operations.py @@ -6,497 +6,459 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_delivery_attributes_request( - subscription_id: str, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_full_url_request( - subscription_id: str, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + resource_group_name: str, topic_name: str, event_subscription_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), - "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), + "eventSubscriptionName": _SERIALIZER.url("event_subscription_name", event_subscription_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, resource_group_name: str, topic_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TopicEventSubscriptionsOperations(object): - """TopicEventSubscriptionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TopicEventSubscriptionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`topic_event_subscriptions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_delivery_attributes( - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.DeliveryAttributeListResult": + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.DeliveryAttributeListResult: """Get delivery attributes for an event subscription for topic. Get all delivery attributes for an event subscription for topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeliveryAttributeListResult, or the result of cls(response) + :return: DeliveryAttributeListResult or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.DeliveryAttributeListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeliveryAttributeListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeliveryAttributeListResult] - request = build_get_delivery_attributes_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_delivery_attributes.metadata['url'], + template_url=self.get_delivery_attributes.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeliveryAttributeListResult', pipeline_response) + deserialized = self._deserialize("DeliveryAttributeListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_delivery_attributes.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore - + get_delivery_attributes.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getDeliveryAttributes"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscription": + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscription: """Get an event subscription of a topic. Get properties of an event subscription of a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the partner topic. + :param topic_name: Name of the partner topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be found. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters only. + Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscription, or the result of cls(response) + :return: EventSubscription or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_info, 'EventSubscription') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_info, (IO, bytes)): + _content = event_subscription_info + else: + _json = self._serialize.body(event_subscription_info, "EventSubscription") + + request = build_create_or_update_request( resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -504,18 +466,105 @@ def _create_or_update_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: _models.EventSubscription, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription to a topic. + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Create or update an event subscription to a topic. + + Asynchronously creates a new event subscription or updates an existing event subscription. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain topic. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be created. Event + subscription names must be between 3 and 100 characters in length and use alphanumeric letters + only. Required. + :type event_subscription_name: str + :param event_subscription_info: Event subscription properties containing the destination and + filter information. Required. + :type event_subscription_info: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -523,24 +572,28 @@ def begin_create_or_update( resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_info: "_models.EventSubscription", + event_subscription_info: Union[_models.EventSubscription, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Create or update an event subscription to a topic. Asynchronously creates a new event subscription or updates an existing event subscription. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be created. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_name: str :param event_subscription_info: Event subscription properties containing the destination and - filter information. - :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription + filter information. Is either a model type or a IO type. Required. + :type event_subscription_info: ~azure.mgmt.eventgrid.models.EventSubscription 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 @@ -552,84 +605,84 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, event_subscription_info=event_subscription_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: @@ -639,28 +692,24 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete an event subscription for a topic. Delete an existing event subscription for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :param event_subscription_name: Name of the event subscription to be deleted. Event subscription names must be between 3 and 100 characters in length and use alphanumeric letters - only. + only. Required. :type event_subscription_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. @@ -672,98 +721,193 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore def _update_initial( self, resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> "_models.EventSubscription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(event_subscription_update_parameters, 'EventSubscriptionUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> _models.EventSubscription: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(event_subscription_update_parameters, (IO, bytes)): + _content = event_subscription_update_parameters + else: + _json = self._serialize.body(event_subscription_update_parameters, "EventSubscriptionUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: _models.EventSubscriptionUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update an event subscription for a topic. + + Update an existing event subscription for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + topic_name: str, + event_subscription_name: str, + event_subscription_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EventSubscription]: + """Update an event subscription for a topic. + Update an existing event subscription for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the domain. Required. + :type topic_name: str + :param event_subscription_name: Name of the event subscription to be updated. Required. + :type event_subscription_name: str + :param event_subscription_update_parameters: Updated event subscription information. Required. + :type event_subscription_update_parameters: IO + :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 EventSubscription or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( @@ -771,22 +915,27 @@ def begin_update( resource_group_name: str, topic_name: str, event_subscription_name: str, - event_subscription_update_parameters: "_models.EventSubscriptionUpdateParameters", + event_subscription_update_parameters: Union[_models.EventSubscriptionUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.EventSubscription"]: + ) -> LROPoller[_models.EventSubscription]: """Update an event subscription for a topic. Update an existing event subscription for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain. + :param topic_name: Name of the domain. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription to be updated. + :param event_subscription_name: Name of the event subscription to be updated. Required. :type event_subscription_name: str - :param event_subscription_update_parameters: Updated event subscription information. + :param event_subscription_update_parameters: Updated event subscription information. Is either + a model type or a IO type. Required. :type event_subscription_update_parameters: - ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters + ~azure.mgmt.eventgrid.models.EventSubscriptionUpdateParameters 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 @@ -798,115 +947,115 @@ def begin_update( :return: An instance of LROPoller that returns either EventSubscription or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.EventSubscription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, event_subscription_update_parameters=event_subscription_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EventSubscription', pipeline_response) + deserialized = self._deserialize("EventSubscription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}"} # type: ignore @distributed_trace def get_full_url( - self, - resource_group_name: str, - topic_name: str, - event_subscription_name: str, - **kwargs: Any - ) -> "_models.EventSubscriptionFullUrl": + self, resource_group_name: str, topic_name: str, event_subscription_name: str, **kwargs: Any + ) -> _models.EventSubscriptionFullUrl: """Get full URL of an event subscription for topic. Get the full endpoint URL for an event subscription for topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the domain topic. + :param topic_name: Name of the domain topic. Required. :type topic_name: str - :param event_subscription_name: Name of the event subscription. + :param event_subscription_name: Name of the event subscription. Required. :type event_subscription_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EventSubscriptionFullUrl, or the result of cls(response) + :return: EventSubscriptionFullUrl or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.EventSubscriptionFullUrl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionFullUrl"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionFullUrl] - request = build_get_full_url_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, event_subscription_name=event_subscription_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_full_url.metadata['url'], + template_url=self.get_full_url.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('EventSubscriptionFullUrl', pipeline_response) + deserialized = self._deserialize("EventSubscriptionFullUrl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_full_url.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore - + get_full_url.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions/{eventSubscriptionName}/getFullUrl"} # type: ignore @distributed_trace def list( @@ -916,14 +1065,15 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any - ) -> Iterable["_models.EventSubscriptionsListResult"]: + ) -> Iterable["_models.EventSubscription"]: """List all event subscriptions for a specific topic. List all event subscriptions that have been created for a specific topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -938,46 +1088,44 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventSubscriptionsListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscriptionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventSubscription or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventSubscription] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventSubscriptionsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventSubscriptionsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - topic_name=topic_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -991,10 +1139,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1004,8 +1150,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/eventSubscriptions"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_types_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_types_operations.py index e303f7944529..729361c3c61f 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_types_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topic_types_operations.py @@ -7,176 +7,160 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import 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 .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.EventGrid/topicTypes") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) +def build_get_request(topic_type_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -def build_get_request( - topic_type_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}") path_format_arguments = { - "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, 'str'), + "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_event_types_request( - topic_type_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str +def build_list_event_types_request(topic_type_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventTypes") path_format_arguments = { - "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, 'str'), + "topicTypeName": _SERIALIZER.url("topic_type_name", topic_type_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TopicTypesOperations(object): - """TopicTypesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TopicTypesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`topic_types` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.TopicTypesListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.TopicTypeInfo"]: """List topic types. List all registered topic types. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicTypesListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.TopicTypesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either TopicTypeInfo or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.TopicTypeInfo] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicTypesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicTypesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -190,10 +174,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -203,112 +185,104 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.EventGrid/topicTypes"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.EventGrid/topicTypes"} # type: ignore @distributed_trace - def get( - self, - topic_type_name: str, - **kwargs: Any - ) -> "_models.TopicTypeInfo": + def get(self, topic_type_name: str, **kwargs: Any) -> _models.TopicTypeInfo: """Get a topic type. Get information about a topic type. - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicTypeInfo, or the result of cls(response) + :return: TopicTypeInfo or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.TopicTypeInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicTypeInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicTypeInfo] - request = build_get_request( topic_type_name=topic_type_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicTypeInfo', pipeline_response) + deserialized = self._deserialize("TopicTypeInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}"} # type: ignore @distributed_trace - def list_event_types( - self, - topic_type_name: str, - **kwargs: Any - ) -> Iterable["_models.EventTypesListResult"]: + def list_event_types(self, topic_type_name: str, **kwargs: Any) -> Iterable["_models.EventType"]: """List event types. List event types for a topic type. - :param topic_type_name: Name of the topic type. + :param topic_type_name: Name of the topic type. Required. :type topic_type_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventTypesListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventTypesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventType or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventType] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventTypesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventTypesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_event_types_request( topic_type_name=topic_type_name, api_version=api_version, - template_url=self.list_event_types.metadata['url'], + template_url=self.list_event_types.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_types_request( - topic_type_name=topic_type_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -322,10 +296,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -335,8 +307,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_types.metadata = {'url': "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventTypes"} # type: ignore + list_event_types.metadata = {"url": "/providers/Microsoft.EventGrid/topicTypes/{topicTypeName}/eventTypes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topics_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topics_operations.py index a45dab0f9d2c..370e79f53500 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topics_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_topics_operations.py @@ -6,533 +6,481 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import 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 azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - subscription_id: str, - resource_group_name: str, - topic_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_request(resource_group_name: str, topic_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str +def build_delete_request(resource_group_name: str, topic_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] +def build_update_request(resource_group_name: str, topic_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_subscription_request( - subscription_id: str, - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topics") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_by_resource_group_request( - subscription_id: str, resource_group_name: str, + subscription_id: str, *, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_shared_access_keys_request( - subscription_id: str, - resource_group_name: str, - topic_name: str, - **kwargs: Any + resource_group_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_regenerate_key_request_initial( - subscription_id: str, - resource_group_name: str, - topic_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_regenerate_key_request( + resource_group_name: str, topic_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "topicName": _SERIALIZER.url("topic_name", topic_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "topicName": _SERIALIZER.url("topic_name", topic_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_event_types_request( - subscription_id: str, resource_group_name: str, provider_namespace: str, resource_type_name: str, resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, 'str'), - "resourceTypeName": _SERIALIZER.url("resource_type_name", resource_type_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "providerNamespace": _SERIALIZER.url("provider_namespace", provider_namespace, "str"), + "resourceTypeName": _SERIALIZER.url("resource_type_name", resource_type_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class TopicsOperations(object): - """TopicsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class TopicsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`topics` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any - ) -> "_models.Topic": + def get(self, resource_group_name: str, topic_name: str, **kwargs: Any) -> _models.Topic: """Get a topic. Get properties of a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Topic, or the result of cls(response) + :return: Topic or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.Topic - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Topic] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore def _create_or_update_initial( - self, - resource_group_name: str, - topic_name: str, - topic_info: "_models.Topic", - **kwargs: Any - ) -> "_models.Topic": - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(topic_info, 'Topic') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + self, resource_group_name: str, topic_name: str, topic_info: Union[_models.Topic, IO], **kwargs: Any + ) -> _models.Topic: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Topic] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(topic_info, (IO, bytes)): + _content = topic_info + else: + _json = self._serialize.body(topic_info, "Topic") + + request = build_create_or_update_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, topic_name: str, - topic_info: "_models.Topic", + topic_info: _models.Topic, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.Topic"]: + ) -> LROPoller[_models.Topic]: """Create a topic. Asynchronously creates a new topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param topic_info: Topic information. + :param topic_info: Topic information. Required. :type topic_info: ~azure.mgmt.eventgrid.models.Topic + :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 @@ -543,81 +491,150 @@ def begin_create_or_update( Retry-After header is present. :return: An instance of LROPoller that returns either Topic or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Topic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + topic_name: str, + topic_info: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Topic]: + """Create a topic. + + Asynchronously creates a new topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_info: Topic information. Required. + :type topic_info: IO + :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 Topic or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, resource_group_name: str, topic_name: str, topic_info: Union[_models.Topic, IO], **kwargs: Any + ) -> LROPoller[_models.Topic]: + """Create a topic. + + Asynchronously creates a new topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_info: Topic information. Is either a model type or a IO type. Required. + :type topic_info: ~azure.mgmt.eventgrid.models.Topic 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. + :return: An instance of LROPoller that returns either Topic or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Topic] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, topic_info=topic_info, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any + self, resource_group_name: str, topic_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202, 204]: @@ -627,23 +644,18 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, topic_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a topic. Delete existing topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_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. @@ -655,80 +667,93 @@ def begin_delete( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore def _update_initial( self, resource_group_name: str, topic_name: str, - topic_update_parameters: "_models.TopicUpdateParameters", + topic_update_parameters: Union[_models.TopicUpdateParameters, IO], **kwargs: Any - ) -> Optional["_models.Topic"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Topic"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(topic_update_parameters, 'TopicUpdateParameters') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.Topic]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.Topic]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(topic_update_parameters, (IO, bytes)): + _content = topic_update_parameters + else: + _json = self._serialize.body(topic_update_parameters, "TopicUpdateParameters") + + request = build_update_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -737,34 +762,112 @@ def _update_initial( deserialized = None if response.status_code == 201: - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + topic_name: str, + topic_update_parameters: _models.TopicUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a topic. + + Asynchronously updates a topic with the specified parameters. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_update_parameters: Topic update information. Required. + :type topic_update_parameters: ~azure.mgmt.eventgrid.models.TopicUpdateParameters + :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 Topic or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + topic_name: str, + topic_update_parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update a topic. + + Asynchronously updates a topic with the specified parameters. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param topic_update_parameters: Topic update information. Required. + :type topic_update_parameters: IO + :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 Topic or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, topic_name: str, - topic_update_parameters: "_models.TopicUpdateParameters", + topic_update_parameters: Union[_models.TopicUpdateParameters, IO], **kwargs: Any - ) -> LROPoller["_models.Topic"]: + ) -> LROPoller[None]: """Update a topic. Asynchronously updates a topic with the specified parameters. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param topic_update_parameters: Topic update information. - :type topic_update_parameters: ~azure.mgmt.eventgrid.models.TopicUpdateParameters + :param topic_update_parameters: Topic update information. Is either a model type or a IO type. + Required. + :type topic_update_parameters: ~azure.mgmt.eventgrid.models.TopicUpdateParameters 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 @@ -775,58 +878,58 @@ def begin_update( Retry-After header is present. :return: An instance of LROPoller that returns either Topic or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.Topic] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.Topic"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, topic_update_parameters=topic_update_parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('Topic', pipeline_response) + deserialized = self._deserialize("Topic", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}"} # type: ignore @distributed_trace def list_by_subscription( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.TopicsListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.Topic"]: """List topics under an Azure subscription. List all the topics under an Azure subscription. @@ -844,41 +947,42 @@ def list_by_subscription( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.TopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Topic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - api_version=api_version, filter=filter, top=top, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -892,10 +996,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -905,25 +1007,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topics"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.EventGrid/topics"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.TopicsListResult"]: + self, resource_group_name: str, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.Topic"]: """List topics under a resource group. List all the topics under a resource group. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param filter: The query used to filter the search results using OData syntax. Filtering is permitted on the 'name' property only and with limited number of OData operations. These @@ -938,43 +1035,43 @@ def list_by_resource_group( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TopicsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.TopicsListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Topic or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.Topic] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicsListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicsListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, top=top, - template_url=self.list_by_resource_group.metadata['url'], + api_version=api_version, + template_url=self.list_by_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) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -988,10 +1085,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1001,107 +1096,112 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics"} # type: ignore @distributed_trace def list_shared_access_keys( - self, - resource_group_name: str, - topic_name: str, - **kwargs: Any - ) -> "_models.TopicSharedAccessKeys": + self, resource_group_name: str, topic_name: str, **kwargs: Any + ) -> _models.TopicSharedAccessKeys: """List keys for a topic. List the two keys used to publish to a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TopicSharedAccessKeys, or the result of cls(response) + :return: TopicSharedAccessKeys or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.TopicSharedAccessKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicSharedAccessKeys"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicSharedAccessKeys] - request = build_list_shared_access_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_shared_access_keys.metadata['url'], + template_url=self.list_shared_access_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TopicSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("TopicSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_shared_access_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys"} # type: ignore - + list_shared_access_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/listKeys"} # type: ignore def _regenerate_key_initial( self, resource_group_name: str, topic_name: str, - regenerate_key_request: "_models.TopicRegenerateKeyRequest", + regenerate_key_request: Union[_models.TopicRegenerateKeyRequest, IO], **kwargs: Any - ) -> Optional["_models.TopicSharedAccessKeys"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.TopicSharedAccessKeys"]] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(regenerate_key_request, 'TopicRegenerateKeyRequest') - - request = build_regenerate_key_request_initial( - subscription_id=self._config.subscription_id, + ) -> Optional[_models.TopicSharedAccessKeys]: + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TopicSharedAccessKeys]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key_request, (IO, bytes)): + _content = regenerate_key_request + else: + _json = self._serialize.body(regenerate_key_request, "TopicRegenerateKeyRequest") + + request = build_regenerate_key_request( resource_group_name=resource_group_name, topic_name=topic_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._regenerate_key_initial.metadata['url'], + content=_content, + template_url=self._regenerate_key_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) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1110,34 +1210,114 @@ def _regenerate_key_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('TopicSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("TopicSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _regenerate_key_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore + _regenerate_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + topic_name: str, + regenerate_key_request: _models.TopicRegenerateKeyRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TopicSharedAccessKeys]: + """Regenerate key for a topic. + + Regenerate a shared access key for a topic. + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.TopicRegenerateKeyRequest + :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 TopicSharedAccessKeys or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.TopicSharedAccessKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + topic_name: str, + regenerate_key_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.TopicSharedAccessKeys]: + """Regenerate key for a topic. + + Regenerate a shared access key for a topic. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param topic_name: Name of the topic. Required. + :type topic_name: str + :param regenerate_key_request: Request body to regenerate key. Required. + :type regenerate_key_request: IO + :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 TopicSharedAccessKeys or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.TopicSharedAccessKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_regenerate_key( self, resource_group_name: str, topic_name: str, - regenerate_key_request: "_models.TopicRegenerateKeyRequest", + regenerate_key_request: Union[_models.TopicRegenerateKeyRequest, IO], **kwargs: Any - ) -> LROPoller["_models.TopicSharedAccessKeys"]: + ) -> LROPoller[_models.TopicSharedAccessKeys]: """Regenerate key for a topic. Regenerate a shared access key for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param topic_name: Name of the topic. + :param topic_name: Name of the topic. Required. :type topic_name: str - :param regenerate_key_request: Request body to regenerate key. - :type regenerate_key_request: ~azure.mgmt.eventgrid.models.TopicRegenerateKeyRequest + :param regenerate_key_request: Request body to regenerate key. Is either a model type or a IO + type. Required. + :type regenerate_key_request: ~azure.mgmt.eventgrid.models.TopicRegenerateKeyRequest 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 @@ -1149,50 +1329,53 @@ def begin_regenerate_key( :return: An instance of LROPoller that returns either TopicSharedAccessKeys or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.eventgrid.models.TopicSharedAccessKeys] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.TopicSharedAccessKeys"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopicSharedAccessKeys] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._regenerate_key_initial( + raw_result = self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, topic_name=topic_name, regenerate_key_request=regenerate_key_request, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('TopicSharedAccessKeys', pipeline_response) + deserialized = self._deserialize("TopicSharedAccessKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore + begin_regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/topics/{topicName}/regenerateKey"} # type: ignore @distributed_trace def list_event_types( @@ -1202,60 +1385,59 @@ def list_event_types( resource_type_name: str, resource_name: str, **kwargs: Any - ) -> Iterable["_models.EventTypesListResult"]: + ) -> Iterable["_models.EventType"]: """List topic event types. List event types for a topic. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str - :param provider_namespace: Namespace of the provider of the topic. + :param provider_namespace: Namespace of the provider of the topic. Required. :type provider_namespace: str - :param resource_type_name: Name of the topic type. + :param resource_type_name: Name of the topic type. Required. :type resource_type_name: str - :param resource_name: Name of the topic. + :param resource_name: Name of the topic. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventTypesListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventTypesListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EventType or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.EventType] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EventTypesListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.EventTypesListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_event_types_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provider_namespace=provider_namespace, resource_type_name=resource_type_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_event_types.metadata['url'], + template_url=self.list_event_types.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_event_types_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - provider_namespace=provider_namespace, - resource_type_name=resource_type_name, - resource_name=resource_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1269,10 +1451,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1282,8 +1462,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_event_types.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes"} # type: ignore + list_event_types.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}/providers/Microsoft.EventGrid/eventTypes"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_verified_partners_operations.py b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_verified_partners_operations.py index cca408b71fdb..155e8e163c31 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_verified_partners_operations.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/azure/mgmt/eventgrid/operations/_verified_partners_operations.py @@ -7,173 +7,155 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import 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 .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_get_request( - verified_partner_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - accept = "application/json" +def build_get_request(verified_partner_name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.EventGrid/verifiedPartners/{verifiedPartnerName}") path_format_arguments = { - "verifiedPartnerName": _SERIALIZER.url("verified_partner_name", verified_partner_name, 'str'), + "verifiedPartnerName": _SERIALIZER.url("verified_partner_name", verified_partner_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_request( - *, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-06-15") # type: str - - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(*, filter: Optional[str] = None, 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-15")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.EventGrid/verifiedPartners") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + _params["$top"] = _SERIALIZER.query("top", top, "int") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class VerifiedPartnersOperations(object): - """VerifiedPartnersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.eventgrid.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class VerifiedPartnersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.eventgrid.EventGridManagementClient`'s + :attr:`verified_partners` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get( - self, - verified_partner_name: str, - **kwargs: Any - ) -> "_models.VerifiedPartner": + def get(self, verified_partner_name: str, **kwargs: Any) -> _models.VerifiedPartner: """Get a verified partner. Get properties of a verified partner. - :param verified_partner_name: Name of the verified partner. + :param verified_partner_name: Name of the verified partner. Required. :type verified_partner_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VerifiedPartner, or the result of cls(response) + :return: VerifiedPartner or the result of cls(response) :rtype: ~azure.mgmt.eventgrid.models.VerifiedPartner - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VerifiedPartner"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VerifiedPartner] - request = build_get_request( verified_partner_name=verified_partner_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('VerifiedPartner', pipeline_response) + deserialized = self._deserialize("VerifiedPartner", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.EventGrid/verifiedPartners/{verifiedPartnerName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.EventGrid/verifiedPartners/{verifiedPartnerName}"} # type: ignore @distributed_trace def list( - self, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> Iterable["_models.VerifiedPartnersListResult"]: + self, filter: Optional[str] = None, top: Optional[int] = None, **kwargs: Any + ) -> Iterable["_models.VerifiedPartner"]: """List all verified partners. Get a list of all verified partners. @@ -191,40 +173,41 @@ def list( items per page. Default value is None. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VerifiedPartnersListResult or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.VerifiedPartnersListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either VerifiedPartner or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.eventgrid.models.VerifiedPartner] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-06-15") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.VerifiedPartnersListResult] + + error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} + error_map.update(kwargs.pop("error_map", {}) or {}) - cls = kwargs.pop('cls', None) # type: ClsType["_models.VerifiedPartnersListResult"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - api_version=api_version, filter=filter, top=top, - template_url=self.list.metadata['url'], + 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) # type: ignore else: - - request = build_list_request( - api_version=api_version, - filter=filter, - top=top, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -238,10 +221,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -251,8 +232,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.EventGrid/verifiedPartners"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.EventGrid/verifiedPartners"} # type: ignore diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/setup.py b/sdk/eventgrid/azure-mgmt-eventgrid/setup.py index ba927db8e502..1b5d368bf40f 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/setup.py +++ b/sdk/eventgrid/azure-mgmt-eventgrid/setup.py @@ -69,9 +69,9 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'msrest>=0.6.21', + 'msrest>=0.7.1', 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.1,<2.0.0', + 'azure-mgmt-core>=1.3.2,<2.0.0', ], python_requires=">=3.7" ) diff --git a/sdk/eventgrid/azure-mgmt-eventgrid/tests/recordings/test_domain.pyTestMgmtEventGridtest_domain.json b/sdk/eventgrid/azure-mgmt-eventgrid/tests/recordings/test_domain.pyTestMgmtEventGridtest_domain.json index 6963efce4abe..cff1e2867e74 100644 --- a/sdk/eventgrid/azure-mgmt-eventgrid/tests/recordings/test_domain.pyTestMgmtEventGridtest_domain.json +++ b/sdk/eventgrid/azure-mgmt-eventgrid/tests/recordings/test_domain.pyTestMgmtEventGridtest_domain.json @@ -7,7 +7,7 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-identity/1.8.0b2 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, @@ -17,12 +17,12 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "1753", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:30 GMT", + "Date": "Wed, 17 Aug 2022 07:59:24 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.12890.7 - SCUS ProdSlices", + "x-ms-ests-server": "2.1.13481.9 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -101,7 +101,7 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.8.0b2 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, @@ -111,12 +111,12 @@ "Cache-Control": "max-age=86400, private", "Content-Length": "945", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:30 GMT", + "Date": "Wed, 17 Aug 2022 07:59:24 GMT", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Set-Cookie": "[set-cookie;]", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-ests-server": "2.1.13006.6 - SEASLR2 ProdSlices", + "x-ms-ests-server": "2.1.13481.9 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -172,28 +172,28 @@ "RequestHeaders": { "Accept": "application/json", "Accept-Encoding": "gzip, deflate", - "client-request-id": "515e670a-8e04-4c8d-b2db-2cd7d4dbb434", + "client-request-id": "cf2eb09f-d59f-4679-a73a-e1a770277f2d", "Connection": "keep-alive", - "Content-Length": "289", + "Content-Length": "288", "Content-Type": "application/x-www-form-urlencoded", "Cookie": "cookie;", - "User-Agent": "azsdk-python-identity/1.8.0b2 Python/3.8.8 (Windows-10-10.0.19041-SP0)", + "User-Agent": "azsdk-python-identity/1.11.0b4 Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0", "x-client-cpu": "x64", "x-client-current-telemetry": "4|730,0|", "x-client-last-telemetry": "4|0|||", - "x-client-os": "win32", + "x-client-os": "linux", "x-client-sku": "MSAL.Python", - "x-client-ver": "1.16.0", + "x-client-ver": "1.18.0", "x-ms-lib-capability": "retry-after, h429" }, "RequestBody": "client_id=00000000-0000-0000-0000-000000000000\u0026grant_type=client_credentials\u0026client_info=1\u0026client_secret=00000000-0000-0000-0000-000000000000\u0026claims=%7B%22access_token%22%3A\u002B%7B%22xms_cc%22%3A\u002B%7B%22values%22%3A\u002B%5B%22CP1%22%5D%7D%7D%7D\u0026scope=https%3A%2F%2Fmanagement.azure.com%2F.default", "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-store, no-cache", - "client-request-id": "515e670a-8e04-4c8d-b2db-2cd7d4dbb434", + "client-request-id": "cf2eb09f-d59f-4679-a73a-e1a770277f2d", "Content-Length": "93", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:31 GMT", + "Date": "Wed, 17 Aug 2022 07:59:25 GMT", "Expires": "-1", "P3P": "CP=\u0022DSP CUR OTPi IND OTRi ONL FIN\u0022", "Pragma": "no-cache", @@ -201,7 +201,7 @@ "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", "x-ms-clitelem": "1,0,0,,", - "x-ms-ests-server": "2.1.12890.7 - NCUS ProdSlices", + "x-ms-ests-server": "2.1.13481.9 - NCUS ProdSlices", "X-XSS-Protection": "0" }, "ResponseBody": { @@ -220,27 +220,27 @@ "Connection": "keep-alive", "Content-Length": "23", "Content-Type": "application/json", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": { "location": "eastus2" }, "StatusCode": 201, "ResponseHeaders": { - "Azure-AsyncOperation": "https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/FB85846B-BEA2-4B71-A1F3-983352EE023C?api-version=2022-06-15", + "Azure-AsyncOperation": "https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/2B86E793-8487-4479-80B4-A7A387EC9388?api-version=2022-06-15", "Cache-Control": "no-cache", "Content-Length": "309", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:38 GMT", + "Date": "Wed, 17 Aug 2022 07:59:25 GMT", "Expires": "-1", "Pragma": "no-cache", "Retry-After": "10", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "b1defd0c-a9a9-4655-9d80-7938061a522b", + "x-ms-correlation-request-id": "b6651a80-9449-48f5-a6af-2ffd027eb43d", "x-ms-ratelimit-remaining-subscription-writes": "1199", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072638Z:b1defd0c-a9a9-4655-9d80-7938061a522b" + "x-ms-routing-request-id": "EASTUS2:20220817T075926Z:b6651a80-9449-48f5-a6af-2ffd027eb43d" }, "ResponseBody": { "properties": { @@ -256,33 +256,35 @@ } }, { - "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/FB85846B-BEA2-4B71-A1F3-983352EE023C?api-version=2022-06-15", + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/2B86E793-8487-4479-80B4-A7A387EC9388?api-version=2022-06-15", "RequestMethod": "GET", "RequestHeaders": { "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "280", + "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:48 GMT", + "Date": "Wed, 17 Aug 2022 07:59:35 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "a0d813e3-618f-4ccc-bb37-02bfab667f42", - "x-ms-ratelimit-remaining-subscription-reads": "11998", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072649Z:a0d813e3-618f-4ccc-bb37-02bfab667f42" + "x-ms-correlation-request-id": "1dff3296-1fad-4af2-96cf-5b0b7475cf29", + "x-ms-ratelimit-remaining-subscription-reads": "11999", + "x-ms-routing-request-id": "EASTUS2:20220817T075936Z:1dff3296-1fad-4af2-96cf-5b0b7475cf29" }, "ResponseBody": { - "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/FB85846B-BEA2-4B71-A1F3-983352EE023C?api-version=2022-06-15", - "name": "fb85846b-bea2-4b71-a1f3-983352ee023c", + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/2B86E793-8487-4479-80B4-A7A387EC9388?api-version=2022-06-15", + "name": "2b86e793-8487-4479-80b4-a7a387ec9388", "status": "Succeeded" } }, @@ -293,31 +295,34 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "493", + "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:49 GMT", + "Date": "Wed, 17 Aug 2022 07:59:35 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "95784b14-91cf-421b-860a-71916b907252", - "x-ms-ratelimit-remaining-subscription-reads": "11997", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072649Z:95784b14-91cf-421b-860a-71916b907252" + "x-ms-correlation-request-id": "6bb7eadc-62d9-4b8d-9d4b-257c92416790", + "x-ms-ratelimit-remaining-subscription-reads": "11998", + "x-ms-routing-request-id": "EASTUS2:20220817T075936Z:6bb7eadc-62d9-4b8d-9d4b-257c92416790" }, "ResponseBody": { "properties": { "provisioningState": "Succeeded", "endpoint": "https://domainc98a23ef.eastus2-1.eventgrid.azure.net/api/events", "inputSchema": "EventGridSchema", - "metricResourceId": "ca249b55-f104-477b-aa8f-53b1c3b8dc81", - "publicNetworkAccess": "Enabled" + "metricResourceId": "c59a74f5-b095-4d5a-89fa-d93118502c65", + "publicNetworkAccess": "Enabled", + "dataResidencyBoundary": "WithinGeopair" }, "systemData": null, "location": "eastus2", @@ -336,7 +341,7 @@ "Connection": "keep-alive", "Content-Length": "46", "Content-Type": "application/json", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": { "tags": { @@ -346,28 +351,29 @@ }, "StatusCode": 201, "ResponseHeaders": { - "Azure-AsyncOperation": "https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/899D1B34-A7DA-4B1F-B912-CD78EDA31F10?api-version=2022-06-15", + "Azure-AsyncOperation": "https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/37422228-EE66-491B-B7ED-45E0595DD297?api-version=2022-06-15", "Cache-Control": "no-cache", - "Content-Length": "521", + "Content-Length": "561", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:26:52 GMT", + "Date": "Wed, 17 Aug 2022 07:59:36 GMT", "Expires": "-1", "Pragma": "no-cache", "Retry-After": "10", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "df1e3052-03ac-4366-8c32-a7dbaccdc196", + "x-ms-correlation-request-id": "375c0b9a-51b8-4c73-b839-71d230d93e94", "x-ms-ratelimit-remaining-subscription-writes": "1198", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072652Z:df1e3052-03ac-4366-8c32-a7dbaccdc196" + "x-ms-routing-request-id": "EASTUS2:20220817T075936Z:375c0b9a-51b8-4c73-b839-71d230d93e94" }, "ResponseBody": { "properties": { "provisioningState": "Updating", "endpoint": "https://domainc98a23ef.eastus2-1.eventgrid.azure.net/api/events", "inputSchema": "EventGridSchema", - "metricResourceId": "ca249b55-f104-477b-aa8f-53b1c3b8dc81", - "publicNetworkAccess": "Enabled" + "metricResourceId": "c59a74f5-b095-4d5a-89fa-d93118502c65", + "publicNetworkAccess": "Enabled", + "dataResidencyBoundary": "WithinGeopair" }, "systemData": null, "location": "eastus2", @@ -381,33 +387,35 @@ } }, { - "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/899D1B34-A7DA-4B1F-B912-CD78EDA31F10?api-version=2022-06-15", + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/37422228-EE66-491B-B7ED-45E0595DD297?api-version=2022-06-15", "RequestMethod": "GET", "RequestHeaders": { "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "280", + "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:27:02 GMT", + "Date": "Wed, 17 Aug 2022 07:59:46 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "2263311c-ee5f-481e-b113-67424c45e207", - "x-ms-ratelimit-remaining-subscription-reads": "11996", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072702Z:2263311c-ee5f-481e-b113-67424c45e207" + "x-ms-correlation-request-id": "16031e65-ebce-4586-a98b-2b349155ef09", + "x-ms-ratelimit-remaining-subscription-reads": "11997", + "x-ms-routing-request-id": "EASTUS2:20220817T075947Z:16031e65-ebce-4586-a98b-2b349155ef09" }, "ResponseBody": { - "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/899D1B34-A7DA-4B1F-B912-CD78EDA31F10?api-version=2022-06-15", - "name": "899d1b34-a7da-4b1f-b912-cd78eda31f10", + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/37422228-EE66-491B-B7ED-45E0595DD297?api-version=2022-06-15", + "name": "37422228-ee66-491b-b7ed-45e0595dd297", "status": "Succeeded" } }, @@ -418,31 +426,34 @@ "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "522", + "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:27:02 GMT", + "Date": "Wed, 17 Aug 2022 07:59:46 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "668284ec-727a-421c-b8f4-62fa938129e9", - "x-ms-ratelimit-remaining-subscription-reads": "11995", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072703Z:668284ec-727a-421c-b8f4-62fa938129e9" + "x-ms-correlation-request-id": "83151d3e-85d3-46b9-9024-4cfaa930aee0", + "x-ms-ratelimit-remaining-subscription-reads": "11996", + "x-ms-routing-request-id": "EASTUS2:20220817T075947Z:83151d3e-85d3-46b9-9024-4cfaa930aee0" }, "ResponseBody": { "properties": { "provisioningState": "Succeeded", "endpoint": "https://domainc98a23ef.eastus2-1.eventgrid.azure.net/api/events", "inputSchema": "EventGridSchema", - "metricResourceId": "ca249b55-f104-477b-aa8f-53b1c3b8dc81", - "publicNetworkAccess": "Enabled" + "metricResourceId": "c59a74f5-b095-4d5a-89fa-d93118502c65", + "publicNetworkAccess": "Enabled", + "dataResidencyBoundary": "WithinGeopair" }, "systemData": null, "location": "eastus2", @@ -462,31 +473,34 @@ "Accept": "application/json", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "522", + "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:27:02 GMT", + "Date": "Wed, 17 Aug 2022 07:59:46 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "c506fcc8-a643-4504-950b-d08cb3c90f3c", - "x-ms-ratelimit-remaining-subscription-reads": "11994", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072703Z:c506fcc8-a643-4504-950b-d08cb3c90f3c" + "x-ms-correlation-request-id": "9c397200-09f6-4cb7-a4a2-64c9311c8cca", + "x-ms-ratelimit-remaining-subscription-reads": "11995", + "x-ms-routing-request-id": "EASTUS2:20220817T075947Z:9c397200-09f6-4cb7-a4a2-64c9311c8cca" }, "ResponseBody": { "properties": { "provisioningState": "Succeeded", "endpoint": "https://domainc98a23ef.eastus2-1.eventgrid.azure.net/api/events", "inputSchema": "EventGridSchema", - "metricResourceId": "ca249b55-f104-477b-aa8f-53b1c3b8dc81", - "publicNetworkAccess": "Enabled" + "metricResourceId": "c59a74f5-b095-4d5a-89fa-d93118502c65", + "publicNetworkAccess": "Enabled", + "dataResidencyBoundary": "WithinGeopair" }, "systemData": null, "location": "eastus2", @@ -507,56 +521,58 @@ "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "Content-Length": "0", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 202, "ResponseHeaders": { - "Azure-AsyncOperation": "https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/8615A211-86B6-48C3-B53A-B29500B491C4?api-version=2022-06-15", + "Azure-AsyncOperation": "https://management.azure.com:443/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/C9E39D25-2862-41CA-BC85-758374FA7C54?api-version=2022-06-15", "Cache-Control": "no-cache", "Content-Length": "0", - "Date": "Mon, 20 Jun 2022 07:27:03 GMT", + "Date": "Wed, 17 Aug 2022 07:59:46 GMT", "Expires": "-1", - "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationResults/8615A211-86B6-48C3-B53A-B29500B491C4?api-version=2022-06-15", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationResults/C9E39D25-2862-41CA-BC85-758374FA7C54?api-version=2022-06-15", "Pragma": "no-cache", "Retry-After": "10", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "a5ba428c-00f9-404e-9b46-356fc256cea3", + "x-ms-correlation-request-id": "0e37478b-f081-4208-b02a-3a62c90c1c13", "x-ms-ratelimit-remaining-subscription-deletes": "14999", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072704Z:a5ba428c-00f9-404e-9b46-356fc256cea3" + "x-ms-routing-request-id": "EASTUS2:20220817T075947Z:0e37478b-f081-4208-b02a-3a62c90c1c13" }, "ResponseBody": null }, { - "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/8615A211-86B6-48C3-B53A-B29500B491C4?api-version=2022-06-15", + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/C9E39D25-2862-41CA-BC85-758374FA7C54?api-version=2022-06-15", "RequestMethod": "GET", "RequestHeaders": { "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", - "User-Agent": "azsdk-python-mgmt-eventgrid/10.2.0 Python/3.8.8 (Windows-10-10.0.19041-SP0)" + "User-Agent": "azsdk-python-mgmt-eventgrid/0.0.0 (it should be stable) Python/3.8.13 (Linux-5.15.0-1017-azure-x86_64-with-glibc2.2.5) VSTS_0fb41ef4-5012-48a9-bf39-4ee3de03ee35_build_2384_0" }, "RequestBody": null, "StatusCode": 200, "ResponseHeaders": { "Cache-Control": "no-cache", - "Content-Length": "280", + "Content-Encoding": "gzip", "Content-Type": "application/json; charset=utf-8", - "Date": "Mon, 20 Jun 2022 07:27:14 GMT", + "Date": "Wed, 17 Aug 2022 07:59:56 GMT", "Expires": "-1", "Pragma": "no-cache", "Server": "Microsoft-HTTPAPI/2.0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", "X-Content-Type-Options": "nosniff", - "x-ms-correlation-request-id": "9d30d721-f786-4ba5-8523-d5f35f44d037", - "x-ms-ratelimit-remaining-subscription-reads": "11993", - "x-ms-routing-request-id": "SOUTHEASTASIA:20220620T072715Z:9d30d721-f786-4ba5-8523-d5f35f44d037" + "x-ms-correlation-request-id": "fae03cf7-7ca0-48ec-aa00-49a057542b37", + "x-ms-ratelimit-remaining-subscription-reads": "11994", + "x-ms-routing-request-id": "EASTUS2:20220817T075957Z:fae03cf7-7ca0-48ec-aa00-49a057542b37" }, "ResponseBody": { - "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/8615A211-86B6-48C3-B53A-B29500B491C4?api-version=2022-06-15", - "name": "8615a211-86b6-48c3-b53a-b29500b491c4", + "id": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.EventGrid/locations/eastus2/operationsStatus/C9E39D25-2862-41CA-BC85-758374FA7C54?api-version=2022-06-15", + "name": "c9e39d25-2862-41ca-bc85-758374fa7c54", "status": "Succeeded" } } diff --git a/shared_requirements.txt b/shared_requirements.txt index dc06fe51f8de..eb1c0f655c0f 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -230,7 +230,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mixedreality-remoterendering azure-core<2.0.0,>=1.6.0 #override azure-mixedreality-remoterendering azure-mixedreality-authentication>=1.0.0b1 #override azure-ai-language-conversations azure-core<2.0.0,>=1.24.0 -#override azure-mgmt-eventgrid msrest>=0.6.21 +#override azure-mgmt-eventgrid msrest>=0.7.1 #override azure-ai-language-conversations isodate<1.0.0,>=0.6.1 #override azure-mgmt-loadtestservice azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-loadtestservice msrest>=0.6.21 @@ -330,7 +330,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-cognitiveservices azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-dns msrest>=0.6.21 #override azure-mgmt-dns azure-mgmt-core>=1.3.1,<2.0.0 -#override azure-mgmt-eventgrid azure-mgmt-core>=1.3.1,<2.0.0 +#override azure-mgmt-eventgrid azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-frontdoor msrest>=0.6.21 #override azure-mgmt-frontdoor azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-signalr msrest>=0.6.21