Skip to content

Commit

Permalink
Release Python WebPubSub SDK (Azure#36807)
Browse files Browse the repository at this point in the history
* remove unnecessary params

* change release date

* remove unnecessary params

* remove add_connections_to_groups and remove_connections_to_groups

---------

Co-authored-by: Chuong Nguyen <[email protected]>
  • Loading branch information
cqnguy23 and cqnguy23 authored Aug 9, 2024
1 parent 131e9ab commit d805e21
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 589 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.2.0 (2024-08-02)
## 1.2.0 (2024-08-08)

### Features Added
- Change API version to `2024-01-01`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,6 @@
_SERIALIZER.client_side_validation = False


def build_web_pub_sub_service_add_connections_to_groups_request( # pylint: disable=name-too-long
hub: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
_url = "/api/hubs/{hub}/:addToGroups"
path_format_arguments = {
"hub": _SERIALIZER.url("hub", hub, "str", pattern=r"^[A-Za-z][A-Za-z0-9_`,.[\]]{0,127}$"),
}

_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_web_pub_sub_service_close_all_connections_request( # pylint: disable=name-too-long
hub: str, *, excluded: Optional[List[str]] = None, reason: Optional[str] = None, **kwargs: Any
) -> HttpRequest:
Expand Down Expand Up @@ -140,35 +111,6 @@ def build_web_pub_sub_service_get_client_access_token_request( # pylint: disabl
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_web_pub_sub_service_remove_connections_from_groups_request( # pylint: disable=name-too-long
hub: str, **kwargs: Any
) -> HttpRequest:
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01"))
accept = _headers.pop("Accept", "application/json")

# Construct URL
_url = "/api/hubs/{hub}/:removeFromGroups"
path_format_arguments = {
"hub": _SERIALIZER.url("hub", hub, "str", pattern=r"^[A-Za-z][A-Za-z0-9_`,.[\]]{0,127}$"),
}

_url: str = _url.format(**path_format_arguments) # type: ignore

# Construct parameters
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")

# Construct headers
if content_type is not None:
_headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")

return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)


def build_web_pub_sub_service_send_to_all_request( # pylint: disable=name-too-long
hub: str,
*,
Expand Down Expand Up @@ -739,138 +681,6 @@ def build_web_pub_sub_service_add_user_to_group_request( # pylint: disable=name

class WebPubSubServiceClientOperationsMixin(WebPubSubServiceClientMixinABC): # pylint: disable=too-many-public-methods

@overload
def add_connections_to_groups( # pylint: disable=inconsistent-return-statements
self, hub: str, groups_to_add: JSON, *, content_type: str = "application/json", **kwargs: Any
) -> None:
"""Add filtered connections to multiple groups.
Add filtered connections to multiple groups.
:param hub: Target hub name, which should start with alphabetic characters and only contain
alpha-numeric characters or underscore. Required.
:type hub: str
:param groups_to_add: Target groups and connection filter. Required.
:type groups_to_add: JSON
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Example:
.. code-block:: python
# JSON input template you can fill out and use as your body input.
groups_to_add = {
"filter": "str",
"groups": [
"str"
]
}
"""

@overload
def add_connections_to_groups( # pylint: disable=inconsistent-return-statements
self, hub: str, groups_to_add: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
) -> None:
"""Add filtered connections to multiple groups.
Add filtered connections to multiple groups.
:param hub: Target hub name, which should start with alphabetic characters and only contain
alpha-numeric characters or underscore. Required.
:type hub: str
:param groups_to_add: Target groups and connection filter. Required.
:type groups_to_add: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace
def add_connections_to_groups( # pylint: disable=inconsistent-return-statements
self, hub: str, groups_to_add: Union[JSON, IO[bytes]], **kwargs: Any
) -> None:
"""Add filtered connections to multiple groups.
Add filtered connections to multiple groups.
:param hub: Target hub name, which should start with alphabetic characters and only contain
alpha-numeric characters or underscore. Required.
:type hub: str
:param groups_to_add: Target groups and connection filter. Is either a JSON type or a IO[bytes]
type. Required.
:type groups_to_add: JSON or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Example:
.. code-block:: python
# JSON input template you can fill out and use as your body input.
groups_to_add = {
"filter": "str",
"groups": [
"str"
]
}
"""
error_map: MutableMapping[int, Type[HttpResponseError]] = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = kwargs.pop("params", {}) or {}

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)

content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(groups_to_add, (IOBase, bytes)):
_content = groups_to_add
else:
_json = groups_to_add

_request = build_web_pub_sub_service_add_connections_to_groups_request(
hub=hub,
content_type=content_type,
api_version=self._config.api_version,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}
_request.url = self._client.format_url(_request.url, **path_format_arguments)

_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

if cls:
return cls(pipeline_response, None, {}) # type: ignore

@distributed_trace
def close_all_connections( # pylint: disable=inconsistent-return-statements
self, *, excluded: Optional[List[str]] = None, reason: Optional[str] = None, **kwargs: Any
Expand Down Expand Up @@ -1018,138 +828,6 @@ def get_client_access_token(

return cast(JSON, deserialized) # type: ignore

@overload
def remove_connections_from_groups( # pylint: disable=inconsistent-return-statements
self, hub: str, groups_to_remove: JSON, *, content_type: str = "application/json", **kwargs: Any
) -> None:
"""Remove filtered connections from multiple groups.
Remove filtered connections from multiple groups.
:param hub: Target hub name, which should start with alphabetic characters and only contain
alpha-numeric characters or underscore. Required.
:type hub: str
:param groups_to_remove: Target groups and connection filter. Required.
:type groups_to_remove: JSON
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Example:
.. code-block:: python
# JSON input template you can fill out and use as your body input.
groups_to_remove = {
"filter": "str",
"groups": [
"str"
]
}
"""

@overload
def remove_connections_from_groups( # pylint: disable=inconsistent-return-statements
self, hub: str, groups_to_remove: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
) -> None:
"""Remove filtered connections from multiple groups.
Remove filtered connections from multiple groups.
:param hub: Target hub name, which should start with alphabetic characters and only contain
alpha-numeric characters or underscore. Required.
:type hub: str
:param groups_to_remove: Target groups and connection filter. Required.
:type groups_to_remove: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace
def remove_connections_from_groups( # pylint: disable=inconsistent-return-statements
self, hub: str, groups_to_remove: Union[JSON, IO[bytes]], **kwargs: Any
) -> None:
"""Remove filtered connections from multiple groups.
Remove filtered connections from multiple groups.
:param hub: Target hub name, which should start with alphabetic characters and only contain
alpha-numeric characters or underscore. Required.
:type hub: str
:param groups_to_remove: Target groups and connection filter. Is either a JSON type or a
IO[bytes] type. Required.
:type groups_to_remove: JSON or IO[bytes]
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
Example:
.. code-block:: python
# JSON input template you can fill out and use as your body input.
groups_to_remove = {
"filter": "str",
"groups": [
"str"
]
}
"""
error_map: MutableMapping[int, Type[HttpResponseError]] = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = kwargs.pop("params", {}) or {}

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[None] = kwargs.pop("cls", None)

content_type = content_type or "application/json"
_json = None
_content = None
if isinstance(groups_to_remove, (IOBase, bytes)):
_content = groups_to_remove
else:
_json = groups_to_remove

_request = build_web_pub_sub_service_remove_connections_from_groups_request(
hub=hub,
content_type=content_type,
api_version=self._config.api_version,
json=_json,
content=_content,
headers=_headers,
params=_params,
)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}
_request.url = self._client.format_url(_request.url, **path_format_arguments)

_stream = False
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

if cls:
return cls(pipeline_response, None, {}) # type: ignore

@distributed_trace
def send_to_all( # pylint: disable=inconsistent-return-statements
self,
Expand Down
Loading

0 comments on commit d805e21

Please sign in to comment.