diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_configuration.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_configuration.py index 44defc058a54..0ad85a86eb78 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_configuration.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_configuration.py @@ -26,6 +26,8 @@ class WebPubSubServiceClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. + :param hub: Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore. + :type hub: str :param endpoint: HTTP or HTTPS endpoint for the Web PubSub service instance. :type endpoint: str :param credential: Credential needed for the client to connect to Azure. @@ -36,6 +38,7 @@ class WebPubSubServiceClientConfiguration(Configuration): def __init__( self, + hub, # type: str endpoint, # type: str credential, # type: "TokenCredential" **kwargs # type: Any @@ -44,11 +47,14 @@ def __init__( super(WebPubSubServiceClientConfiguration, self).__init__(**kwargs) api_version = kwargs.pop('api_version', "2021-10-01") # type: str + if hub is None: + raise ValueError("Parameter 'hub' must not be None.") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if credential is None: raise ValueError("Parameter 'credential' must not be None.") + self.hub = hub self.endpoint = endpoint self.credential = credential self.api_version = api_version diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_operations.py index 1eb379f1551b..a3e45932a41a 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_operations/_operations.py @@ -26,6 +26,7 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False # fmt: off def build_get_client_access_token_request( @@ -798,7 +799,6 @@ class WebPubSubServiceClientOperationsMixin(object): @distributed_trace def get_client_access_token( self, - hub, # type: str **kwargs # type: Any ): # type: (...) -> JSONType @@ -806,9 +806,6 @@ def get_client_access_token( Generate token for the client to connect Azure Web PubSub service. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :keyword user_id: User Id. :paramtype user_id: str :keyword roles: Roles that the connection with the generated token will have. @@ -843,7 +840,7 @@ def get_client_access_token( request = build_get_client_access_token_request( - hub=hub, + hub=self._config.hub, api_version=api_version, user_id=user_id, roles=roles, @@ -878,7 +875,6 @@ def get_client_access_token( @distributed_trace def close_all_connections( self, - hub, # type: str **kwargs # type: Any ): # type: (...) -> None @@ -886,9 +882,6 @@ def close_all_connections( Close the connections in the hub. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :keyword excluded: Exclude these connectionIds when closing the connections in the hub. :paramtype excluded: list[str] :keyword reason: The reason closing the client connection. @@ -912,7 +905,7 @@ def close_all_connections( request = build_close_all_connections_request( - hub=hub, + hub=self._config.hub, api_version=api_version, excluded=excluded, reason=reason, @@ -939,7 +932,6 @@ def close_all_connections( @distributed_trace def send_to_all( self, - hub, # type: str message, # type: Union[IO, str, JSONType] **kwargs # type: Any ): @@ -948,9 +940,6 @@ def send_to_all( Broadcast content inside request body to all the connected client connections. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param message: The payload body. :type message: IO or str or JSONType :keyword excluded: Excluded connection Ids. @@ -988,7 +977,7 @@ def send_to_all( ) request = build_send_to_all_request( - hub=hub, + hub=self._config.hub, api_version=api_version, content_type=content_type, json=json, @@ -1017,7 +1006,6 @@ def send_to_all( @distributed_trace def connection_exists( self, - hub, # type: str connection_id, # type: str **kwargs # type: Any ): @@ -1026,9 +1014,6 @@ def connection_exists( Check if the connection with the given connectionId exists. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param connection_id: The connection Id. :type connection_id: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -1048,7 +1033,7 @@ def connection_exists( request = build_connection_exists_request( - hub=hub, + hub=self._config.hub, connection_id=connection_id, api_version=api_version, template_url=self.connection_exists.metadata['url'], @@ -1075,7 +1060,6 @@ def connection_exists( @distributed_trace def close_connection( self, - hub, # type: str connection_id, # type: str **kwargs # type: Any ): @@ -1084,9 +1068,6 @@ def close_connection( Close the client connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param connection_id: Target connection Id. :type connection_id: str :keyword reason: The reason closing the client connection. @@ -1109,7 +1090,7 @@ def close_connection( request = build_close_connection_request( - hub=hub, + hub=self._config.hub, connection_id=connection_id, api_version=api_version, reason=reason, @@ -1136,7 +1117,6 @@ def close_connection( @distributed_trace def send_to_connection( self, - hub, # type: str connection_id, # type: str message, # type: Union[IO, str, JSONType] **kwargs # type: Any @@ -1146,9 +1126,6 @@ def send_to_connection( Send content inside request body to the specific connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param connection_id: The connection Id. :type connection_id: str :param message: The payload body. @@ -1185,7 +1162,7 @@ def send_to_connection( ) request = build_send_to_connection_request( - hub=hub, + hub=self._config.hub, connection_id=connection_id, api_version=api_version, content_type=content_type, @@ -1214,7 +1191,6 @@ def send_to_connection( @distributed_trace def group_exists( self, - hub, # type: str group, # type: str **kwargs # type: Any ): @@ -1223,9 +1199,6 @@ def group_exists( Check if there are any client connections inside the given group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -1245,7 +1218,7 @@ def group_exists( request = build_group_exists_request( - hub=hub, + hub=self._config.hub, group=group, api_version=api_version, template_url=self.group_exists.metadata['url'], @@ -1272,7 +1245,6 @@ def group_exists( @distributed_trace def close_group_connections( self, - hub, # type: str group, # type: str **kwargs # type: Any ): @@ -1281,9 +1253,6 @@ def close_group_connections( Close connections in the specific group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :keyword excluded: Exclude these connectionIds when closing the connections in the group. @@ -1309,7 +1278,7 @@ def close_group_connections( request = build_close_group_connections_request( - hub=hub, + hub=self._config.hub, group=group, api_version=api_version, excluded=excluded, @@ -1337,7 +1306,6 @@ def close_group_connections( @distributed_trace def send_to_group( self, - hub, # type: str group, # type: str message, # type: Union[IO, str, JSONType] **kwargs # type: Any @@ -1347,9 +1315,6 @@ def send_to_group( Send content inside request body to a group of connections. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param message: The payload body. @@ -1389,7 +1354,7 @@ def send_to_group( ) request = build_send_to_group_request( - hub=hub, + hub=self._config.hub, group=group, api_version=api_version, content_type=content_type, @@ -1419,7 +1384,6 @@ def send_to_group( @distributed_trace def add_connection_to_group( self, - hub, # type: str group, # type: str connection_id, # type: str **kwargs # type: Any @@ -1429,9 +1393,6 @@ def add_connection_to_group( Add a connection to the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param connection_id: Target connection Id. @@ -1453,7 +1414,7 @@ def add_connection_to_group( request = build_add_connection_to_group_request( - hub=hub, + hub=self._config.hub, group=group, connection_id=connection_id, api_version=api_version, @@ -1480,7 +1441,6 @@ def add_connection_to_group( @distributed_trace def remove_connection_from_group( self, - hub, # type: str group, # type: str connection_id, # type: str **kwargs # type: Any @@ -1490,9 +1450,6 @@ def remove_connection_from_group( Remove a connection from the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param connection_id: Target connection Id. @@ -1514,7 +1471,7 @@ def remove_connection_from_group( request = build_remove_connection_from_group_request( - hub=hub, + hub=self._config.hub, group=group, connection_id=connection_id, api_version=api_version, @@ -1541,7 +1498,6 @@ def remove_connection_from_group( @distributed_trace def user_exists( self, - hub, # type: str user_id, # type: str **kwargs # type: Any ): @@ -1550,9 +1506,6 @@ def user_exists( Check if there are any client connections connected for the given user. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: Target user Id. :type user_id: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -1572,7 +1525,7 @@ def user_exists( request = build_user_exists_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, template_url=self.user_exists.metadata['url'], @@ -1599,7 +1552,6 @@ def user_exists( @distributed_trace def close_user_connections( self, - hub, # type: str user_id, # type: str **kwargs # type: Any ): @@ -1608,9 +1560,6 @@ def close_user_connections( Close connections for the specific user. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: The user Id. :type user_id: str :keyword excluded: Exclude these connectionIds when closing the connections for the user. @@ -1636,7 +1585,7 @@ def close_user_connections( request = build_close_user_connections_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, excluded=excluded, @@ -1664,7 +1613,6 @@ def close_user_connections( @distributed_trace def send_to_user( self, - hub, # type: str user_id, # type: str message, # type: Union[IO, str, JSONType] **kwargs # type: Any @@ -1674,9 +1622,6 @@ def send_to_user( Send content inside request body to the specific user. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: The user Id. :type user_id: str :param message: The payload body. @@ -1713,7 +1658,7 @@ def send_to_user( ) request = build_send_to_user_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, content_type=content_type, @@ -1742,7 +1687,6 @@ def send_to_user( @distributed_trace def add_user_to_group( self, - hub, # type: str group, # type: str user_id, # type: str **kwargs # type: Any @@ -1752,9 +1696,6 @@ def add_user_to_group( Add a user to the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param user_id: Target user Id. @@ -1776,7 +1717,7 @@ def add_user_to_group( request = build_add_user_to_group_request( - hub=hub, + hub=self._config.hub, group=group, user_id=user_id, api_version=api_version, @@ -1803,7 +1744,6 @@ def add_user_to_group( @distributed_trace def remove_user_from_group( self, - hub, # type: str group, # type: str user_id, # type: str **kwargs # type: Any @@ -1813,9 +1753,6 @@ def remove_user_from_group( Remove a user from the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param user_id: Target user Id. @@ -1837,7 +1774,7 @@ def remove_user_from_group( request = build_remove_user_from_group_request( - hub=hub, + hub=self._config.hub, group=group, user_id=user_id, api_version=api_version, @@ -1864,7 +1801,6 @@ def remove_user_from_group( @distributed_trace def remove_user_from_all_groups( self, - hub, # type: str user_id, # type: str **kwargs # type: Any ): @@ -1873,9 +1809,6 @@ def remove_user_from_all_groups( Remove a user from all groups. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: Target user Id. :type user_id: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -1895,7 +1828,7 @@ def remove_user_from_all_groups( request = build_remove_user_from_all_groups_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, template_url=self.remove_user_from_all_groups.metadata['url'], @@ -1921,7 +1854,6 @@ def remove_user_from_all_groups( @distributed_trace def grant_permission( self, - hub, # type: str permission, # type: str connection_id, # type: str **kwargs # type: Any @@ -1931,9 +1863,6 @@ def grant_permission( Grant permission to the connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param permission: The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: "sendToGroup" or "joinLeaveGroup". :type permission: str @@ -1960,7 +1889,7 @@ def grant_permission( request = build_grant_permission_request( - hub=hub, + hub=self._config.hub, permission=permission, connection_id=connection_id, api_version=api_version, @@ -1988,7 +1917,6 @@ def grant_permission( @distributed_trace def revoke_permission( self, - hub, # type: str permission, # type: str connection_id, # type: str **kwargs # type: Any @@ -1998,9 +1926,6 @@ def revoke_permission( Revoke permission for the connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param permission: The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: "sendToGroup" or "joinLeaveGroup". :type permission: str @@ -2027,7 +1952,7 @@ def revoke_permission( request = build_revoke_permission_request( - hub=hub, + hub=self._config.hub, permission=permission, connection_id=connection_id, api_version=api_version, @@ -2055,7 +1980,6 @@ def revoke_permission( @distributed_trace def has_permission( self, - hub, # type: str permission, # type: str connection_id, # type: str **kwargs # type: Any @@ -2065,9 +1989,6 @@ def has_permission( Check if a connection has permission to the specified action. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param permission: The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: "sendToGroup" or "joinLeaveGroup". :type permission: str @@ -2094,7 +2015,7 @@ def has_permission( request = build_has_permission_request( - hub=hub, + hub=self._config.hub, permission=permission, connection_id=connection_id, api_version=api_version, diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_web_pub_sub_service_client.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_web_pub_sub_service_client.py index 0c8702bf159f..9d96f87e1225 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_web_pub_sub_service_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_web_pub_sub_service_client.py @@ -25,6 +25,9 @@ class WebPubSubServiceClient(WebPubSubServiceClientOperationsMixin): """WebPubSubServiceClient. + :param hub: Target hub name, which should start with alphabetic characters and only contain + alpha-numeric characters or underscore. + :type hub: str :param endpoint: HTTP or HTTPS endpoint for the Web PubSub service instance. :type endpoint: str :param credential: Credential needed for the client to connect to Azure. @@ -36,13 +39,14 @@ class WebPubSubServiceClient(WebPubSubServiceClientOperationsMixin): def __init__( self, + hub, # type: str endpoint, # type: str credential, # type: "TokenCredential" **kwargs # type: Any ): # type: (...) -> None _endpoint = '{Endpoint}' - self._config = WebPubSubServiceClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = WebPubSubServiceClientConfiguration(hub=hub, endpoint=endpoint, credential=credential, **kwargs) self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_configuration.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_configuration.py index c9c68386762d..24dea080d9bd 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_configuration.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_configuration.py @@ -24,6 +24,8 @@ class WebPubSubServiceClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. + :param hub: Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore. + :type hub: str :param endpoint: HTTP or HTTPS endpoint for the Web PubSub service instance. :type endpoint: str :param credential: Credential needed for the client to connect to Azure. @@ -34,6 +36,7 @@ class WebPubSubServiceClientConfiguration(Configuration): def __init__( self, + hub: str, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any @@ -41,11 +44,14 @@ def __init__( super(WebPubSubServiceClientConfiguration, self).__init__(**kwargs) api_version = kwargs.pop('api_version', "2021-10-01") # type: str + if hub is None: + raise ValueError("Parameter 'hub' must not be None.") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") if credential is None: raise ValueError("Parameter 'credential' must not be None.") + self.hub = hub self.endpoint = endpoint self.credential = credential self.api_version = api_version diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_operations.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_operations.py index ebd1f4541681..0fe699744e5b 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_operations.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_operations/_operations.py @@ -25,7 +25,6 @@ class WebPubSubServiceClientOperationsMixin: @distributed_trace_async async def get_client_access_token( self, - hub: str, *, user_id: Optional[str] = None, roles: Optional[List[str]] = None, @@ -36,9 +35,6 @@ async def get_client_access_token( Generate token for the client to connect Azure Web PubSub service. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :keyword user_id: User Id. :paramtype user_id: str :keyword roles: Roles that the connection with the generated token will have. @@ -70,7 +66,7 @@ async def get_client_access_token( request = build_get_client_access_token_request( - hub=hub, + hub=self._config.hub, api_version=api_version, user_id=user_id, roles=roles, @@ -105,7 +101,6 @@ async def get_client_access_token( @distributed_trace_async async def close_all_connections( self, - hub: str, *, excluded: Optional[List[str]] = None, reason: Optional[str] = None, @@ -115,9 +110,6 @@ async def close_all_connections( Close the connections in the hub. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :keyword excluded: Exclude these connectionIds when closing the connections in the hub. :paramtype excluded: list[str] :keyword reason: The reason closing the client connection. @@ -139,7 +131,7 @@ async def close_all_connections( request = build_close_all_connections_request( - hub=hub, + hub=self._config.hub, api_version=api_version, excluded=excluded, reason=reason, @@ -166,7 +158,6 @@ async def close_all_connections( @distributed_trace_async async def send_to_all( self, - hub: str, message: Union[IO, str, JSONType], *, excluded: Optional[List[str]] = None, @@ -176,9 +167,6 @@ async def send_to_all( Broadcast content inside request body to all the connected client connections. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param message: The payload body. :type message: IO or str or JSONType :keyword excluded: Excluded connection Ids. @@ -215,7 +203,7 @@ async def send_to_all( ) request = build_send_to_all_request( - hub=hub, + hub=self._config.hub, api_version=api_version, content_type=content_type, json=json, @@ -244,7 +232,6 @@ async def send_to_all( @distributed_trace_async async def connection_exists( self, - hub: str, connection_id: str, **kwargs: Any ) -> bool: @@ -252,9 +239,6 @@ async def connection_exists( Check if the connection with the given connectionId exists. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param connection_id: The connection Id. :type connection_id: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -274,7 +258,7 @@ async def connection_exists( request = build_connection_exists_request( - hub=hub, + hub=self._config.hub, connection_id=connection_id, api_version=api_version, template_url=self.connection_exists.metadata['url'], @@ -301,7 +285,6 @@ async def connection_exists( @distributed_trace_async async def close_connection( self, - hub: str, connection_id: str, *, reason: Optional[str] = None, @@ -311,9 +294,6 @@ async def close_connection( Close the client connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param connection_id: Target connection Id. :type connection_id: str :keyword reason: The reason closing the client connection. @@ -335,7 +315,7 @@ async def close_connection( request = build_close_connection_request( - hub=hub, + hub=self._config.hub, connection_id=connection_id, api_version=api_version, reason=reason, @@ -362,7 +342,6 @@ async def close_connection( @distributed_trace_async async def send_to_connection( self, - hub: str, connection_id: str, message: Union[IO, str, JSONType], **kwargs: Any @@ -371,9 +350,6 @@ async def send_to_connection( Send content inside request body to the specific connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param connection_id: The connection Id. :type connection_id: str :param message: The payload body. @@ -410,7 +386,7 @@ async def send_to_connection( ) request = build_send_to_connection_request( - hub=hub, + hub=self._config.hub, connection_id=connection_id, api_version=api_version, content_type=content_type, @@ -439,7 +415,6 @@ async def send_to_connection( @distributed_trace_async async def group_exists( self, - hub: str, group: str, **kwargs: Any ) -> bool: @@ -447,9 +422,6 @@ async def group_exists( Check if there are any client connections inside the given group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -469,7 +441,7 @@ async def group_exists( request = build_group_exists_request( - hub=hub, + hub=self._config.hub, group=group, api_version=api_version, template_url=self.group_exists.metadata['url'], @@ -496,7 +468,6 @@ async def group_exists( @distributed_trace_async async def close_group_connections( self, - hub: str, group: str, *, excluded: Optional[List[str]] = None, @@ -507,9 +478,6 @@ async def close_group_connections( Close connections in the specific group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :keyword excluded: Exclude these connectionIds when closing the connections in the group. @@ -533,7 +501,7 @@ async def close_group_connections( request = build_close_group_connections_request( - hub=hub, + hub=self._config.hub, group=group, api_version=api_version, excluded=excluded, @@ -561,7 +529,6 @@ async def close_group_connections( @distributed_trace_async async def send_to_group( self, - hub: str, group: str, message: Union[IO, str, JSONType], *, @@ -572,9 +539,6 @@ async def send_to_group( Send content inside request body to a group of connections. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param message: The payload body. @@ -613,7 +577,7 @@ async def send_to_group( ) request = build_send_to_group_request( - hub=hub, + hub=self._config.hub, group=group, api_version=api_version, content_type=content_type, @@ -643,7 +607,6 @@ async def send_to_group( @distributed_trace_async async def add_connection_to_group( self, - hub: str, group: str, connection_id: str, **kwargs: Any @@ -652,9 +615,6 @@ async def add_connection_to_group( Add a connection to the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param connection_id: Target connection Id. @@ -676,7 +636,7 @@ async def add_connection_to_group( request = build_add_connection_to_group_request( - hub=hub, + hub=self._config.hub, group=group, connection_id=connection_id, api_version=api_version, @@ -703,7 +663,6 @@ async def add_connection_to_group( @distributed_trace_async async def remove_connection_from_group( self, - hub: str, group: str, connection_id: str, **kwargs: Any @@ -712,9 +671,6 @@ async def remove_connection_from_group( Remove a connection from the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param connection_id: Target connection Id. @@ -736,7 +692,7 @@ async def remove_connection_from_group( request = build_remove_connection_from_group_request( - hub=hub, + hub=self._config.hub, group=group, connection_id=connection_id, api_version=api_version, @@ -763,7 +719,6 @@ async def remove_connection_from_group( @distributed_trace_async async def user_exists( self, - hub: str, user_id: str, **kwargs: Any ) -> bool: @@ -771,9 +726,6 @@ async def user_exists( Check if there are any client connections connected for the given user. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: Target user Id. :type user_id: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -793,7 +745,7 @@ async def user_exists( request = build_user_exists_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, template_url=self.user_exists.metadata['url'], @@ -820,7 +772,6 @@ async def user_exists( @distributed_trace_async async def close_user_connections( self, - hub: str, user_id: str, *, excluded: Optional[List[str]] = None, @@ -831,9 +782,6 @@ async def close_user_connections( Close connections for the specific user. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: The user Id. :type user_id: str :keyword excluded: Exclude these connectionIds when closing the connections for the user. @@ -857,7 +805,7 @@ async def close_user_connections( request = build_close_user_connections_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, excluded=excluded, @@ -885,7 +833,6 @@ async def close_user_connections( @distributed_trace_async async def send_to_user( self, - hub: str, user_id: str, message: Union[IO, str, JSONType], **kwargs: Any @@ -894,9 +841,6 @@ async def send_to_user( Send content inside request body to the specific user. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: The user Id. :type user_id: str :param message: The payload body. @@ -933,7 +877,7 @@ async def send_to_user( ) request = build_send_to_user_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, content_type=content_type, @@ -962,7 +906,6 @@ async def send_to_user( @distributed_trace_async async def add_user_to_group( self, - hub: str, group: str, user_id: str, **kwargs: Any @@ -971,9 +914,6 @@ async def add_user_to_group( Add a user to the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param user_id: Target user Id. @@ -995,7 +935,7 @@ async def add_user_to_group( request = build_add_user_to_group_request( - hub=hub, + hub=self._config.hub, group=group, user_id=user_id, api_version=api_version, @@ -1022,7 +962,6 @@ async def add_user_to_group( @distributed_trace_async async def remove_user_from_group( self, - hub: str, group: str, user_id: str, **kwargs: Any @@ -1031,9 +970,6 @@ async def remove_user_from_group( Remove a user from the target group. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param group: Target group name, which length should be greater than 0 and less than 1025. :type group: str :param user_id: Target user Id. @@ -1055,7 +991,7 @@ async def remove_user_from_group( request = build_remove_user_from_group_request( - hub=hub, + hub=self._config.hub, group=group, user_id=user_id, api_version=api_version, @@ -1082,7 +1018,6 @@ async def remove_user_from_group( @distributed_trace_async async def remove_user_from_all_groups( self, - hub: str, user_id: str, **kwargs: Any ) -> None: @@ -1090,9 +1025,6 @@ async def remove_user_from_all_groups( Remove a user from all groups. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param user_id: Target user Id. :type user_id: str :keyword api_version: Api Version. The default value is "2021-10-01". Note that overriding this @@ -1112,7 +1044,7 @@ async def remove_user_from_all_groups( request = build_remove_user_from_all_groups_request( - hub=hub, + hub=self._config.hub, user_id=user_id, api_version=api_version, template_url=self.remove_user_from_all_groups.metadata['url'], @@ -1138,7 +1070,6 @@ async def remove_user_from_all_groups( @distributed_trace_async async def grant_permission( self, - hub: str, permission: str, connection_id: str, *, @@ -1149,9 +1080,6 @@ async def grant_permission( Grant permission to the connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param permission: The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: "sendToGroup" or "joinLeaveGroup". :type permission: str @@ -1177,7 +1105,7 @@ async def grant_permission( request = build_grant_permission_request( - hub=hub, + hub=self._config.hub, permission=permission, connection_id=connection_id, api_version=api_version, @@ -1205,7 +1133,6 @@ async def grant_permission( @distributed_trace_async async def revoke_permission( self, - hub: str, permission: str, connection_id: str, *, @@ -1216,9 +1143,6 @@ async def revoke_permission( Revoke permission for the connection. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param permission: The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: "sendToGroup" or "joinLeaveGroup". :type permission: str @@ -1244,7 +1168,7 @@ async def revoke_permission( request = build_revoke_permission_request( - hub=hub, + hub=self._config.hub, permission=permission, connection_id=connection_id, api_version=api_version, @@ -1272,7 +1196,6 @@ async def revoke_permission( @distributed_trace_async async def has_permission( self, - hub: str, permission: str, connection_id: str, *, @@ -1283,9 +1206,6 @@ async def has_permission( Check if a connection has permission to the specified action. - :param hub: Target hub name, which should start with alphabetic characters and only contain - alpha-numeric characters or underscore. - :type hub: str :param permission: The permission: current supported actions are joinLeaveGroup and sendToGroup. Possible values are: "sendToGroup" or "joinLeaveGroup". :type permission: str @@ -1311,7 +1231,7 @@ async def has_permission( request = build_has_permission_request( - hub=hub, + hub=self._config.hub, permission=permission, connection_id=connection_id, api_version=api_version, diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_web_pub_sub_service_client.py b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_web_pub_sub_service_client.py index 6ee270bc5bf6..340adac20cc3 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_web_pub_sub_service_client.py +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/aio/_web_pub_sub_service_client.py @@ -25,6 +25,9 @@ class WebPubSubServiceClient(WebPubSubServiceClientOperationsMixin): """WebPubSubServiceClient. + :param hub: Target hub name, which should start with alphabetic characters and only contain + alpha-numeric characters or underscore. + :type hub: str :param endpoint: HTTP or HTTPS endpoint for the Web PubSub service instance. :type endpoint: str :param credential: Credential needed for the client to connect to Azure. @@ -36,12 +39,13 @@ class WebPubSubServiceClient(WebPubSubServiceClientOperationsMixin): def __init__( self, + hub: str, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any ) -> None: _endpoint = '{Endpoint}' - self._config = WebPubSubServiceClientConfiguration(endpoint=endpoint, credential=credential, **kwargs) + self._config = WebPubSubServiceClientConfiguration(hub=hub, endpoint=endpoint, credential=credential, **kwargs) self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) self._serialize = Serializer() diff --git a/sdk/webpubsub/azure-messaging-webpubsubservice/swagger/README.md b/sdk/webpubsub/azure-messaging-webpubsubservice/swagger/README.md index d9baae2ca7e4..1e36db4cab71 100644 --- a/sdk/webpubsub/azure-messaging-webpubsubservice/swagger/README.md +++ b/sdk/webpubsub/azure-messaging-webpubsubservice/swagger/README.md @@ -82,4 +82,166 @@ directive: - from: swagger-document where: $["paths"]["/api/hubs/{hub}/:generateToken"].post transform: $["operationId"] = "GetClientAccessToken" -``` \ No newline at end of file +``` + +### Add hub to client on generate token + +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/:generateToken"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### SendToAll + +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/:send"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### ConnectionExistsImpl +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/connections/{connectionId}"].head.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### CloseConnection +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/connections/{connectionId}"].delete.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### SendToConnection +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/connections/{connectionId}/:send"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### GroupExistsImpl +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/groups/{group}"].head.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### SendToGroup +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/groups/{group}/:send"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### AddConnectionToGroup +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/groups/{group}/connections/{connectionId}"].put.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### RemoveConnectionFromGroup +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/groups/{group}/connections/{connectionId}"].delete.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### UserExistsImpl +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/users/{userId}"].head.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### SendToUser +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/users/{userId}/:send"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### AddUserToGroup +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/users/{userId}/groups/{group}"].put.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### RemoveUserFromGroup +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/users/{userId}/groups/{group}"].delete.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### RemoveUserFromAllGroups +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/users/{userId}/groups"].delete.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### GrantPermission +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}"].put.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### RevokePermission +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}"].delete.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### CheckPermission +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}"].head.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### CloseAllConnections +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/:closeConnections"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### CloseGroupConnections +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/groups/{group}/:closeConnections"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +``` + +### CloseUserConnections +``` yaml +directive: +- from: swagger-document + where: $.paths["/api/hubs/{hub}/users/{userId}/:closeConnections"].post.parameters["0"] + transform: $["x-ms-parameter-location"] = "client" +```