Skip to content

Commit 78b00c5

Browse files
authored
[WebPubSub] Update send methods signatures (#34855)
* update send methods signatures * resolve comments * update * add `groups` parameter to async `get_client_access_token` * update changelog and send* method comments
1 parent 9104867 commit 78b00c5

File tree

3 files changed

+598
-20
lines changed

3 files changed

+598
-20
lines changed

sdk/webpubsub/azure-messaging-webpubsubservice/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Release History
22

3-
## 1.1.0 (2024-02-28)
3+
## 1.1.0 (2024-04-24)
44

55
### Bugs Fixed
66
- Use the correct REST API parameter name `groups` in method `get_client_access_token`
77
- Upgrade dependency package `pyjwt` to `>=2.0.0` which changes the return type of `jwt.encode(...)`. See https://pyjwt.readthedocs.io/en/stable/changelog.html#id30 for detail
88

9+
### Features Added
10+
- Add overload signatures for operation `send_to_all` ,`send_to_user` ,`send_to_group` and `send_to_connection`
11+
- Update the type of parameter `content` from `IO` to `Union[IO, str, JSON]` for operation `send_to_all` ,`send_to_user` ,`send_to_group` and `send_to_connection`
12+
913
## 1.1.0b1 (2022-12-12)
1014

1115
### Features Added

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

Lines changed: 294 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
88
"""
9-
from typing import Any, List, IO, Optional
9+
from typing import Any, List, IO, Optional, Union, overload
1010
from datetime import datetime, timedelta, tzinfo
1111
import jwt
1212
from azure.core.credentials import AzureKeyCredential
@@ -126,9 +126,53 @@ def get_client_access_token(self, **kwargs: Any) -> JSON:
126126

127127
get_client_access_token.metadata = {"url": "/api/hubs/{hub}/:generateToken"} # type: ignore
128128

129-
@distributed_trace
129+
@overload
130+
def send_to_all( # pylint: disable=inconsistent-return-statements
131+
self, message: Union[str, JSON], *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = "application/json", **kwargs: Any
132+
) -> None:
133+
"""Broadcast content inside request body to all the connected client connections.
134+
135+
Broadcast content inside request body to all the connected client connections.
136+
137+
:param message: The payload body. Required.
138+
:type message: Union[str, JSON]
139+
:keyword excluded: Excluded connection Ids. Default value is None.
140+
:paramtype excluded: list[str]
141+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
142+
messages. Default value is None.
143+
:paramtype filter: str
144+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
145+
:paramtype content_type: str
146+
:return: None
147+
:rtype: None
148+
:raises ~azure.core.exceptions.HttpResponseError:
149+
"""
150+
151+
@overload
152+
def send_to_all( # pylint: disable=inconsistent-return-statements
153+
self, message: str, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = "text/plain", **kwargs: Any
154+
) -> None:
155+
"""Broadcast content inside request body to all the connected client connections.
156+
157+
Broadcast content inside request body to all the connected client connections.
158+
159+
:param message: The payload body. Required.
160+
:type message: str
161+
:keyword excluded: Excluded connection Ids. Default value is None.
162+
:paramtype excluded: list[str]
163+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
164+
messages. Default value is None.
165+
:paramtype filter: str
166+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
167+
:paramtype content_type: str
168+
:return: None
169+
:rtype: None
170+
:raises ~azure.core.exceptions.HttpResponseError:
171+
"""
172+
173+
@overload
130174
def send_to_all( # pylint: disable=inconsistent-return-statements
131-
self, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any
175+
self, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = "application/octet-stream", **kwargs: Any
132176
) -> None:
133177
"""Broadcast content inside request body to all the connected client connections.
134178
@@ -147,6 +191,28 @@ def send_to_all( # pylint: disable=inconsistent-return-statements
147191
:rtype: None
148192
:raises ~azure.core.exceptions.HttpResponseError:
149193
"""
194+
195+
@distributed_trace
196+
def send_to_all( # pylint: disable=inconsistent-return-statements
197+
self, message: Union[IO, str, JSON], *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any
198+
) -> None:
199+
"""Broadcast content inside request body to all the connected client connections.
200+
201+
Broadcast content inside request body to all the connected client connections.
202+
203+
:param message: The payload body. Required.
204+
:type message: Union[IO, str, JSON]
205+
:keyword excluded: Excluded connection Ids. Default value is None.
206+
:paramtype excluded: list[str]
207+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
208+
messages. Default value is None.
209+
:paramtype filter: str
210+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
211+
:paramtype content_type: str
212+
:return: None
213+
:rtype: None
214+
:raises ~azure.core.exceptions.HttpResponseError:
215+
"""
150216
error_map = {
151217
401: ClientAuthenticationError,
152218
404: ResourceNotFoundError,
@@ -201,9 +267,53 @@ def send_to_all( # pylint: disable=inconsistent-return-statements
201267
if cls:
202268
return cls(pipeline_response, None, {})
203269

204-
@distributed_trace
270+
@overload
205271
def send_to_user( # pylint: disable=inconsistent-return-statements
206-
self, user_id: str, message: IO, *, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any
272+
self, user_id: str, message: Union[str, JSON], *, filter: Optional[str] = None, content_type: Optional[str] = "application/json", **kwargs: Any
273+
) -> None:
274+
"""Send content inside request body to the specific user.
275+
276+
Send content inside request body to the specific user.
277+
278+
:param user_id: The user Id. Required.
279+
:type user_id: str
280+
:param message: The payload body. Required.
281+
:type message: Union[str, JSON]
282+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
283+
messages. Default value is None.
284+
:paramtype filter: str
285+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
286+
:paramtype content_type: str
287+
:return: None
288+
:rtype: None
289+
:raises ~azure.core.exceptions.HttpResponseError:
290+
"""
291+
292+
@overload
293+
def send_to_user( # pylint: disable=inconsistent-return-statements
294+
self, user_id: str, message: str, *, filter: Optional[str] = None, content_type: Optional[str] = "text/plain", **kwargs: Any
295+
) -> None:
296+
"""Send content inside request body to the specific user.
297+
298+
Send content inside request body to the specific user.
299+
300+
:param user_id: The user Id. Required.
301+
:type user_id: str
302+
:param message: The payload body. Required.
303+
:type message: str
304+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
305+
messages. Default value is None.
306+
:paramtype filter: str
307+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
308+
:paramtype content_type: str
309+
:return: None
310+
:rtype: None
311+
:raises ~azure.core.exceptions.HttpResponseError:
312+
"""
313+
314+
@overload
315+
def send_to_user( # pylint: disable=inconsistent-return-statements
316+
self, user_id: str, message: IO, *, filter: Optional[str] = None, content_type: Optional[str] = "application/octet-stream", **kwargs: Any
207317
) -> None:
208318
"""Send content inside request body to the specific user.
209319
@@ -222,6 +332,28 @@ def send_to_user( # pylint: disable=inconsistent-return-statements
222332
:rtype: None
223333
:raises ~azure.core.exceptions.HttpResponseError:
224334
"""
335+
336+
@distributed_trace
337+
def send_to_user( # pylint: disable=inconsistent-return-statements
338+
self, user_id: str, message: Union[IO, str, JSON], *, filter: Optional[str] = None, content_type: Optional[str] = None, **kwargs: Any
339+
) -> None:
340+
"""Send content inside request body to the specific user.
341+
342+
Send content inside request body to the specific user.
343+
344+
:param user_id: The user Id. Required.
345+
:type user_id: str
346+
:param message: The payload body. Required.
347+
:type message: Union[IO, str, JSON]
348+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
349+
messages. Default value is None.
350+
:paramtype filter: str
351+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
352+
:paramtype content_type: str
353+
:return: None
354+
:rtype: None
355+
:raises ~azure.core.exceptions.HttpResponseError:
356+
"""
225357
error_map = {
226358
401: ClientAuthenticationError,
227359
404: ResourceNotFoundError,
@@ -276,15 +408,79 @@ def send_to_user( # pylint: disable=inconsistent-return-statements
276408
if cls:
277409
return cls(pipeline_response, None, {})
278410

279-
@distributed_trace
411+
@overload
412+
def send_to_group( # pylint: disable=inconsistent-return-statements
413+
self,
414+
group: str,
415+
message: Union[str, JSON],
416+
*,
417+
excluded: Optional[List[str]] = None,
418+
filter: Optional[str] = None,
419+
content_type: Optional[str] = "application/json",
420+
**kwargs: Any
421+
) -> None:
422+
"""Send content inside request body to a group of connections.
423+
424+
Send content inside request body to a group of connections.
425+
426+
:param group: Target group name, which length should be greater than 0 and less than 1025.
427+
Required.
428+
:type group: str
429+
:param message: The payload body. Required.
430+
:type message: Union[str, JSON]
431+
:keyword excluded: Excluded connection Ids. Default value is None.
432+
:paramtype excluded: list[str]
433+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
434+
messages. Default value is None.
435+
:paramtype filter: str
436+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
437+
:paramtype content_type: str
438+
:return: None
439+
:rtype: None
440+
:raises ~azure.core.exceptions.HttpResponseError:
441+
"""
442+
443+
@overload
444+
def send_to_group( # pylint: disable=inconsistent-return-statements
445+
self,
446+
group: str,
447+
message: str,
448+
*,
449+
excluded: Optional[List[str]] = None,
450+
filter: Optional[str] = None,
451+
content_type: Optional[str] = "text/plain",
452+
**kwargs: Any
453+
) -> None:
454+
"""Send content inside request body to a group of connections.
455+
456+
Send content inside request body to a group of connections.
457+
458+
:param group: Target group name, which length should be greater than 0 and less than 1025.
459+
Required.
460+
:type group: str
461+
:param message: The payload body. Required.
462+
:type message: str
463+
:keyword excluded: Excluded connection Ids. Default value is None.
464+
:paramtype excluded: list[str]
465+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
466+
messages. Default value is None.
467+
:paramtype filter: str
468+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
469+
:paramtype content_type: str
470+
:return: None
471+
:rtype: None
472+
:raises ~azure.core.exceptions.HttpResponseError:
473+
"""
474+
475+
@overload
280476
def send_to_group( # pylint: disable=inconsistent-return-statements
281477
self,
282478
group: str,
283479
message: IO,
284480
*,
285481
excluded: Optional[List[str]] = None,
286482
filter: Optional[str] = None,
287-
content_type: Optional[str] = None,
483+
content_type: Optional[str] = "application/octet-stream",
288484
**kwargs: Any
289485
) -> None:
290486
"""Send content inside request body to a group of connections.
@@ -307,6 +503,38 @@ def send_to_group( # pylint: disable=inconsistent-return-statements
307503
:rtype: None
308504
:raises ~azure.core.exceptions.HttpResponseError:
309505
"""
506+
507+
@distributed_trace
508+
def send_to_group( # pylint: disable=inconsistent-return-statements
509+
self,
510+
group: str,
511+
message: Union[IO, str, JSON],
512+
*,
513+
excluded: Optional[List[str]] = None,
514+
filter: Optional[str] = None,
515+
content_type: Optional[str] = None,
516+
**kwargs: Any
517+
) -> None:
518+
"""Send content inside request body to a group of connections.
519+
520+
Send content inside request body to a group of connections.
521+
522+
:param group: Target group name, which length should be greater than 0 and less than 1025.
523+
Required.
524+
:type group: str
525+
:param message: The payload body. Required.
526+
:type message: Union[IO, str, JSON]
527+
:keyword excluded: Excluded connection Ids. Default value is None.
528+
:paramtype excluded: list[str]
529+
:keyword filter: Following OData filter syntax to filter out the subscribers receiving the
530+
messages. Default value is None.
531+
:paramtype filter: str
532+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
533+
:paramtype content_type: str
534+
:return: None
535+
:rtype: None
536+
:raises ~azure.core.exceptions.HttpResponseError:
537+
"""
310538
error_map = {
311539
401: ClientAuthenticationError,
312540
404: ResourceNotFoundError,
@@ -361,10 +589,48 @@ def send_to_group( # pylint: disable=inconsistent-return-statements
361589
raise HttpResponseError(response=response)
362590
if cls:
363591
return cls(pipeline_response, None, {})
592+
593+
@overload
594+
def send_to_connection( # pylint: disable=inconsistent-return-statements
595+
self, connection_id: str, message: Union[str, JSON], *, content_type: Optional[str] = "application/json", **kwargs: Any
596+
) -> None:
597+
"""Send content inside request body to the specific connection.
364598
365-
@distributed_trace
599+
Send content inside request body to the specific connection.
600+
601+
:param connection_id: The connection Id. Required.
602+
:type connection_id: str
603+
:param message: The payload body. Required.
604+
:type message: Union[str, JSON]
605+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
606+
:paramtype content_type: str
607+
:return: None
608+
:rtype: None
609+
:raises ~azure.core.exceptions.HttpResponseError:
610+
"""
611+
612+
@overload
366613
def send_to_connection( # pylint: disable=inconsistent-return-statements
367-
self, connection_id: str, message: IO, *, content_type: Optional[str] = None, **kwargs: Any
614+
self, connection_id: str, message: str, *, content_type: Optional[str] = "text/plain", **kwargs: Any
615+
) -> None:
616+
"""Send content inside request body to the specific connection.
617+
618+
Send content inside request body to the specific connection.
619+
620+
:param connection_id: The connection Id. Required.
621+
:type connection_id: str
622+
:param message: The payload body. Required.
623+
:type message: str
624+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
625+
:paramtype content_type: str
626+
:return: None
627+
:rtype: None
628+
:raises ~azure.core.exceptions.HttpResponseError:
629+
"""
630+
631+
@overload
632+
def send_to_connection( # pylint: disable=inconsistent-return-statements
633+
self, connection_id: str, message: IO, *, content_type: Optional[str] = "application/octet-stream", **kwargs: Any
368634
) -> None:
369635
"""Send content inside request body to the specific connection.
370636
@@ -380,6 +646,25 @@ def send_to_connection( # pylint: disable=inconsistent-return-statements
380646
:rtype: None
381647
:raises ~azure.core.exceptions.HttpResponseError:
382648
"""
649+
650+
@distributed_trace
651+
def send_to_connection( # pylint: disable=inconsistent-return-statements
652+
self, connection_id: str, message: Union[IO, str, JSON], *, content_type: Optional[str] = None, **kwargs: Any
653+
) -> None:
654+
"""Send content inside request body to the specific connection.
655+
656+
Send content inside request body to the specific connection.
657+
658+
:param connection_id: The connection Id. Required.
659+
:type connection_id: str
660+
:param message: The payload body. Required.
661+
:type message: Union[IO, str, JSON]
662+
:keyword content_type: The content type of the payload. Default value is None. Allowed values are 'application/json', 'application/octet-stream' and 'text/plain'
663+
:paramtype content_type: str
664+
:return: None
665+
:rtype: None
666+
:raises ~azure.core.exceptions.HttpResponseError:
667+
"""
383668
error_map = {
384669
401: ClientAuthenticationError,
385670
404: ResourceNotFoundError,

0 commit comments

Comments
 (0)