azure.messaging.webpubsubservice.aio package¶
-
class
azure.messaging.webpubsubservice.aio.
WebPubSubServiceClient
(endpoint: str, credential: Union[AsyncTokenCredential, AzureKeyCredential], **kwargs: Any)[source]¶ WebPubSubServiceClient.
- Parameters
endpoint (str) – HTTP or HTTPS endpoint for the Web PubSub service instance.
credential (AsyncTokenCredential) – Credential needed for the client to connect to Azure.
-
async
add_connection_to_group
(hub: str, 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
~azure.core.exceptions.HttpResponseError
-
async
add_user_to_group
(hub: str, 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
~azure.core.exceptions.HttpResponseError
-
async
check_permission
(hub: str, permission: str, connection_id: str, *, target_name: Optional[str] = None, **kwargs: Any) → None¶ Check if a connection has permission to the specified action.
Check if a connection has permission to the specified action.
- Parameters
hub (str) – Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
permission (str) – The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: “sendToGroup” or “joinLeaveGroup”.
connection_id (str) – Target connection Id.
- 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.
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
close_all_connections
(hub: str, *, excluded: Optional[List[str]] = None, reason: Optional[str] = None, **kwargs: Any) → None¶ Close the connections in the hub.
Close the connections in the hub.
- Parameters
hub (str) – Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
- Keyword Arguments
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
close_connection
(hub: str, connection_id: str, *, reason: Optional[str] = None, **kwargs: Any) → None¶ Close the client connection.
Close the client connection.
- Parameters
- Keyword Arguments
reason (str) – The reason closing the client connection.
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
close_group_connections
(hub: str, 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
- Keyword Arguments
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
close_user_connections
(hub: str, 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
- Keyword Arguments
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
connection_exists
(hub: str, connection_id: str, **kwargs: Any) → None¶ Check if the connection with the given connectionId exists.
Check if the connection with the given connectionId exists.
-
classmethod
from_connection_string
(connection_string: Type[ClientType], **kwargs: str) → ClientType[source]¶ Create a new WebPubSubServiceClient from a connection string. :param connection_string: Connection string :type connection_string: ~str :rtype: WebPubSubServiceClient
-
async
generate_client_token
(hub: str, *, user_id: Optional[str] = None, role: Optional[List[str]] = None, minutes_to_expire: Optional[int] = 60, **kwargs: Any) → Any¶ Generate token for the client to connect Azure Web PubSub service.
Generate token for the client to connect Azure Web PubSub service.
- Parameters
hub (str) – Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
- Keyword Arguments
- Returns
JSON object
- Return type
Any
- Raises
~azure.core.exceptions.HttpResponseError
Example
# response body for status code(s): 200 response.json() == { "token": "str" # Optional. The token value for the WebSocket client to connect to the service. }
-
async
grant_permission
(hub: str, permission: str, connection_id: str, *, target_name: Optional[str] = None, **kwargs: Any) → None¶ Grant permission to the connection.
Grant permission to the connection.
- Parameters
hub (str) – Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
permission (str) – The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: “sendToGroup” or “joinLeaveGroup”.
connection_id (str) – Target connection Id.
- 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.
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
group_exists
(hub: str, group: str, **kwargs: Any) → None¶ Check if there are any client connections inside the given group.
Check if there are any client connections inside the given group.
- Parameters
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
remove_connection_from_group
(hub: str, 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
~azure.core.exceptions.HttpResponseError
-
async
remove_user_from_all_groups
(hub: str, user_id: str, **kwargs: Any) → None¶ Remove a user from all groups.
Remove a user from all groups.
-
async
remove_user_from_group
(hub: str, 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
~azure.core.exceptions.HttpResponseError
-
async
revoke_permission
(hub: str, permission: str, connection_id: str, *, target_name: Optional[str] = None, **kwargs: Any) → None¶ Revoke permission for the connection.
Revoke permission for the connection.
- Parameters
hub (str) – Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
permission (str) – The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: “sendToGroup” or “joinLeaveGroup”.
connection_id (str) – Target connection Id.
- 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.
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
send_request
(request: azure.core.rest._rest_py3.HttpRequest, **kwargs: Any) → Awaitable[azure.core.rest._rest_py3.AsyncHttpResponse][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 = await client.send_request(request) <AsyncHttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
- 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
-
async
send_to_all
(hub: str, message: Union[IO, str], *, excluded: Optional[List[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
- Keyword Arguments
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
send_to_connection
(hub: str, connection_id: str, message: Union[IO, str], **kwargs: Any) → None¶ Send content inside request body to the specific connection.
Send content inside request body to the specific connection.
- Parameters
- Keyword Arguments
content_type (str) – Media type of the body sent to the API. Default value is “application/json”. Allowed values are: “application/json”, “application/octet-stream”, “text/plain.”
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
send_to_group
(hub: str, group: str, message: Union[IO, str], *, excluded: Optional[List[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
- Keyword Arguments
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError
-
async
send_to_user
(hub: str, user_id: str, message: Union[IO, str], **kwargs: Any) → None¶ Send content inside request body to the specific user.
Send content inside request body to the specific user.
- Parameters
- Keyword Arguments
content_type (str) – Media type of the body sent to the API. Default value is “application/json”. Allowed values are: “application/json”, “application/octet-stream”, “text/plain.”
- Returns
None
- Return type
- Raises
~azure.core.exceptions.HttpResponseError