Skip to content

Commit 6cd9716

Browse files
authored
Add content_type for aio (#34826)
1 parent 6f5a43b commit 6cd9716

File tree

2 files changed

+17
-8
lines changed
  • sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice

2 files changed

+17
-8
lines changed

sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ def send_to_all( # pylint: disable=inconsistent-return-statements
141141
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
142142
messages. Default value is None.
143143
:paramtype filter: str
144-
:return: None
145144
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
146145
:paramtype content_type: str
146+
:return: None
147147
:rtype: None
148148
:raises ~azure.core.exceptions.HttpResponseError:
149149
"""

sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_patch.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async def get_client_access_token( # pylint: disable=arguments-differ
102102

103103
@distributed_trace_async
104104
async def send_to_all( # pylint: disable=inconsistent-return-statements
105-
self, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, **kwargs: Any
105+
self, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any
106106
) -> None:
107107
"""Broadcast content inside request body to all the connected client connections.
108108
@@ -115,6 +115,8 @@ async def send_to_all( # pylint: disable=inconsistent-return-statements
115115
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
116116
messages. Default value is None.
117117
:paramtype filter: str
118+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
119+
:paramtype content_type: str
118120
:return: None
119121
:rtype: None
120122
:raises ~azure.core.exceptions.HttpResponseError:
@@ -130,7 +132,7 @@ async def send_to_all( # pylint: disable=inconsistent-return-statements
130132
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
131133
_params = kwargs.pop("params", {}) or {}
132134

133-
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str
135+
content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str
134136
cls = kwargs.pop("cls", None) # type: ClsType[None]
135137

136138
_json = None
@@ -181,6 +183,7 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements
181183
*,
182184
excluded: Optional[List[str]] = None,
183185
filter: Optional[str] = None,
186+
content_type: Optional[str] = None,
184187
**kwargs: Any
185188
) -> None:
186189
"""Send content inside request body to a group of connections.
@@ -197,6 +200,8 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements
197200
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
198201
messages. Default value is None.
199202
:paramtype filter: str
203+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
204+
:paramtype content_type: str
200205
:return: None
201206
:rtype: None
202207
:raises ~azure.core.exceptions.HttpResponseError:
@@ -212,7 +217,7 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements
212217
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
213218
_params = kwargs.pop("params", {}) or {}
214219

215-
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str
220+
content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str
216221
cls = kwargs.pop("cls", None) # type: ClsType[None]
217222

218223
_json = None
@@ -258,7 +263,7 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements
258263

259264
@distributed_trace_async
260265
async def send_to_connection( # pylint: disable=inconsistent-return-statements
261-
self, connection_id: str, message: IO, **kwargs: Any
266+
self, connection_id: str, message: IO, *, content_type: Optional[str] = None, **kwargs: Any
262267
) -> None:
263268
"""Send content inside request body to the specific connection.
264269
@@ -268,6 +273,8 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements
268273
:type connection_id: str
269274
:param message: The payload body. Required.
270275
:type message: IO
276+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
277+
:paramtype content_type: str
271278
:return: None
272279
:rtype: None
273280
:raises ~azure.core.exceptions.HttpResponseError:
@@ -283,7 +290,7 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements
283290
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
284291
_params = kwargs.pop("params", {}) or {}
285292

286-
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str
293+
content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str
287294
cls = kwargs.pop("cls", None) # type: ClsType[None]
288295

289296
_json = None
@@ -327,7 +334,7 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements
327334

328335
@distributed_trace_async
329336
async def send_to_user( # pylint: disable=inconsistent-return-statements
330-
self, user_id: str, message: IO, *, filter: Optional[str] = None, **kwargs: Any
337+
self, user_id: str, message: IO, *, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any
331338
) -> None:
332339
"""Send content inside request body to the specific user.
333340
@@ -340,6 +347,8 @@ async def send_to_user( # pylint: disable=inconsistent-return-statements
340347
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
341348
messages. Default value is None.
342349
:paramtype filter: str
350+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
351+
:paramtype content_type: str
343352
:return: None
344353
:rtype: None
345354
:raises ~azure.core.exceptions.HttpResponseError:
@@ -355,7 +364,7 @@ async def send_to_user( # pylint: disable=inconsistent-return-statements
355364
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
356365
_params = kwargs.pop("params", {}) or {}
357366

358-
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str
367+
content_type = _headers.pop("Content-Type", "application/json") if content_type is None else content_type # type: str
359368
cls = kwargs.pop("cls", None) # type: ClsType[None]
360369

361370
_json = None

0 commit comments

Comments
 (0)