From 96e21a83441d297e89a8a9de9c77be2716f136e9 Mon Sep 17 00:00:00 2001 From: xingsy97 <87063252+xingsy97@users.noreply.github.com> Date: Fri, 1 Mar 2024 15:49:50 +0800 Subject: [PATCH 1/3] update --- .../webpubsubservice/_operations/_patch.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 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 11175e891495..6920ead4c72f 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 @@ -128,7 +128,7 @@ def get_client_access_token(self, **kwargs: Any) -> JSON: @distributed_trace 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. @@ -142,6 +142,8 @@ def send_to_all( # pylint: disable=inconsistent-return-statements 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 :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ @@ -156,7 +158,6 @@ 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 cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -201,7 +202,7 @@ def send_to_all( # pylint: disable=inconsistent-return-statements @distributed_trace 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. @@ -214,6 +215,8 @@ 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: @@ -229,7 +232,6 @@ 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 cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -280,6 +282,7 @@ 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. @@ -296,6 +299,8 @@ 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: @@ -311,7 +316,6 @@ 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 cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -357,7 +361,7 @@ def send_to_group( # pylint: disable=inconsistent-return-statements @distributed_trace 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. @@ -367,6 +371,8 @@ 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: @@ -382,7 +388,6 @@ 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 cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None From 754f716b4ba38b0de46e2ad6a0173150dbf59888 Mon Sep 17 00:00:00 2001 From: xingsy97 <87063252+xingsy97@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:03:41 +0800 Subject: [PATCH 2/3] handle default value --- .../azure/messaging/webpubsubservice/_operations/_patch.py | 4 ++++ 1 file changed, 4 insertions(+) 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 6920ead4c72f..087666ea5346 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 @@ -158,6 +158,7 @@ def send_to_all( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -232,6 +233,7 @@ def send_to_user( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -316,6 +318,7 @@ def send_to_group( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None @@ -388,6 +391,7 @@ def send_to_connection( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type cls = kwargs.pop("cls", None) # type: ClsType[None] _json = None From 03f44e4cf8538f119aa50a1ad966f0acda17c8f9 Mon Sep 17 00:00:00 2001 From: xingsy97 <87063252+xingsy97@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:54:41 +0800 Subject: [PATCH 3/3] resolve comment --- .../azure/messaging/webpubsubservice/_operations/_patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 087666ea5346..1121c94523f2 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 @@ -364,7 +364,7 @@ def send_to_group( # pylint: disable=inconsistent-return-statements @distributed_trace def send_to_connection( # pylint: disable=inconsistent-return-statements - self, connection_id: str, message: IO, content_type: Optional[str] = None, **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.