Skip to content

Commit b90e176

Browse files
authored
[WebPubSub] Release 1.1.0 for bug fix (#34492)
* init * resolve comments * resolve new comments * disabled some checks
1 parent 1763dab commit b90e176

File tree

12 files changed

+59
-58
lines changed

12 files changed

+59
-58
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# Release History
22

3-
## 1.1.0b2 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 1.1.0 (2024-02-28)
84

95
### Bugs Fixed
10-
11-
### Other Changes
6+
- Use the correct REST API parameter name `groups` in method `get_client_access_token`
7+
- 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
128

139
## 1.1.0b1 (2022-12-12)
1410

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def build_get_client_access_token_request(
7474
user_id: Optional[str] = None,
7575
roles: Optional[List[str]] = None,
7676
minutes_to_expire: int = 60,
77-
group: Optional[List[str]] = None,
77+
groups: Optional[List[str]] = None,
7878
**kwargs: Any
7979
) -> HttpRequest:
8080
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
@@ -99,8 +99,8 @@ def build_get_client_access_token_request(
9999
if minutes_to_expire is not None:
100100
_params["minutesToExpire"] = _SERIALIZER.query("minutes_to_expire", minutes_to_expire, "int", minimum=1)
101101
_params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
102-
if group is not None:
103-
_params["group"] = [_SERIALIZER.query("group", q, "str") if q is not None else "" for q in group]
102+
if groups is not None:
103+
_params["group"] = [_SERIALIZER.query("groups", q, "str") if q is not None else "" for q in groups]
104104

105105
# Construct headers
106106
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
@@ -691,7 +691,7 @@ def get_client_access_token(
691691
user_id: Optional[str] = None,
692692
roles: Optional[List[str]] = None,
693693
minutes_to_expire: int = 60,
694-
group: Optional[List[str]] = None,
694+
groups: Optional[List[str]] = None,
695695
**kwargs: Any
696696
) -> JSON:
697697
"""Generate token for the client to connect Azure Web PubSub service.
@@ -705,8 +705,8 @@ def get_client_access_token(
705705
:paramtype roles: list[str]
706706
:keyword minutes_to_expire: The expire time of the generated token. Default value is 60.
707707
:paramtype minutes_to_expire: int
708-
:keyword group: Groups that the connection will join when it connects. Default value is None.
709-
:paramtype group: list[str]
708+
:keyword groups: Groups that the connection will join when it connects. Default value is None.
709+
:paramtype groups: list[str]
710710
:return: JSON object
711711
:rtype: JSON
712712
:raises ~azure.core.exceptions.HttpResponseError:
@@ -738,7 +738,7 @@ def get_client_access_token(
738738
user_id=user_id,
739739
roles=roles,
740740
minutes_to_expire=minutes_to_expire,
741-
group=group,
741+
groups=groups,
742742
api_version=self._config.api_version,
743743
headers=_headers,
744744
params=_params,

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def get_token_by_key(endpoint: str, hub: str, key: str, **kwargs: Any) -> str:
7474
payload["role"] = roles
7575
if groups:
7676
payload["webpubsub.group"] = groups
77-
return jwt.encode(payload, key, algorithm="HS256", headers=kwargs.pop("jwt_headers", {})).decode("utf-8")
77+
encoded = jwt.encode(payload, key, algorithm="HS256", headers=kwargs.pop("jwt_headers", {}))
78+
return encoded
7879

7980

8081
class WebPubSubServiceClientOperationsMixin(WebPubSubServiceClientOperationsMixinGenerated):
@@ -88,6 +89,8 @@ def get_client_access_token(self, **kwargs: Any) -> JSON:
8889
:keyword minutes_to_expire: The expire time of the generated token.
8990
:paramtype minutes_to_expire: int
9091
:keyword dict[str, any] jwt_headers: Any headers you want to pass to jwt encoding.
92+
:keyword groups: Groups that the connection will join when it connects. Default value is None.
93+
:paramtype groups: list[str]
9194
:returns: JSON response containing the web socket endpoint, the token and a url with the generated access token.
9295
:rtype: JSON
9396
Example:
@@ -168,7 +171,6 @@ def send_to_all( # pylint: disable=inconsistent-return-statements
168171
"The content_type '{}' is not one of the allowed values: "
169172
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
170173
)
171-
172174
request = build_send_to_all_request(
173175
hub=self._config.hub,
174176
excluded=excluded,
@@ -194,7 +196,6 @@ def send_to_all( # pylint: disable=inconsistent-return-statements
194196
if response.status_code not in [202]:
195197
map_error(status_code=response.status_code, response=response, error_map=error_map)
196198
raise HttpResponseError(response=response)
197-
198199
if cls:
199200
return cls(pipeline_response, None, {})
200201

@@ -243,7 +244,6 @@ def send_to_user( # pylint: disable=inconsistent-return-statements
243244
"The content_type '{}' is not one of the allowed values: "
244245
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
245246
)
246-
247247
request = build_send_to_user_request(
248248
user_id=user_id,
249249
hub=self._config.hub,
@@ -269,7 +269,6 @@ def send_to_user( # pylint: disable=inconsistent-return-statements
269269
if response.status_code not in [202]:
270270
map_error(status_code=response.status_code, response=response, error_map=error_map)
271271
raise HttpResponseError(response=response)
272-
273272
if cls:
274273
return cls(pipeline_response, None, {})
275274

@@ -327,7 +326,6 @@ def send_to_group( # pylint: disable=inconsistent-return-statements
327326
"The content_type '{}' is not one of the allowed values: "
328327
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
329328
)
330-
331329
request = build_send_to_group_request(
332330
group=group,
333331
hub=self._config.hub,
@@ -354,7 +352,6 @@ def send_to_group( # pylint: disable=inconsistent-return-statements
354352
if response.status_code not in [202]:
355353
map_error(status_code=response.status_code, response=response, error_map=error_map)
356354
raise HttpResponseError(response=response)
357-
358355
if cls:
359356
return cls(pipeline_response, None, {})
360357

@@ -400,7 +397,6 @@ def send_to_connection( # pylint: disable=inconsistent-return-statements
400397
"The content_type '{}' is not one of the allowed values: "
401398
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
402399
)
403-
404400
request = build_send_to_connection_request(
405401
connection_id=connection_id,
406402
hub=self._config.hub,
@@ -425,7 +421,6 @@ def send_to_connection( # pylint: disable=inconsistent-return-statements
425421
if response.status_code not in [202]:
426422
map_error(status_code=response.status_code, response=response, error_map=error_map)
427423
raise HttpResponseError(response=response)
428-
429424
if cls:
430425
return cls(pipeline_response, None, {})
431426

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _encode(self, url: AzureKeyCredential) -> str:
109109
key=self._credential.key,
110110
algorithm="HS256",
111111
)
112-
return encoded.decode("utf-8")
112+
return encoded
113113

114114

115115
class ApiManagementProxy(ProxyPolicy):

sdk/webpubsub/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.1.0b2"
9+
VERSION = "1.1.0"

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def get_client_access_token(
121121
user_id: Optional[str] = None,
122122
roles: Optional[List[str]] = None,
123123
minutes_to_expire: int = 60,
124-
group: Optional[List[str]] = None,
124+
groups: Optional[List[str]] = None,
125125
**kwargs: Any
126126
) -> JSON:
127127
"""Generate token for the client to connect Azure Web PubSub service.
@@ -135,8 +135,8 @@ async def get_client_access_token(
135135
:paramtype roles: list[str]
136136
:keyword minutes_to_expire: The expire time of the generated token. Default value is 60.
137137
:paramtype minutes_to_expire: int
138-
:keyword group: Groups that the connection will join when it connects. Default value is None.
139-
:paramtype group: list[str]
138+
:keyword groups: Groups that the connection will join when it connects. Default value is None.
139+
:paramtype groups: list[str]
140140
:return: JSON object
141141
:rtype: JSON
142142
:raises ~azure.core.exceptions.HttpResponseError:
@@ -168,7 +168,7 @@ async def get_client_access_token(
168168
user_id=user_id,
169169
roles=roles,
170170
minutes_to_expire=minutes_to_expire,
171-
group=group,
171+
groups=groups,
172172
api_version=self._config.api_version,
173173
headers=_headers,
174174
params=_params,

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ async def send_to_all( # pylint: disable=inconsistent-return-statements
145145
"The content_type '{}' is not one of the allowed values: "
146146
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
147147
)
148-
149148
request = build_send_to_all_request(
150149
hub=self._config.hub,
151150
excluded=excluded,
@@ -171,7 +170,6 @@ async def send_to_all( # pylint: disable=inconsistent-return-statements
171170
if response.status_code not in [202]:
172171
map_error(status_code=response.status_code, response=response, error_map=error_map)
173172
raise HttpResponseError(response=response)
174-
175173
if cls:
176174
return cls(pipeline_response, None, {})
177175

@@ -229,7 +227,6 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements
229227
"The content_type '{}' is not one of the allowed values: "
230228
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
231229
)
232-
233230
request = build_send_to_group_request(
234231
group=group,
235232
hub=self._config.hub,
@@ -256,7 +253,6 @@ async def send_to_group( # pylint: disable=inconsistent-return-statements
256253
if response.status_code not in [202]:
257254
map_error(status_code=response.status_code, response=response, error_map=error_map)
258255
raise HttpResponseError(response=response)
259-
260256
if cls:
261257
return cls(pipeline_response, None, {})
262258

@@ -302,7 +298,6 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements
302298
"The content_type '{}' is not one of the allowed values: "
303299
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
304300
)
305-
306301
request = build_send_to_connection_request(
307302
connection_id=connection_id,
308303
hub=self._config.hub,
@@ -327,7 +322,6 @@ async def send_to_connection( # pylint: disable=inconsistent-return-statements
327322
if response.status_code not in [202]:
328323
map_error(status_code=response.status_code, response=response, error_map=error_map)
329324
raise HttpResponseError(response=response)
330-
331325
if cls:
332326
return cls(pipeline_response, None, {})
333327

@@ -376,7 +370,6 @@ async def send_to_user( # pylint: disable=inconsistent-return-statements
376370
"The content_type '{}' is not one of the allowed values: "
377371
"['application/json', 'application/octet-stream', 'text/plain']".format(content_type)
378372
)
379-
380373
request = build_send_to_user_request(
381374
user_id=user_id,
382375
hub=self._config.hub,
@@ -402,7 +395,6 @@ async def send_to_user( # pylint: disable=inconsistent-return-statements
402395
if response.status_code not in [202]:
403396
map_error(status_code=response.status_code, response=response, error_map=error_map)
404397
raise HttpResponseError(response=response)
405-
406398
if cls:
407399
return cls(pipeline_response, None, {})
408400

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.azure-sdk-build]
2+
pylint = false
3+
pyright = false
4+
mypy = false

sdk/webpubsub/azure-messaging-webpubsubservice/setup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@
3838
url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk",
3939
keywords="azure, azure sdk",
4040
classifiers=[
41-
"Development Status :: 7 - Inactive",
4241
"Programming Language :: Python",
4342
"Programming Language :: Python :: 3 :: Only",
4443
"Programming Language :: Python :: 3",
45-
"Programming Language :: Python :: 3.7",
4644
"Programming Language :: Python :: 3.8",
4745
"Programming Language :: Python :: 3.9",
4846
"Programming Language :: Python :: 3.10",
@@ -64,7 +62,7 @@
6462
install_requires=[
6563
"isodate<1.0.0,>=0.6.1",
6664
"azure-core<2.0.0,>=1.24.0",
67-
"pyjwt>=1.7.1",
65+
"pyjwt>=2.0.0"
6866
],
69-
python_requires=">=3.7",
67+
python_requires=">=3.8",
7068
)

sdk/webpubsub/azure-messaging-webpubsubservice/swagger/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ license-header: MICROSOFT_MIT_NO_VERSION
2828
python: true
2929
title: WebPubSubServiceClient
3030
head-as-boolean: true
31-
package-version: 1.1.0b1
31+
package-version: 1.1.0
3232
add-credential: true
3333
credential-scopes: https://webpubsub.azure.com/.default
3434
package-mode: dataplane
@@ -67,6 +67,10 @@ directive:
6767
where: $["paths"]["/api/hubs/{hub}/:generateToken"].post.parameters
6868
transform: >
6969
$[2]["x-ms-client-name"] = "roles"
70+
- from: swagger-document
71+
where: $["paths"]["/api/hubs/{hub}/:generateToken"].post.parameters
72+
transform: >
73+
$[5]["x-ms-client-name"] = "groups"
7074
```
7175
7276
```yaml

0 commit comments

Comments
 (0)