azure.messaging.webpubsubservice package¶
-
class
azure.messaging.webpubsubservice.
WebPubSubServiceClient
(endpoint: str, hub: str, credential: Union[TokenCredential, azure.core.credentials.AzureKeyCredential], **kwargs: Any)[source]¶ WebPubSubServiceClient.
- Parameters
endpoint (str) – HTTP or HTTPS endpoint for the Web PubSub service instance.
hub (str) – Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
credential (TokenCredential or AzureKeyCredential) – Credential needed for the client to connect to Azure.
- Keyword Arguments
api_version (str) – Api Version. The default value is “2021-10-01”. Note that overriding this default value may result in unsupported behavior.
-
add_connection_to_group
(group: str, connection_id: str, **kwargs: Any) → None¶ Add a connection to the target group.
Add a connection to the target group.
- Parameters
- Returns
None
- Return type
- Raises
-
add_user_to_group
(group: str, user_id: str, **kwargs: Any) → None¶ Add a user to the target group.
Add a user to the target group.
- Parameters
- Returns
None
- Return type
- Raises
-
close_all_connections
(*, excluded: Optional[List[str]] = None, reason: Optional[str] = None, **kwargs: Any) → None¶ Close the connections in the hub.
Close the connections in the hub.
- Keyword Arguments
- Returns
None
- Return type
- Raises
-
close_connection
(connection_id: str, *, reason: Optional[str] = None, **kwargs: Any) → None¶ Close the client connection.
Close the client connection.
-
close_group_connections
(group: str, *, excluded: Optional[List[str]] = None, reason: Optional[str] = None, **kwargs: Any) → None¶ Close connections in the specific group.
Close connections in the specific group.
- Parameters
group (str) – Target group name, which length should be greater than 0 and less than 1025. Required.
- Keyword Arguments
- Returns
None
- Return type
- Raises
-
close_user_connections
(user_id: str, *, excluded: Optional[List[str]] = None, reason: Optional[str] = None, **kwargs: Any) → None¶ Close connections for the specific user.
Close connections for the specific user.
- Parameters
user_id (str) – The user Id. Required.
- Keyword Arguments
- Returns
None
- Return type
- Raises
-
connection_exists
(connection_id: str, **kwargs: Any) → bool¶ Check if the connection with the given connectionId exists.
Check if the connection with the given connectionId exists.
- Parameters
connection_id (str) – The connection Id. Required.
- Returns
bool
- Return type
- Raises
-
classmethod
from_connection_string
(connection_string: str, hub: str, **kwargs: Any) → azure.messaging.webpubsubservice._patch.WebPubSubServiceClient[source]¶ Create a new WebPubSubServiceClient from a connection string.
- Parameters
- Return type
-
get_client_access_token
(**kwargs: Any) → collections.abc.MutableMapping[str, Any]¶ Build an authentication token. :keyword user_id: User Id. :paramtype user_id: str :keyword roles: Roles that the connection with the generated token will have. :paramtype roles: list[str] :keyword minutes_to_expire: The expire time of the generated token. :paramtype minutes_to_expire: int :keyword dict[str, any] jwt_headers: Any headers you want to pass to jwt encoding. :returns: JSON response containing the web socket endpoint, the token and a url with the generated access token. :rtype: JSON Example: >>> get_client_access_token() {
‘baseUrl’: ‘wss://contoso.com/api/webpubsub/client/hubs/theHub’, ‘token’: ‘<access-token>…’, ‘url’: ‘wss://contoso.com/api/webpubsub/client/hubs/theHub?access_token=<access-token>…’
}
-
grant_permission
(permission: str, connection_id: str, *, target_name: Optional[str] = None, **kwargs: Any) → None¶ Grant permission to the connection.
Grant permission to the connection.
- Parameters
- Keyword Arguments
target_name (str) – The meaning of the target depends on the specific permission. For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name. Default value is None.
- Returns
None
- Return type
- Raises
-
group_exists
(group: str, **kwargs: Any) → bool¶ Check if there are any client connections inside the given group.
Check if there are any client connections inside the given group.
- Parameters
group (str) – Target group name, which length should be greater than 0 and less than 1025. Required.
- Returns
bool
- Return type
- Raises
-
has_permission
(permission: str, connection_id: str, *, target_name: Optional[str] = None, **kwargs: Any) → bool¶ Check if a connection has permission to the specified action.
Check if a connection has permission to the specified action.
- Parameters
- Keyword Arguments
target_name (str) – The meaning of the target depends on the specific permission. For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name. Default value is None.
- Returns
bool
- Return type
- Raises
-
remove_connection_from_all_groups
(connection_id: str, **kwargs: Any) → None¶ Remove a connection from all groups.
Remove a connection from all groups.
- Parameters
connection_id (str) – Target connection Id. Required.
- Returns
None
- Return type
- Raises
-
remove_connection_from_group
(group: str, connection_id: str, **kwargs: Any) → None¶ Remove a connection from the target group.
Remove a connection from the target group.
- Parameters
- Returns
None
- Return type
- Raises
-
remove_user_from_all_groups
(user_id: str, **kwargs: Any) → None¶ Remove a user from all groups.
Remove a user from all groups.
- Parameters
user_id (str) – Target user Id. Required.
- Returns
None
- Return type
- Raises
-
remove_user_from_group
(group: str, user_id: str, **kwargs: Any) → None¶ Remove a user from the target group.
Remove a user from the target group.
- Parameters
- Returns
None
- Return type
- Raises
-
revoke_permission
(permission: str, connection_id: str, *, target_name: Optional[str] = None, **kwargs: Any) → None¶ Revoke permission for the connection.
Revoke permission for the connection.
- Parameters
- Keyword Arguments
target_name (str) – The meaning of the target depends on the specific permission. For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name. Default value is None.
- Returns
None
- Return type
- Raises
-
send_request
(request: azure.core.rest._rest_py3.HttpRequest, **kwargs: Any) → azure.core.rest._rest_py3.HttpResponse[source]¶ Runs the network request through the client’s chained policies.
>>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client.send_request(request) <HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
- Parameters
request (HttpRequest) – The network request you want to make. Required.
- Keyword Arguments
stream (bool) – Whether the response payload will be streamed. Defaults to False.
- Returns
The response of your network call. Does not do error handling on your response.
- Return type
-
send_to_all
(message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, **kwargs: Any) → None¶ Broadcast content inside request body to all the connected client connections.
Broadcast content inside request body to all the connected client connections.
- Parameters
message (IO) – The payload body. Required.
- Keyword Arguments
- Returns
None
- Return type
- Raises
-
send_to_connection
(connection_id: str, message: IO, **kwargs: Any) → None¶ Send content inside request body to the specific connection.
Send content inside request body to the specific connection.
- Parameters
connection_id (str) – The connection Id. Required.
message (IO) – The payload body. Required.
- Returns
None
- Return type
- Raises
-
send_to_group
(group: str, message: IO, *, excluded: Optional[List[str]] = None, filter: Optional[str] = None, **kwargs: Any) → None¶ Send content inside request body to a group of connections.
Send content inside request body to a group of connections.
- Parameters
group (str) – Target group name, which length should be greater than 0 and less than 1025. Required.
message (IO) – The payload body. Required.
- Keyword Arguments
- Returns
None
- Return type
- Raises
-
send_to_user
(user_id: str, message: IO, *, filter: Optional[str] = None, **kwargs: Any) → None¶ Send content inside request body to the specific user.
Send content inside request body to the specific user.