Skip to content

Commit 44edb70

Browse files
cqnguy23vicancy
andauthored
Rename ClientEndpointType to WebPubSubClientProtocol (Azure#41147)
* rename ClientEndpointType to ClientType * update changelog Co-authored-by: Liangying.Wei <[email protected]> * rename to WebPubSubClientAccess * change name to WebPubSubClientProtocol --------- Co-authored-by: chuongnguyen <[email protected]> Co-authored-by: Liangying.Wei <[email protected]>
1 parent f5f42b8 commit 44edb70

File tree

7 files changed

+29
-30
lines changed

7 files changed

+29
-30
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
### Features Added
66

7-
- Added a `clientEndpointType` option to `GenerateClientTokenOptions` to specify the type of client endpoint
8-
when generating token. This option can be used to generate token and client connection URL for a specific client endpoint type, such as `Default` or `MQTT`.
7+
- Added a `webPubSubClientProtocol` option to `GenerateClientTokenOptions` to specify the type of client when generating token. This option can be used to generate token and client connection URL for a specific client type, such as `Default` or `MQTT`.
98
- Added a `addConnectionsToGroups` method to `WebPubSubServiceClient` and `WebPubSubServiceAsyncClient` to add filtered connections to multiple groups.
109
- Migrated serialization to `azure-json` which offers implementation agnostic serialization, providing support for
1110
more serialization frameworks than just Jackson.

sdk/webpubsub/azure-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceAsyncClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.azure.messaging.webpubsub.implementation.WebPubSubUtil;
2222
import com.azure.messaging.webpubsub.implementation.WebPubSubsImpl;
2323
import com.azure.messaging.webpubsub.implementation.models.AddToGroupsRequest;
24-
import com.azure.messaging.webpubsub.models.ClientEndpointType;
24+
import com.azure.messaging.webpubsub.models.WebPubSubClientProtocol;
2525
import com.azure.messaging.webpubsub.models.GetClientAccessTokenOptions;
2626
import com.azure.messaging.webpubsub.models.WebPubSubClientAccessToken;
2727
import com.azure.messaging.webpubsub.models.WebPubSubContentType;
@@ -59,8 +59,8 @@ public final class WebPubSubServiceAsyncClient {
5959
*/
6060
@ServiceMethod(returns = ReturnType.SINGLE)
6161
public Mono<WebPubSubClientAccessToken> getClientAccessToken(GetClientAccessTokenOptions options) {
62-
final ClientEndpointType clientEndpointType = options.getClientEndpointType();
63-
final String path = clientEndpointType.equals(ClientEndpointType.MQTT)
62+
final WebPubSubClientProtocol webPubSubClientProtocol = options.getWebPubSubClientAccess();
63+
final String path = webPubSubClientProtocol.equals(WebPubSubClientProtocol.MQTT)
6464
? "clients/mqtt/hubs/" : "client/hubs/";
6565
if (this.keyCredential == null) {
6666
return this.serviceClient.generateClientTokenWithResponseAsync(hub,
@@ -91,8 +91,8 @@ static RequestOptions configureClientAccessTokenRequestOptions(GetClientAccessTo
9191
if (!CoreUtils.isNullOrEmpty(options.getGroups())) {
9292
options.getGroups().stream().forEach(groupName -> requestOptions.addQueryParam("group", groupName));
9393
}
94-
if (options.getClientEndpointType() != null) {
95-
requestOptions.addQueryParam("clientType", options.getClientEndpointType().toString());
94+
if (options.getWebPubSubClientAccess() != null) {
95+
requestOptions.addQueryParam("clientType", options.getWebPubSubClientAccess().toString());
9696
}
9797
return requestOptions;
9898
}

sdk/webpubsub/azure-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/WebPubSubServiceClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.azure.messaging.webpubsub.implementation.WebPubSubUtil;
2020
import com.azure.messaging.webpubsub.implementation.WebPubSubsImpl;
2121
import com.azure.messaging.webpubsub.implementation.models.AddToGroupsRequest;
22-
import com.azure.messaging.webpubsub.models.ClientEndpointType;
22+
import com.azure.messaging.webpubsub.models.WebPubSubClientProtocol;
2323
import com.azure.messaging.webpubsub.models.GetClientAccessTokenOptions;
2424
import com.azure.messaging.webpubsub.models.WebPubSubClientAccessToken;
2525
import com.azure.messaging.webpubsub.models.WebPubSubContentType;
@@ -60,8 +60,8 @@ public final class WebPubSubServiceClient {
6060
*/
6161
@ServiceMethod(returns = ReturnType.SINGLE)
6262
public WebPubSubClientAccessToken getClientAccessToken(GetClientAccessTokenOptions options) {
63-
final ClientEndpointType clientEndpointType = options.getClientEndpointType();
64-
final String path = clientEndpointType.equals(ClientEndpointType.MQTT)
63+
final WebPubSubClientProtocol webPubSubClientProtocol = options.getWebPubSubClientAccess();
64+
final String path = webPubSubClientProtocol.equals(WebPubSubClientProtocol.MQTT)
6565
? "clients/mqtt/hubs/" : "client/hubs/";
6666
if (this.keyCredential == null) {
6767
Response<BinaryData> response = serviceClient.generateClientTokenWithResponse(hub,

sdk/webpubsub/azure-messaging-webpubsub/src/main/java/com/azure/messaging/webpubsub/models/GetClientAccessTokenOptions.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public final class GetClientAccessTokenOptions {
2020
private String userId;
2121
private List<String> roles;
2222
private List<String> groups;
23-
private ClientEndpointType clientEndpointType;
23+
private WebPubSubClientProtocol webPubSubClientProtocol;
2424

2525
/**
2626
* Creates an instance of GetClientAccessTokenOptions.
2727
*/
2828
public GetClientAccessTokenOptions() {
29-
this.clientEndpointType = ClientEndpointType.DEFAULT;
29+
this.webPubSubClientProtocol = WebPubSubClientProtocol.DEFAULT;
3030
}
3131

3232
/**
@@ -130,18 +130,18 @@ public GetClientAccessTokenOptions setGroups(List<String> groups) {
130130
*
131131
* @return The same instance of this type, modified based on the value provided in this set method.
132132
*/
133-
public ClientEndpointType getClientEndpointType() {
134-
return clientEndpointType;
133+
public WebPubSubClientProtocol getWebPubSubClientAccess() {
134+
return webPubSubClientProtocol;
135135
}
136136

137137
/**
138138
* Specifies the endpoint type of the client. Default type is <code>default</code>
139139
*
140-
* @param clientEndpointType The endpoint type of client
140+
* @param webPubSubClientProtocol The endpoint type of client
141141
* @return The same instance of this type, modified based on the value provided in this set method.
142142
*/
143-
public GetClientAccessTokenOptions setClientEndpointType(final ClientEndpointType clientEndpointType) {
144-
this.clientEndpointType = clientEndpointType;
143+
public GetClientAccessTokenOptions setWebPubSubClientAccess(final WebPubSubClientProtocol webPubSubClientProtocol) {
144+
this.webPubSubClientProtocol = webPubSubClientProtocol;
145145
return this;
146146
}
147147

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package com.azure.messaging.webpubsub.models;
55

66
/**
7-
* Defines values for ClientEndpointType
7+
* Defines values for WebPubSubClientProtocol
88
*/
9-
public enum ClientEndpointType {
9+
public enum WebPubSubClientProtocol {
1010
/**
1111
* Default WebPubSub Client Endpoint. E.g: <code>wss://exampleHost.com/client/hubs/exampleHub</code>
1212
*/
@@ -18,23 +18,23 @@ public enum ClientEndpointType {
1818
MQTT("mqtt");
1919

2020
/**
21-
* The actual serialized value for a ClientEndpointType.
21+
* The actual serialized value for a WebPubSubClientProtocol.
2222
*/
2323
private final String value;
2424

25-
ClientEndpointType(String value) {
25+
WebPubSubClientProtocol(String value) {
2626
this.value = value;
2727
}
2828

2929
/**
30-
* Parses a serialized value to a ClientEndpointType instance.
30+
* Parses a serialized value to a WebPubSubClientProtocol instance.
3131
*
3232
* @param value the serialized value to parse.
33-
* @return the parsed ClientEndpointType object, or null if unable to parse.
33+
* @return the parsed WebPubSubClientProtocol object, or null if unable to parse.
3434
*/
35-
public static ClientEndpointType fromString(String value) {
36-
ClientEndpointType[] items = ClientEndpointType.values();
37-
for (ClientEndpointType item : items) {
35+
public static WebPubSubClientProtocol fromString(String value) {
36+
WebPubSubClientProtocol[] items = WebPubSubClientProtocol.values();
37+
for (WebPubSubClientProtocol item : items) {
3838
if (item.toString().equalsIgnoreCase(value)) {
3939
return item;
4040
}

sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceAsyncClientTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.azure.core.test.annotation.LiveOnly;
1717
import com.azure.core.util.BinaryData;
1818
import com.azure.identity.DefaultAzureCredentialBuilder;
19-
import com.azure.messaging.webpubsub.models.ClientEndpointType;
19+
import com.azure.messaging.webpubsub.models.WebPubSubClientProtocol;
2020
import com.azure.messaging.webpubsub.models.GetClientAccessTokenOptions;
2121
import com.azure.messaging.webpubsub.models.WebPubSubContentType;
2222
import com.azure.messaging.webpubsub.models.WebPubSubPermission;
@@ -276,7 +276,7 @@ public void testGetAuthenticationToken() {
276276
@LiveOnly
277277
public void testGetMqttAuthenticationToken() {
278278
GetClientAccessTokenOptions options = new GetClientAccessTokenOptions();
279-
options.setClientEndpointType(ClientEndpointType.MQTT);
279+
options.setWebPubSubClientAccess(WebPubSubClientProtocol.MQTT);
280280
StepVerifier.create(client.getClientAccessToken(options))
281281
.assertNext(token -> {
282282
Assertions.assertNotNull(token);

sdk/webpubsub/azure-messaging-webpubsub/src/test/java/com/azure/messaging/webpubsub/WebPubSubServiceClientTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import com.azure.core.test.annotation.LiveOnly;
1717
import com.azure.core.util.BinaryData;
1818
import com.azure.identity.DefaultAzureCredentialBuilder;
19-
import com.azure.messaging.webpubsub.models.ClientEndpointType;
19+
import com.azure.messaging.webpubsub.models.WebPubSubClientProtocol;
2020
import com.azure.messaging.webpubsub.models.GetClientAccessTokenOptions;
2121
import com.azure.messaging.webpubsub.models.WebPubSubClientAccessToken;
2222
import com.azure.messaging.webpubsub.models.WebPubSubContentType;
@@ -244,7 +244,7 @@ public void testGetAuthenticationToken() throws ParseException {
244244
@LiveOnly
245245
public void testGetMqttAuthenticationToken() throws ParseException {
246246
GetClientAccessTokenOptions options = new GetClientAccessTokenOptions()
247-
.setClientEndpointType(ClientEndpointType.MQTT);
247+
.setWebPubSubClientAccess(WebPubSubClientProtocol.MQTT);
248248
WebPubSubClientAccessToken token = client.getClientAccessToken(options);
249249

250250
Assertions.assertNotNull(token);

0 commit comments

Comments
 (0)