From 129f659e16bb4cc50e1bb32683da3826f9fce016 Mon Sep 17 00:00:00 2001 From: xingsy97 <87063252+xingsy97@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:51:03 +0800 Subject: [PATCH] Add content_type for aio --- .../webpubsubservice/_operations/_patch.py | 2 +- .../aio/_operations/_patch.py | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_patch.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_patch.py index 1121c94523f2..8a474ecabb49 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_patch.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_patch.py @@ -141,9 +141,9 @@ def send_to_all( # pylint: disable=inconsistent-return-statements :keyword filter: Following OData filter syntax to filter out the subscribers receiving the messages. Default value is None. :paramtype filter: str - :return: None :keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain' :paramtype content_type: str + :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_patch.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_patch.py index 3a6ef7dae15a..5377d3131e3f 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_patch.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_patch.py @@ -102,7 +102,7 @@ async def get_client_access_token( # pylint: disable=arguments-differ @distributed_trace_async async def send_to_all( # pylint: disable=inconsistent-return-statements - self, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, **kwargs: Any + self, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any ) -> None: """Broadcast content inside request body to all the connected client connections. @@ -115,6 +115,8 @@ async def send_to_all( # pylint: disable=inconsistent-return-statements :keyword filter: Following OData filter syntax to filter out the subscribers receiving the messages. Default value is None. :paramtype filter: str + :keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain' + :paramtype content_type: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -130,7 +132,7 @@ async def send_to_all( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -181,6 +183,7 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, + content_type: Optional[str] = None, **kwargs: Any ) -> None: """Send content inside request body to a group of connections. @@ -197,6 +200,8 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements :keyword filter: Following OData filter syntax to filter out the subscribers receiving the messages. Default value is None. :paramtype filter: str + :keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain' + :paramtype content_type: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -212,7 +217,7 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -258,7 +263,7 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements @distributed_trace_async async def send_to_connection( # pylint: disable=inconsistent-return-statements - self, connection_id: str, message: IO, **kwargs: Any + self, connection_id: str, message: IO, *, content_type: Optional[str] = None, **kwargs: Any ) -> None: """Send content inside request body to the specific connection. @@ -268,6 +273,8 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements :type connection_id: str :param message: The payload body. Required. :type message: IO + :keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain' + :paramtype content_type: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -283,7 +290,7 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -327,7 +334,7 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements @distributed_trace_async async def send_to_user( # pylint: disable=inconsistent-return-statements - self, user_id: str, message: IO, *, filter: Optional[str] = None, **kwargs: Any + self, user_id: str, message: IO, *, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any ) -> None: """Send content inside request body to the specific user. @@ -340,6 +347,8 @@ async def send_to_user( # pylint: disable=inconsistent-return-statements :keyword filter: Following OData filter syntax to filter out the subscribers receiving the messages. Default value is None. :paramtype filter: str + :keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain' + :paramtype content_type: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -355,7 +364,7 @@ async def send_to_user( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None