deleteMessageWithResponse(String conversationId, String messageId,
+ RequestOptions requestOptions) {
+ return service.deleteMessageSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ conversationId, messageId, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Update a message.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * createdBy: String (Optional, Required on create)
+ * content (Optional, Required on create): {
+ * text: String (Optional)
+ * binary: byte[] (Optional)
+ * }
+ * createdAt: OffsetDateTime (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * createdBy: String (Optional, Required on create)
+ * content (Optional, Required on create): {
+ * text: String (Optional)
+ * binary: byte[] (Optional)
+ * }
+ * createdAt: OffsetDateTime (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param conversationId Conversation identifier.
+ * @param messageId Message identifier.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a chat message along with {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> updateMessageWithResponseAsync(String conversationId, String messageId,
+ BinaryData resource, RequestOptions requestOptions) {
+ final String contentType = "application/merge-patch+json";
+ final String accept = "application/json";
+ return FluxUtil
+ .withContext(context -> service.updateMessage(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), conversationId, messageId, contentType, accept, resource, requestOptions, context));
+ }
+
+ /**
+ * Update a message.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * createdBy: String (Optional, Required on create)
+ * content (Optional, Required on create): {
+ * text: String (Optional)
+ * binary: byte[] (Optional)
+ * }
+ * createdAt: OffsetDateTime (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * createdBy: String (Optional, Required on create)
+ * content (Optional, Required on create): {
+ * text: String (Optional)
+ * binary: byte[] (Optional)
+ * }
+ * createdAt: OffsetDateTime (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param conversationId Conversation identifier.
+ * @param messageId Message identifier.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a chat message along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response updateMessageWithResponse(String conversationId, String messageId, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/merge-patch+json";
+ final String accept = "application/json";
+ return service.updateMessageSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ conversationId, messageId, contentType, accept, resource, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Query roles in a hub.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatRole items along with {@link PagedResponse} on successful completion of
+ * {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private Mono> listRolesSinglePageAsync(RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil
+ .withContext(context -> service.listRoles(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), accept, requestOptions, context))
+ .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null));
+ }
+
+ /**
+ * Query roles in a hub.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatRole items as paginated response with {@link PagedFlux}.
+ */
+ @ServiceMethod(returns = ReturnType.COLLECTION)
+ public PagedFlux listRolesAsync(RequestOptions requestOptions) {
+ RequestOptions requestOptionsForNextPage = new RequestOptions();
+ requestOptionsForNextPage.setContext(
+ requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE);
+ return new PagedFlux<>((pageSize) -> {
+ RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRolesSinglePageAsync(requestOptionsLocal);
+ }, (nextLink, pageSize) -> {
+ RequestOptions requestOptionsLocal = new RequestOptions();
+ requestOptionsLocal.setContext(requestOptionsForNextPage.getContext());
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRolesNextSinglePageAsync(nextLink, requestOptionsLocal);
+ });
+ }
+
+ /**
+ * Query roles in a hub.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatRole items along with {@link PagedResponse}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private PagedResponse listRolesSinglePage(RequestOptions requestOptions) {
+ final String accept = "application/json";
+ Response res = service.listRolesSync(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), accept, requestOptions, Context.NONE);
+ return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null);
+ }
+
+ /**
+ * Query roles in a hub.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatRole items as paginated response with {@link PagedIterable}.
+ */
+ @ServiceMethod(returns = ReturnType.COLLECTION)
+ public PagedIterable listRoles(RequestOptions requestOptions) {
+ RequestOptions requestOptionsForNextPage = new RequestOptions();
+ requestOptionsForNextPage.setContext(
+ requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE);
+ return new PagedIterable<>((pageSize) -> {
+ RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRolesSinglePage(requestOptionsLocal);
+ }, (nextLink, pageSize) -> {
+ RequestOptions requestOptionsLocal = new RequestOptions();
+ requestOptionsLocal.setContext(requestOptionsForNextPage.getContext());
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRolesNextSinglePage(nextLink, requestOptionsLocal);
+ });
+ }
+
+ /**
+ * Get role information.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roleName Role name. Must start with 'user.' or 'room.' prefix.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return role information along with {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> getRoleWithResponseAsync(String roleName, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.getRole(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), roleName, accept, requestOptions, context));
+ }
+
+ /**
+ * Get role information.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roleName Role name. Must start with 'user.' or 'room.' prefix.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return role information along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response getRoleWithResponse(String roleName, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return service.getRoleSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roleName,
+ accept, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Create or replace a role.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param roleName Role name. Must start with 'user.' or 'room.' prefix.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a chat role.
+ * A role name must start with 'user.' or 'room.' prefix.
+ * A role must contain either user permissions or room permissions, but not both along with {@link Response} on
+ * successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createOrReplaceRoleWithResponseAsync(String roleName, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context -> service.createOrReplaceRole(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), roleName, contentType, accept, resource, requestOptions, context));
+ }
+
+ /**
+ * Create or replace a role.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param roleName Role name. Must start with 'user.' or 'room.' prefix.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a chat role.
+ * A role name must start with 'user.' or 'room.' prefix.
+ * A role must contain either user permissions or room permissions, but not both along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createOrReplaceRoleWithResponse(String roleName, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.createOrReplaceRoleSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ roleName, contentType, accept, resource, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Delete a role.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param roleName Role name. Must start with 'user.' or 'room.' prefix.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> deleteRoleWithResponseAsync(String roleName, RequestOptions requestOptions) {
+ return FluxUtil.withContext(context -> service.deleteRole(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), roleName, requestOptions, context));
+ }
+
+ /**
+ * Delete a role.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param roleName Role name. Must start with 'user.' or 'room.' prefix.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response deleteRoleWithResponse(String roleName, RequestOptions requestOptions) {
+ return service.deleteRoleSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ roleName, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Create or replace a room.
+ *
+ * Create or replace a room with a client-specified ID.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * title: String (Required)
+ * defaultConversation: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * title: String (Required)
+ * defaultConversation: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param roomId Room identifier.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a chat room along with {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createOrReplaceRoomWithResponseAsync(String roomId, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context -> service.createOrReplaceRoom(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), roomId, contentType, accept, resource, requestOptions, context));
+ }
+
+ /**
+ * Create or replace a room.
+ *
+ * Create or replace a room with a client-specified ID.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * title: String (Required)
+ * defaultConversation: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * title: String (Required)
+ * defaultConversation: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param roomId Room identifier.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a chat room along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createOrReplaceRoomWithResponse(String roomId, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.createOrReplaceRoomSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ roomId, contentType, accept, resource, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Get room information.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * title: String (Required)
+ * defaultConversation: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room information along with {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> getRoomWithResponseAsync(String roomId, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.getRoom(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), roomId, accept, requestOptions, context));
+ }
+
+ /**
+ * Get room information.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * title: String (Required)
+ * defaultConversation: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room information along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response getRoomWithResponse(String roomId, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return service.getRoomSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId,
+ accept, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Delete a room.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> deleteRoomWithResponseAsync(String roomId, RequestOptions requestOptions) {
+ return FluxUtil.withContext(context -> service.deleteRoom(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), roomId, requestOptions, context));
+ }
+
+ /**
+ * Delete a room.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response deleteRoomWithResponse(String roomId, RequestOptions requestOptions) {
+ return service.deleteRoomSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), roomId,
+ requestOptions, Context.NONE);
+ }
+
+ /**
+ * Get room members.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room members along with {@link PagedResponse} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private Mono> listRoomMembersSinglePageAsync(String roomId,
+ RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil
+ .withContext(context -> service.listRoomMembers(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), roomId, accept, requestOptions, context))
+ .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null));
+ }
+
+ /**
+ * Get room members.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room members as paginated response with {@link PagedFlux}.
+ */
+ @ServiceMethod(returns = ReturnType.COLLECTION)
+ public PagedFlux listRoomMembersAsync(String roomId, RequestOptions requestOptions) {
+ RequestOptions requestOptionsForNextPage = new RequestOptions();
+ requestOptionsForNextPage.setContext(
+ requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE);
+ return new PagedFlux<>((pageSize) -> {
+ RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRoomMembersSinglePageAsync(roomId, requestOptionsLocal);
+ }, (nextLink, pageSize) -> {
+ RequestOptions requestOptionsLocal = new RequestOptions();
+ requestOptionsLocal.setContext(requestOptionsForNextPage.getContext());
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRoomMembersNextSinglePageAsync(nextLink, requestOptionsLocal);
+ });
+ }
+
+ /**
+ * Get room members.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room members along with {@link PagedResponse}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private PagedResponse listRoomMembersSinglePage(String roomId, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ Response res = service.listRoomMembersSync(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), roomId, accept, requestOptions, Context.NONE);
+ return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null);
+ }
+
+ /**
+ * Get room members.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | maxpagesize | Integer | No | The maximum number of result items per page. |
+ * | continuationToken | String | No | Continuation token for pagination. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param roomId Room identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room members as paginated response with {@link PagedIterable}.
+ */
+ @ServiceMethod(returns = ReturnType.COLLECTION)
+ public PagedIterable listRoomMembers(String roomId, RequestOptions requestOptions) {
+ RequestOptions requestOptionsForNextPage = new RequestOptions();
+ requestOptionsForNextPage.setContext(
+ requestOptions != null && requestOptions.getContext() != null ? requestOptions.getContext() : Context.NONE);
+ return new PagedIterable<>((pageSize) -> {
+ RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions;
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRoomMembersSinglePage(roomId, requestOptionsLocal);
+ }, (nextLink, pageSize) -> {
+ RequestOptions requestOptionsLocal = new RequestOptions();
+ requestOptionsLocal.setContext(requestOptionsForNextPage.getContext());
+ if (pageSize != null) {
+ requestOptionsLocal.addRequestCallback(requestLocal -> {
+ UrlBuilder urlBuilder = UrlBuilder.parse(requestLocal.getUrl());
+ urlBuilder.setQueryParameter("maxpagesize", String.valueOf(pageSize));
+ requestLocal.setUrl(urlBuilder.toString());
+ });
+ }
+ return listRoomMembersNextSinglePage(nextLink, requestOptionsLocal);
+ });
+ }
+
+ /**
+ * Create or replace a room member.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param roomId Room identifier.
+ * @param userId User ID of the member.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a room member along with {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createOrReplaceRoomMemberWithResponseAsync(String roomId, String userId,
+ BinaryData resource, RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context -> service.createOrReplaceRoomMember(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, context));
+ }
+
+ /**
+ * Create or replace a room member.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param roomId Room identifier.
+ * @param userId User ID of the member.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a room member along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createOrReplaceRoomMemberWithResponse(String roomId, String userId, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.createOrReplaceRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), roomId, userId, contentType, accept, resource, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Delete a room member.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param roomId Room identifier.
+ * @param userId User ID of the member.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> deleteRoomMemberWithResponseAsync(String roomId, String userId,
+ RequestOptions requestOptions) {
+ return FluxUtil.withContext(context -> service.deleteRoomMember(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), roomId, userId, requestOptions, context));
+ }
+
+ /**
+ * Delete a room member.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param roomId Room identifier.
+ * @param userId User ID of the member.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response deleteRoomMemberWithResponse(String roomId, String userId, RequestOptions requestOptions) {
+ return service.deleteRoomMemberSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ roomId, userId, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Get a user's profile.
+ *
+ * Get a user's profile. The response is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the `kind`
+ * discriminator.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * kind: String(Human) (Required)
+ * id: String (Required)
+ * nickname: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param userId User identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return a user's profile.
+ *
+ * Get a user's profile along with {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> getUserWithResponseAsync(String userId, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.getUser(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), userId, accept, requestOptions, context));
+ }
+
+ /**
+ * Get a user's profile.
+ *
+ * Get a user's profile. The response is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the `kind`
+ * discriminator.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * kind: String(Human) (Required)
+ * id: String (Required)
+ * nickname: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param userId User identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return a user's profile.
+ *
+ * Get a user's profile along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response getUserWithResponse(String userId, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return service.getUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), userId,
+ accept, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Create or replace a user.
+ *
+ * Create or replace a user. The request body is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the
+ * `kind` discriminator.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * kind: String(Human) (Required)
+ * id: String (Required)
+ * nickname: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * kind: String(Human) (Required)
+ * id: String (Required)
+ * nickname: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param userId User identifier.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a user profile in the chat system along with {@link Response} on successful completion of
+ * {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> createOrReplaceUserWithResponseAsync(String userId, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return FluxUtil.withContext(
+ context -> service.createOrReplaceUser(this.getEndpoint(), this.getServiceVersion().getVersion(),
+ this.getHub(), userId, contentType, accept, resource, requestOptions, context));
+ }
+
+ /**
+ * Create or replace a user.
+ *
+ * Create or replace a user. The request body is a polymorphic `ChatUser` (e.g. `HumanChatUser`) selected by the
+ * `kind` discriminator.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ * Request Body Schema
+ *
+ *
+ * {@code
+ * {
+ * kind: String(Human) (Required)
+ * id: String (Required)
+ * nickname: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * kind: String(Human) (Required)
+ * id: String (Required)
+ * nickname: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * Response Headers
+ *
+ * Response Headers
+ * | Name | Type | Description |
+ * | ETag | String | The entity tag for the response. |
+ *
+ *
+ * @param userId User identifier.
+ * @param resource The resource instance.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return represents a user profile in the chat system along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response createOrReplaceUserWithResponse(String userId, BinaryData resource,
+ RequestOptions requestOptions) {
+ final String contentType = "application/json";
+ final String accept = "application/json";
+ return service.createOrReplaceUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(),
+ userId, contentType, accept, resource, requestOptions, Context.NONE);
+ }
+
+ /**
+ * Delete a user.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param userId User identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> deleteUserWithResponseAsync(String userId, RequestOptions requestOptions) {
+ return FluxUtil.withContext(context -> service.deleteUser(this.getEndpoint(),
+ this.getServiceVersion().getVersion(), this.getHub(), userId, requestOptions, context));
+ }
+
+ /**
+ * Delete a user.
+ * Header Parameters
+ *
+ * Header Parameters
+ * | Name | Type | Required | Description |
+ * | If-Match | String | No | The request should only proceed if an entity matches this
+ * string. |
+ * | If-None-Match | String | No | The request should only proceed if no entity matches this
+ * string. |
+ *
+ * You can add these to a request with {@link RequestOptions#addHeader}
+ *
+ * @param userId User identifier.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return the {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response deleteUserWithResponse(String userId, RequestOptions requestOptions) {
+ return service.deleteUserSync(this.getEndpoint(), this.getServiceVersion().getVersion(), this.getHub(), userId,
+ requestOptions, Context.NONE);
+ }
+
+ /**
+ * Generate a token for connecting a client to Azure Web PubSub.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | userId | String | No | User identifier for the client connection. |
+ * | role | List<String> | No | Roles granted to the client connection. Call
+ * {@link RequestOptions#addQueryParam} to add string to array. |
+ * | minutesToExpire | Integer | No | Lifetime of the generated token, in minutes. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * token: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param hub Target hub name.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return response containing a Web PubSub client access token along with {@link Response} on successful completion
+ * of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Mono> generateClientTokenWithResponseAsync(String hub, RequestOptions requestOptions) {
+ final String apiVersion = "2024-12-01";
+ final String clientType = "default";
+ final String accept = "application/json";
+ return FluxUtil.withContext(context -> service.generateClientToken(this.getEndpoint(), hub, apiVersion,
+ clientType, accept, requestOptions, context));
+ }
+
+ /**
+ * Generate a token for connecting a client to Azure Web PubSub.
+ * Query Parameters
+ *
+ * Query Parameters
+ * | Name | Type | Required | Description |
+ * | userId | String | No | User identifier for the client connection. |
+ * | role | List<String> | No | Roles granted to the client connection. Call
+ * {@link RequestOptions#addQueryParam} to add string to array. |
+ * | minutesToExpire | Integer | No | Lifetime of the generated token, in minutes. |
+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam}
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * token: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param hub Target hub name.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return response containing a Web PubSub client access token along with {@link Response}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ public Response generateClientTokenWithResponse(String hub, RequestOptions requestOptions) {
+ final String apiVersion = "2024-12-01";
+ final String clientType = "default";
+ final String accept = "application/json";
+ return service.generateClientTokenSync(this.getEndpoint(), hub, apiVersion, clientType, accept, requestOptions,
+ Context.NONE);
+ }
+
+ /**
+ * Query messages in a conversation from latest to earliest.
+ *
+ * Get the next page of items.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * createdBy: String (Optional, Required on create)
+ * content (Optional, Required on create): {
+ * text: String (Optional)
+ * binary: byte[] (Optional)
+ * }
+ * createdAt: OffsetDateTime (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param nextLink The URL to get the next list of items.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatMessage items along with {@link PagedResponse} on successful completion of
+ * {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private Mono> listMessagesNextSinglePageAsync(String nextLink,
+ RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil
+ .withContext(
+ context -> service.listMessagesNext(nextLink, this.getEndpoint(), accept, requestOptions, context))
+ .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null));
+ }
+
+ /**
+ * Query messages in a conversation from latest to earliest.
+ *
+ * Get the next page of items.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * id: String (Required)
+ * createdBy: String (Optional, Required on create)
+ * content (Optional, Required on create): {
+ * text: String (Optional)
+ * binary: byte[] (Optional)
+ * }
+ * createdAt: OffsetDateTime (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param nextLink The URL to get the next list of items.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatMessage items along with {@link PagedResponse}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private PagedResponse listMessagesNextSinglePage(String nextLink, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ Response res
+ = service.listMessagesNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE);
+ return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null);
+ }
+
+ /**
+ * Query roles in a hub.
+ *
+ * Get the next page of items.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param nextLink The URL to get the next list of items.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatRole items along with {@link PagedResponse} on successful completion of
+ * {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private Mono> listRolesNextSinglePageAsync(String nextLink,
+ RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil
+ .withContext(
+ context -> service.listRolesNext(nextLink, this.getEndpoint(), accept, requestOptions, context))
+ .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null));
+ }
+
+ /**
+ * Query roles in a hub.
+ *
+ * Get the next page of items.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * name: String (Required)
+ * permissions (Required): [
+ * String(user.create_room/user.fetch_all_rooms/room.publish_message/room.history/room.invite/room.remove_user) (Required)
+ * ]
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param nextLink The URL to get the next list of items.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return paged collection of ChatRole items along with {@link PagedResponse}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private PagedResponse listRolesNextSinglePage(String nextLink, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ Response res
+ = service.listRolesNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE);
+ return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null);
+ }
+
+ /**
+ * Get room members.
+ *
+ * Get the next page of items.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param nextLink The URL to get the next list of items.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room members along with {@link PagedResponse} on successful completion of {@link Mono}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private Mono> listRoomMembersNextSinglePageAsync(String nextLink,
+ RequestOptions requestOptions) {
+ final String accept = "application/json";
+ return FluxUtil
+ .withContext(
+ context -> service.listRoomMembersNext(nextLink, this.getEndpoint(), accept, requestOptions, context))
+ .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null));
+ }
+
+ /**
+ * Get room members.
+ *
+ * Get the next page of items.
+ * Response Body Schema
+ *
+ *
+ * {@code
+ * {
+ * userId: String (Required)
+ * roleName: String (Required)
+ * etag: String (Required)
+ * }
+ * }
+ *
+ *
+ * @param nextLink The URL to get the next list of items.
+ * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
+ * @throws HttpResponseException thrown if the request is rejected by server.
+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
+ * @return room members along with {@link PagedResponse}.
+ */
+ @ServiceMethod(returns = ReturnType.SINGLE)
+ private PagedResponse listRoomMembersNextSinglePage(String nextLink, RequestOptions requestOptions) {
+ final String accept = "application/json";
+ Response res
+ = service.listRoomMembersNextSync(nextLink, this.getEndpoint(), accept, requestOptions, Context.NONE);
+ return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(),
+ getValues(res.getValue(), "value"), getNextLink(res.getValue(), "nextLink"), null);
+ }
+
+ private List getValues(BinaryData binaryData, String... path) {
+ try {
+ Object value = binaryData.toObject(Map.class);
+ for (String segment : path) {
+ value = ((Map, ?>) value).get(segment);
+ }
+ List> values = (List>) value;
+ return values.stream().map(BinaryData::fromObject).collect(Collectors.toList());
+ } catch (RuntimeException e) {
+ return null;
+ }
+ }
+
+ private String getNextLink(BinaryData binaryData, String... path) {
+ try {
+ Object value = binaryData.toObject(Map.class);
+ for (String segment : path) {
+ value = ((Map, ?>) value).get(segment);
+ }
+ return (String) value;
+ } catch (RuntimeException e) {
+ return null;
+ }
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java
new file mode 100644
index 000000000000..30823f37f57b
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java
@@ -0,0 +1,83 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.implementation.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * Response containing a Web PubSub client access token.
+ */
+@Immutable
+public final class GenerateClientTokenResponse implements JsonSerializable {
+ /*
+ * Access token used to connect to Azure Web PubSub.
+ */
+ @Generated
+ private final String token;
+
+ /**
+ * Creates an instance of GenerateClientTokenResponse class.
+ *
+ * @param token the token value to set.
+ */
+ @Generated
+ private GenerateClientTokenResponse(String token) {
+ this.token = token;
+ }
+
+ /**
+ * Get the token property: Access token used to connect to Azure Web PubSub.
+ *
+ * @return the token value.
+ */
+ @Generated
+ public String getToken() {
+ return this.token;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("token", this.token);
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of GenerateClientTokenResponse from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of GenerateClientTokenResponse if the JsonReader was pointing to an instance of it, or null
+ * if it was pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the GenerateClientTokenResponse.
+ */
+ @Generated
+ public static GenerateClientTokenResponse fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String token = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("token".equals(fieldName)) {
+ token = reader.getString();
+ } else {
+ reader.skipChildren();
+ }
+ }
+ return new GenerateClientTokenResponse(token);
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java
new file mode 100644
index 000000000000..11d0f7b14661
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the data models for WebPubSubChat.
+ * Azure Web PubSub Chat REST API.
+ */
+package com.azure.messaging.webpubsub.chat.implementation.models;
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java
new file mode 100644
index 000000000000..6a4093ea8eb0
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the implementations for WebPubSubChat.
+ * Azure Web PubSub Chat REST API.
+ */
+package com.azure.messaging.webpubsub.chat.implementation;
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/BuiltInChatRoles.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/BuiltInChatRoles.java
new file mode 100644
index 000000000000..86d14144da18
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/BuiltInChatRoles.java
@@ -0,0 +1,19 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+/** Built-in roles supported by Azure Web PubSub Chat. */
+public final class BuiltInChatRoles {
+ /** The normal user role. */
+ public static final String USER_NORMAL = "user.normal";
+
+ /** The room member role. */
+ public static final String ROOM_MEMBER = "room.member";
+
+ /** The room operator role. */
+ public static final String ROOM_OPERATOR = "room.operator";
+
+ private BuiltInChatRoles() {
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java
new file mode 100644
index 000000000000..00a529508967
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java
@@ -0,0 +1,125 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * Represents a chat conversation.
+ */
+@Immutable
+public final class ChatConversation implements JsonSerializable {
+ /*
+ * Conversation identifier.
+ */
+ @Generated
+ private String id;
+
+ /*
+ * Parent room identifier.
+ */
+ @Generated
+ private final String parentRoom;
+
+ /*
+ * The entity tag for this resource.
+ */
+ @Generated
+ private String etag;
+
+ /**
+ * Creates an instance of ChatConversation class.
+ *
+ * @param parentRoom the parentRoom value to set.
+ */
+ @Generated
+ private ChatConversation(String parentRoom) {
+ this.parentRoom = parentRoom;
+ }
+
+ /**
+ * Get the id property: Conversation identifier.
+ *
+ * @return the id value.
+ */
+ @Generated
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * Get the parentRoom property: Parent room identifier.
+ *
+ * @return the parentRoom value.
+ */
+ @Generated
+ public String getParentRoom() {
+ return this.parentRoom;
+ }
+
+ /**
+ * Get the etag property: The entity tag for this resource.
+ *
+ * @return the etag value.
+ */
+ @Generated
+ public String getEtag() {
+ return this.etag;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("parentRoom", this.parentRoom);
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatConversation from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatConversation if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatConversation.
+ */
+ @Generated
+ public static ChatConversation fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String id = null;
+ String parentRoom = null;
+ String etag = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("id".equals(fieldName)) {
+ id = reader.getString();
+ } else if ("parentRoom".equals(fieldName)) {
+ parentRoom = reader.getString();
+ } else if ("etag".equals(fieldName)) {
+ etag = reader.getString();
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatConversation deserializedChatConversation = new ChatConversation(parentRoom);
+ deserializedChatConversation.id = id;
+ deserializedChatConversation.etag = etag;
+
+ return deserializedChatConversation;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java
new file mode 100644
index 000000000000..ef21b96f8a29
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java
@@ -0,0 +1,243 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.CoreUtils;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import com.azure.messaging.webpubsub.chat.implementation.JsonMergePatchHelper;
+import java.io.IOException;
+import java.time.OffsetDateTime;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Represents a chat message.
+ */
+@Fluent
+public final class ChatMessage implements JsonSerializable {
+ /*
+ * Message identifier.
+ */
+ @Generated
+ private String id;
+
+ /*
+ * User who created the message.
+ */
+ @Generated
+ private String createdBy;
+
+ /*
+ * Message content.
+ */
+ @Generated
+ private MessageContent content;
+
+ /*
+ * Timestamp when the message was created.
+ */
+ @Generated
+ private OffsetDateTime createdAt;
+
+ /*
+ * The entity tag for this resource.
+ */
+ @Generated
+ private String etag;
+
+ /**
+ * Stores updated model property, the value is property name, not serialized name.
+ */
+ @Generated
+ private final Set updatedProperties = new HashSet<>();
+
+ @Generated
+ private boolean jsonMergePatch;
+
+ @Generated
+ private void serializeAsJsonMergePatch(boolean jsonMergePatch) {
+ this.jsonMergePatch = jsonMergePatch;
+ }
+
+ static {
+ JsonMergePatchHelper.setChatMessageAccessor(new JsonMergePatchHelper.ChatMessageAccessor() {
+ @Override
+ public ChatMessage prepareModelForJsonMergePatch(ChatMessage model, boolean jsonMergePatchEnabled) {
+ model.serializeAsJsonMergePatch(jsonMergePatchEnabled);
+ return model;
+ }
+
+ @Override
+ public boolean isJsonMergePatch(ChatMessage model) {
+ return model.jsonMergePatch;
+ }
+ });
+ }
+
+ /**
+ * Creates an instance of ChatMessage class.
+ */
+ @Generated
+ public ChatMessage() {
+ }
+
+ /**
+ * Get the id property: Message identifier.
+ *
+ * @return the id value.
+ */
+ @Generated
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * Get the createdBy property: User who created the message.
+ *
+ * @return the createdBy value.
+ */
+ @Generated
+ public String getCreatedBy() {
+ return this.createdBy;
+ }
+
+ /**
+ * Set the createdBy property: User who created the message.
+ * Required when create the resource.
+ *
+ * @param createdBy the createdBy value to set.
+ * @return the ChatMessage object itself.
+ */
+ @Generated
+ public ChatMessage setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ this.updatedProperties.add("createdBy");
+ return this;
+ }
+
+ /**
+ * Get the content property: Message content.
+ *
+ * @return the content value.
+ */
+ @Generated
+ public MessageContent getContent() {
+ return this.content;
+ }
+
+ /**
+ * Set the content property: Message content.
+ * Required when create the resource.
+ *
+ * @param content the content value to set.
+ * @return the ChatMessage object itself.
+ */
+ @Generated
+ public ChatMessage setContent(MessageContent content) {
+ this.content = content;
+ this.updatedProperties.add("content");
+ return this;
+ }
+
+ /**
+ * Get the createdAt property: Timestamp when the message was created.
+ *
+ * @return the createdAt value.
+ */
+ @Generated
+ public OffsetDateTime getCreatedAt() {
+ return this.createdAt;
+ }
+
+ /**
+ * Get the etag property: The entity tag for this resource.
+ *
+ * @return the etag value.
+ */
+ @Generated
+ public String getEtag() {
+ return this.etag;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ if (jsonMergePatch) {
+ return toJsonMergePatch(jsonWriter);
+ } else {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("createdBy", this.createdBy);
+ jsonWriter.writeJsonField("content", this.content);
+ return jsonWriter.writeEndObject();
+ }
+ }
+
+ @Generated
+ private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ if (updatedProperties.contains("createdBy")) {
+ if (this.createdBy == null) {
+ jsonWriter.writeNullField("createdBy");
+ } else {
+ jsonWriter.writeStringField("createdBy", this.createdBy);
+ }
+ }
+ if (updatedProperties.contains("content")) {
+ if (this.content == null) {
+ jsonWriter.writeNullField("content");
+ } else {
+ JsonMergePatchHelper.getMessageContentAccessor().prepareModelForJsonMergePatch(this.content, true);
+ jsonWriter.writeJsonField("content", this.content);
+ JsonMergePatchHelper.getMessageContentAccessor().prepareModelForJsonMergePatch(this.content, false);
+ }
+ }
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatMessage from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatMessage if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatMessage.
+ */
+ @Generated
+ public static ChatMessage fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ ChatMessage deserializedChatMessage = new ChatMessage();
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("id".equals(fieldName)) {
+ deserializedChatMessage.id = reader.getString();
+ } else if ("createdAt".equals(fieldName)) {
+ deserializedChatMessage.createdAt = reader
+ .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
+ } else if ("etag".equals(fieldName)) {
+ deserializedChatMessage.etag = reader.getString();
+ } else if ("createdBy".equals(fieldName)) {
+ deserializedChatMessage.createdBy = reader.getString();
+ } else if ("content".equals(fieldName)) {
+ deserializedChatMessage.content = MessageContent.fromJson(reader);
+ } else {
+ reader.skipChildren();
+ }
+ }
+
+ return deserializedChatMessage;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java
new file mode 100644
index 000000000000..4732786864e0
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java
@@ -0,0 +1,81 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.ExpandableStringEnum;
+import java.util.Collection;
+
+/**
+ * A permission that can be assigned to a chat role.
+ */
+public final class ChatPermission extends ExpandableStringEnum {
+ /**
+ * Allows a user to create chat rooms.
+ */
+ @Generated
+ public static final ChatPermission USER_CREATE_ROOM = fromString("user.create_room");
+
+ /**
+ * Allows a user to list the rooms they belong to.
+ */
+ @Generated
+ public static final ChatPermission USER_FETCH_ALL_ROOMS = fromString("user.fetch_all_rooms");
+
+ /**
+ * Allows a room member to publish messages.
+ */
+ @Generated
+ public static final ChatPermission ROOM_PUBLISH_MESSAGE = fromString("room.publish_message");
+
+ /**
+ * Allows a room member to read message history.
+ */
+ @Generated
+ public static final ChatPermission ROOM_HISTORY = fromString("room.history");
+
+ /**
+ * Allows a room member to add users to a room.
+ */
+ @Generated
+ public static final ChatPermission ROOM_INVITE = fromString("room.invite");
+
+ /**
+ * Allows a room operator to remove users from a room.
+ */
+ @Generated
+ public static final ChatPermission ROOM_REMOVE_USER = fromString("room.remove_user");
+
+ /**
+ * Creates a new instance of ChatPermission value.
+ *
+ * @deprecated Use the {@link #fromString(String)} factory method.
+ */
+ @Generated
+ @Deprecated
+ public ChatPermission() {
+ }
+
+ /**
+ * Creates or finds a ChatPermission from its string representation.
+ *
+ * @param name a name to look for.
+ * @return the corresponding ChatPermission.
+ */
+ @Generated
+ public static ChatPermission fromString(String name) {
+ return fromString(name, ChatPermission.class);
+ }
+
+ /**
+ * Gets known ChatPermission values.
+ *
+ * @return known ChatPermission values.
+ */
+ @Generated
+ public static Collection values() {
+ return values(ChatPermission.class);
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java
new file mode 100644
index 000000000000..331ebeb217e7
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java
@@ -0,0 +1,130 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Represents a chat role.
+ * A role name must start with 'user.' or 'room.' prefix.
+ * A role must contain either user permissions or room permissions, but not both.
+ */
+@Immutable
+public final class ChatRole implements JsonSerializable {
+ /*
+ * Role name. Must start with 'user.' or 'room.' prefix.
+ */
+ @Generated
+ private String name;
+
+ /*
+ * Permissions associated with the role. Do not mix user permissions and room permissions in one role.
+ */
+ @Generated
+ private final List permissions;
+
+ /*
+ * The entity tag for this resource.
+ */
+ @Generated
+ private String etag;
+
+ /**
+ * Creates an instance of ChatRole class.
+ *
+ * @param permissions the permissions value to set.
+ */
+ @Generated
+ public ChatRole(List permissions) {
+ this.permissions = permissions;
+ }
+
+ /**
+ * Get the name property: Role name. Must start with 'user.' or 'room.' prefix.
+ *
+ * @return the name value.
+ */
+ @Generated
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Get the permissions property: Permissions associated with the role. Do not mix user permissions and room
+ * permissions in one role.
+ *
+ * @return the permissions value.
+ */
+ @Generated
+ public List getPermissions() {
+ return this.permissions;
+ }
+
+ /**
+ * Get the etag property: The entity tag for this resource.
+ *
+ * @return the etag value.
+ */
+ @Generated
+ public String getEtag() {
+ return this.etag;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeArrayField("permissions", this.permissions,
+ (writer, element) -> writer.writeString(element == null ? null : element.toString()));
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatRole from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatRole if the JsonReader was pointing to an instance of it, or null if it was pointing
+ * to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatRole.
+ */
+ @Generated
+ public static ChatRole fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String name = null;
+ List permissions = null;
+ String etag = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("name".equals(fieldName)) {
+ name = reader.getString();
+ } else if ("permissions".equals(fieldName)) {
+ permissions = reader.readArray(reader1 -> ChatPermission.fromString(reader1.getString()));
+ } else if ("etag".equals(fieldName)) {
+ etag = reader.getString();
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatRole deserializedChatRole = new ChatRole(permissions);
+ deserializedChatRole.name = name;
+ deserializedChatRole.etag = etag;
+
+ return deserializedChatRole;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java
new file mode 100644
index 000000000000..896f9919363f
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java
@@ -0,0 +1,145 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * Represents a chat room.
+ */
+@Immutable
+public final class ChatRoom implements JsonSerializable {
+ /*
+ * Room identifier.
+ */
+ @Generated
+ private String id;
+
+ /*
+ * Room title.
+ */
+ @Generated
+ private final String title;
+
+ /*
+ * Default conversation ID for this room.
+ */
+ @Generated
+ private String defaultConversation;
+
+ /*
+ * The entity tag for this resource.
+ */
+ @Generated
+ private String etag;
+
+ /**
+ * Creates an instance of ChatRoom class.
+ *
+ * @param title the title value to set.
+ */
+ @Generated
+ public ChatRoom(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Get the id property: Room identifier.
+ *
+ * @return the id value.
+ */
+ @Generated
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * Get the title property: Room title.
+ *
+ * @return the title value.
+ */
+ @Generated
+ public String getTitle() {
+ return this.title;
+ }
+
+ /**
+ * Get the defaultConversation property: Default conversation ID for this room.
+ *
+ * @return the defaultConversation value.
+ */
+ @Generated
+ public String getDefaultConversation() {
+ return this.defaultConversation;
+ }
+
+ /**
+ * Get the etag property: The entity tag for this resource.
+ *
+ * @return the etag value.
+ */
+ @Generated
+ public String getEtag() {
+ return this.etag;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("title", this.title);
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatRoom from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatRoom if the JsonReader was pointing to an instance of it, or null if it was pointing
+ * to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatRoom.
+ */
+ @Generated
+ public static ChatRoom fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String id = null;
+ String title = null;
+ String defaultConversation = null;
+ String etag = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("id".equals(fieldName)) {
+ id = reader.getString();
+ } else if ("title".equals(fieldName)) {
+ title = reader.getString();
+ } else if ("defaultConversation".equals(fieldName)) {
+ defaultConversation = reader.getString();
+ } else if ("etag".equals(fieldName)) {
+ etag = reader.getString();
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatRoom deserializedChatRoom = new ChatRoom(title);
+ deserializedChatRoom.id = id;
+ deserializedChatRoom.defaultConversation = defaultConversation;
+ deserializedChatRoom.etag = etag;
+
+ return deserializedChatRoom;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java
new file mode 100644
index 000000000000..14ac4bac134b
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java
@@ -0,0 +1,125 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * Represents a room member.
+ */
+@Immutable
+public final class ChatRoomMember implements JsonSerializable {
+ /*
+ * User ID of the member.
+ */
+ @Generated
+ private String userId;
+
+ /*
+ * Room role assigned to the user within this room.
+ */
+ @Generated
+ private final String roleName;
+
+ /*
+ * The entity tag for this resource.
+ */
+ @Generated
+ private String etag;
+
+ /**
+ * Creates an instance of ChatRoomMember class.
+ *
+ * @param roleName the roleName value to set.
+ */
+ @Generated
+ public ChatRoomMember(String roleName) {
+ this.roleName = roleName;
+ }
+
+ /**
+ * Get the userId property: User ID of the member.
+ *
+ * @return the userId value.
+ */
+ @Generated
+ public String getUserId() {
+ return this.userId;
+ }
+
+ /**
+ * Get the roleName property: Room role assigned to the user within this room.
+ *
+ * @return the roleName value.
+ */
+ @Generated
+ public String getRoleName() {
+ return this.roleName;
+ }
+
+ /**
+ * Get the etag property: The entity tag for this resource.
+ *
+ * @return the etag value.
+ */
+ @Generated
+ public String getEtag() {
+ return this.etag;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("roleName", this.roleName);
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatRoomMember from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatRoomMember if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatRoomMember.
+ */
+ @Generated
+ public static ChatRoomMember fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String userId = null;
+ String roleName = null;
+ String etag = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("userId".equals(fieldName)) {
+ userId = reader.getString();
+ } else if ("roleName".equals(fieldName)) {
+ roleName = reader.getString();
+ } else if ("etag".equals(fieldName)) {
+ etag = reader.getString();
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatRoomMember deserializedChatRoomMember = new ChatRoomMember(roleName);
+ deserializedChatRoomMember.userId = userId;
+ deserializedChatRoomMember.etag = etag;
+
+ return deserializedChatRoomMember;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java
new file mode 100644
index 000000000000..0e7efcbd33d8
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java
@@ -0,0 +1,197 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * Represents a user profile in the chat system. This is a discriminated base type;
+ * concrete payloads are selected by the `kind` field (e.g. `HumanChatUser`).
+ */
+@Immutable
+public class ChatUser implements JsonSerializable {
+ /*
+ * The kind of user.
+ */
+ @Generated
+ private ChatUserKind kind = ChatUserKind.fromString("ChatUser");
+
+ /*
+ * User identifier.
+ */
+ @Generated
+ private String id;
+
+ /*
+ * User's display nickname.
+ */
+ @Generated
+ private final String nickname;
+
+ /*
+ * The entity tag for this resource.
+ */
+ @Generated
+ private String etag;
+
+ /**
+ * Creates an instance of ChatUser class.
+ *
+ * @param nickname the nickname value to set.
+ */
+ @Generated
+ public ChatUser(String nickname) {
+ this.nickname = nickname;
+ }
+
+ /**
+ * Get the kind property: The kind of user.
+ *
+ * @return the kind value.
+ */
+ @Generated
+ public ChatUserKind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * Get the id property: User identifier.
+ *
+ * @return the id value.
+ */
+ @Generated
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * Set the id property: User identifier.
+ *
+ * @param id the id value to set.
+ * @return the ChatUser object itself.
+ */
+ @Generated
+ ChatUser setId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Get the nickname property: User's display nickname.
+ *
+ * @return the nickname value.
+ */
+ @Generated
+ public String getNickname() {
+ return this.nickname;
+ }
+
+ /**
+ * Get the etag property: The entity tag for this resource.
+ *
+ * @return the etag value.
+ */
+ @Generated
+ public String getEtag() {
+ return this.etag;
+ }
+
+ /**
+ * Set the etag property: The entity tag for this resource.
+ *
+ * @param etag the etag value to set.
+ * @return the ChatUser object itself.
+ */
+ @Generated
+ ChatUser setEtag(String etag) {
+ this.etag = etag;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("nickname", this.nickname);
+ jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of ChatUser from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of ChatUser if the JsonReader was pointing to an instance of it, or null if it was pointing
+ * to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the ChatUser.
+ */
+ @Generated
+ public static ChatUser fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String discriminatorValue = null;
+ try (JsonReader readerToUse = reader.bufferObject()) {
+ readerToUse.nextToken(); // Prepare for reading
+ while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = readerToUse.getFieldName();
+ readerToUse.nextToken();
+ if ("kind".equals(fieldName)) {
+ discriminatorValue = readerToUse.getString();
+ break;
+ } else {
+ readerToUse.skipChildren();
+ }
+ }
+ // Use the discriminator value to determine which subtype should be deserialized.
+ if ("Human".equals(discriminatorValue)) {
+ return HumanChatUser.fromJson(readerToUse.reset());
+ } else {
+ return fromJsonKnownDiscriminator(readerToUse.reset());
+ }
+ }
+ });
+ }
+
+ @Generated
+ static ChatUser fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String id = null;
+ String nickname = null;
+ String etag = null;
+ ChatUserKind kind = null;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("id".equals(fieldName)) {
+ id = reader.getString();
+ } else if ("nickname".equals(fieldName)) {
+ nickname = reader.getString();
+ } else if ("etag".equals(fieldName)) {
+ etag = reader.getString();
+ } else if ("kind".equals(fieldName)) {
+ kind = ChatUserKind.fromString(reader.getString());
+ } else {
+ reader.skipChildren();
+ }
+ }
+ ChatUser deserializedChatUser = new ChatUser(nickname);
+ deserializedChatUser.id = id;
+ deserializedChatUser.etag = etag;
+ deserializedChatUser.kind = kind;
+
+ return deserializedChatUser;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java
new file mode 100644
index 000000000000..88375ec718cf
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.ExpandableStringEnum;
+import java.util.Collection;
+
+/**
+ * Discriminator for the kind of chat user.
+ */
+public final class ChatUserKind extends ExpandableStringEnum {
+ /**
+ * A human end-user.
+ */
+ @Generated
+ public static final ChatUserKind HUMAN = fromString("Human");
+
+ /**
+ * Creates a new instance of ChatUserKind value.
+ *
+ * @deprecated Use the {@link #fromString(String)} factory method.
+ */
+ @Generated
+ @Deprecated
+ public ChatUserKind() {
+ }
+
+ /**
+ * Creates or finds a ChatUserKind from its string representation.
+ *
+ * @param name a name to look for.
+ * @return the corresponding ChatUserKind.
+ */
+ @Generated
+ public static ChatUserKind fromString(String name) {
+ return fromString(name, ChatUserKind.class);
+ }
+
+ /**
+ * Gets known ChatUserKind values.
+ *
+ * @return known ChatUserKind values.
+ */
+ @Generated
+ public static Collection values() {
+ return values(ChatUserKind.class);
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/GetClientAccessTokenOptions.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/GetClientAccessTokenOptions.java
new file mode 100644
index 000000000000..d09f7873b8e1
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/GetClientAccessTokenOptions.java
@@ -0,0 +1,56 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import java.time.Duration;
+
+/** Options for creating a Web PubSub client access token for Chat. */
+public final class GetClientAccessTokenOptions {
+ private Duration expiresAfter = Duration.ofHours(1);
+ private String userId;
+
+ /** Creates an instance of {@link GetClientAccessTokenOptions}. */
+ public GetClientAccessTokenOptions() {
+ }
+
+ /**
+ * Sets the duration after which the client access token expires.
+ *
+ * @param expiresAfter The token lifetime.
+ * @return The updated options.
+ */
+ public GetClientAccessTokenOptions setExpiresAfter(Duration expiresAfter) {
+ this.expiresAfter = expiresAfter;
+ return this;
+ }
+
+ /**
+ * Gets the duration after which the client access token expires.
+ *
+ * @return The token lifetime.
+ */
+ public Duration getExpiresAfter() {
+ return expiresAfter;
+ }
+
+ /**
+ * Sets the user ID included in the client access token.
+ *
+ * @param userId The user ID.
+ * @return The updated options.
+ */
+ public GetClientAccessTokenOptions setUserId(String userId) {
+ this.userId = userId;
+ return this;
+ }
+
+ /**
+ * Gets the user ID included in the client access token.
+ *
+ * @return The user ID.
+ */
+ public String getUserId() {
+ return userId;
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java
new file mode 100644
index 000000000000..553fc3083c34
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java
@@ -0,0 +1,120 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Generated;
+import com.azure.core.annotation.Immutable;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import java.io.IOException;
+
+/**
+ * A human end-user, identified by a user role.
+ */
+@Immutable
+public final class HumanChatUser extends ChatUser {
+ /*
+ * The kind of user.
+ */
+ @Generated
+ private ChatUserKind kind = ChatUserKind.HUMAN;
+
+ /*
+ * Global user role assigned to the user. Must start with `user.`.
+ */
+ @Generated
+ private final String roleName;
+
+ /**
+ * Creates an instance of HumanChatUser class.
+ *
+ * @param nickname the nickname value to set.
+ * @param roleName the roleName value to set.
+ */
+ @Generated
+ public HumanChatUser(String nickname, String roleName) {
+ super(nickname);
+ this.roleName = roleName;
+ }
+
+ /**
+ * Get the kind property: The kind of user.
+ *
+ * @return the kind value.
+ */
+ @Generated
+ @Override
+ public ChatUserKind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * Get the roleName property: Global user role assigned to the user. Must start with `user.`.
+ *
+ * @return the roleName value.
+ */
+ @Generated
+ public String getRoleName() {
+ return this.roleName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("nickname", getNickname());
+ jsonWriter.writeStringField("roleName", this.roleName);
+ jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of HumanChatUser from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of HumanChatUser if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
+ * @throws IOException If an error occurs while reading the HumanChatUser.
+ */
+ @Generated
+ public static HumanChatUser fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ String id = null;
+ String nickname = null;
+ String etag = null;
+ String roleName = null;
+ ChatUserKind kind = ChatUserKind.HUMAN;
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("id".equals(fieldName)) {
+ id = reader.getString();
+ } else if ("nickname".equals(fieldName)) {
+ nickname = reader.getString();
+ } else if ("etag".equals(fieldName)) {
+ etag = reader.getString();
+ } else if ("roleName".equals(fieldName)) {
+ roleName = reader.getString();
+ } else if ("kind".equals(fieldName)) {
+ kind = ChatUserKind.fromString(reader.getString());
+ } else {
+ reader.skipChildren();
+ }
+ }
+ HumanChatUser deserializedHumanChatUser = new HumanChatUser(nickname, roleName);
+ deserializedHumanChatUser.setId(id);
+ deserializedHumanChatUser.setEtag(etag);
+ deserializedHumanChatUser.kind = kind;
+
+ return deserializedHumanChatUser;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java
new file mode 100644
index 000000000000..2affaccea8c2
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java
@@ -0,0 +1,182 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.core.annotation.Generated;
+import com.azure.core.util.CoreUtils;
+import com.azure.json.JsonReader;
+import com.azure.json.JsonSerializable;
+import com.azure.json.JsonToken;
+import com.azure.json.JsonWriter;
+import com.azure.messaging.webpubsub.chat.implementation.JsonMergePatchHelper;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Message content body.
+ */
+@Fluent
+public final class MessageContent implements JsonSerializable {
+ /*
+ * Text content.
+ */
+ @Generated
+ private String text;
+
+ /*
+ * Binary content (base64 encoded).
+ */
+ @Generated
+ private byte[] binary;
+
+ /**
+ * Stores updated model property, the value is property name, not serialized name.
+ */
+ @Generated
+ private final Set updatedProperties = new HashSet<>();
+
+ @Generated
+ private boolean jsonMergePatch;
+
+ @Generated
+ private void serializeAsJsonMergePatch(boolean jsonMergePatch) {
+ this.jsonMergePatch = jsonMergePatch;
+ }
+
+ static {
+ JsonMergePatchHelper.setMessageContentAccessor(new JsonMergePatchHelper.MessageContentAccessor() {
+ @Override
+ public MessageContent prepareModelForJsonMergePatch(MessageContent model, boolean jsonMergePatchEnabled) {
+ model.serializeAsJsonMergePatch(jsonMergePatchEnabled);
+ return model;
+ }
+
+ @Override
+ public boolean isJsonMergePatch(MessageContent model) {
+ return model.jsonMergePatch;
+ }
+ });
+ }
+
+ /**
+ * Creates an instance of MessageContent class.
+ */
+ @Generated
+ public MessageContent() {
+ }
+
+ /**
+ * Get the text property: Text content.
+ *
+ * @return the text value.
+ */
+ @Generated
+ public String getText() {
+ return this.text;
+ }
+
+ /**
+ * Set the text property: Text content.
+ *
+ * @param text the text value to set.
+ * @return the MessageContent object itself.
+ */
+ @Generated
+ public MessageContent setText(String text) {
+ this.text = text;
+ this.updatedProperties.add("text");
+ return this;
+ }
+
+ /**
+ * Get the binary property: Binary content (base64 encoded).
+ *
+ * @return the binary value.
+ */
+ @Generated
+ public byte[] getBinary() {
+ return CoreUtils.clone(this.binary);
+ }
+
+ /**
+ * Set the binary property: Binary content (base64 encoded).
+ *
+ * @param binary the binary value to set.
+ * @return the MessageContent object itself.
+ */
+ @Generated
+ public MessageContent setBinary(byte[] binary) {
+ this.binary = CoreUtils.clone(binary);
+ this.updatedProperties.add("binary");
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Generated
+ @Override
+ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
+ if (jsonMergePatch) {
+ return toJsonMergePatch(jsonWriter);
+ } else {
+ jsonWriter.writeStartObject();
+ jsonWriter.writeStringField("text", this.text);
+ jsonWriter.writeBinaryField("binary", this.binary);
+ return jsonWriter.writeEndObject();
+ }
+ }
+
+ @Generated
+ private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException {
+ jsonWriter.writeStartObject();
+ if (updatedProperties.contains("text")) {
+ if (this.text == null) {
+ jsonWriter.writeNullField("text");
+ } else {
+ jsonWriter.writeStringField("text", this.text);
+ }
+ }
+ if (updatedProperties.contains("binary")) {
+ if (this.binary == null) {
+ jsonWriter.writeNullField("binary");
+ } else {
+ jsonWriter.writeBinaryField("binary", this.binary);
+ }
+ }
+ return jsonWriter.writeEndObject();
+ }
+
+ /**
+ * Reads an instance of MessageContent from the JsonReader.
+ *
+ * @param jsonReader The JsonReader being read.
+ * @return An instance of MessageContent if the JsonReader was pointing to an instance of it, or null if it was
+ * pointing to JSON null.
+ * @throws IOException If an error occurs while reading the MessageContent.
+ */
+ @Generated
+ public static MessageContent fromJson(JsonReader jsonReader) throws IOException {
+ return jsonReader.readObject(reader -> {
+ MessageContent deserializedMessageContent = new MessageContent();
+ while (reader.nextToken() != JsonToken.END_OBJECT) {
+ String fieldName = reader.getFieldName();
+ reader.nextToken();
+
+ if ("text".equals(fieldName)) {
+ deserializedMessageContent.text = reader.getString();
+ } else if ("binary".equals(fieldName)) {
+ deserializedMessageContent.binary = reader.getBinary();
+ } else {
+ reader.skipChildren();
+ }
+ }
+
+ return deserializedMessageContent;
+ });
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/WebPubSubClientAccessToken.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/WebPubSubClientAccessToken.java
new file mode 100644
index 000000000000..9ad5b69adf94
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/WebPubSubClientAccessToken.java
@@ -0,0 +1,39 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat.models;
+
+/** A client access token and URL for connecting to Azure Web PubSub. */
+public final class WebPubSubClientAccessToken {
+ private final String token;
+ private final String url;
+
+ /**
+ * Creates a Web PubSub client access token result.
+ *
+ * @param token The client access token.
+ * @param url The client connection URL.
+ */
+ public WebPubSubClientAccessToken(String token, String url) {
+ this.token = token;
+ this.url = url;
+ }
+
+ /**
+ * Gets the client access token.
+ *
+ * @return The client access token.
+ */
+ public String getToken() {
+ return token;
+ }
+
+ /**
+ * Gets the client connection URL.
+ *
+ * @return The client connection URL.
+ */
+ public String getUrl() {
+ return url;
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java
new file mode 100644
index 000000000000..9b14e91a9d23
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the data models for WebPubSubChat.
+ * Azure Web PubSub Chat REST API.
+ */
+package com.azure.messaging.webpubsub.chat.models;
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/package-info.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/package-info.java
new file mode 100644
index 000000000000..440b0226e10d
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/com/azure/messaging/webpubsub/chat/package-info.java
@@ -0,0 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+/**
+ * Package containing the classes for WebPubSubChat.
+ * Azure Web PubSub Chat REST API.
+ */
+package com.azure.messaging.webpubsub.chat;
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/module-info.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/module-info.java
new file mode 100644
index 000000000000..e28a66920bd9
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/java/module-info.java
@@ -0,0 +1,14 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+module com.azure.messaging.webpubsub.chat {
+ requires transitive com.azure.core;
+ requires com.nimbusds.jose.jwt;
+
+ exports com.azure.messaging.webpubsub.chat;
+ exports com.azure.messaging.webpubsub.chat.models;
+
+ opens com.azure.messaging.webpubsub.chat.models to com.azure.core;
+ opens com.azure.messaging.webpubsub.chat.implementation.models to com.azure.core;
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json
new file mode 100644
index 000000000000..12444820d741
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/META-INF/azure-messaging-webpubsub-chat_metadata.json
@@ -0,0 +1 @@
+{"flavor":"azure","apiVersions":{"WebPubSubChat":"2026-02-01-preview"},"crossLanguagePackageId":"WebPubSubChat","crossLanguageVersion":"c36110faca71","crossLanguageDefinitions":{"com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceAsyncClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRole":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoom":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUser":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.createOrReplaceUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.createOrReplaceUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessage":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRole":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoom":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMember":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomMemberWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoomMember","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUser":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.deleteUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.deleteUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientToken":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.generateClientTokenWithResponse":"Customizations.WebPubSubChatServiceClient.generateClientToken","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversation":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getConversationWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getConversation","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRole":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoleWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRole","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoom":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getRoomWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getRoom","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUser":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.getUserWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.getUser","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listMessages":"WebPubSubChat.WebPubSubChatServiceClient.listMessages","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoles":"WebPubSubChat.WebPubSubChatServiceClient.listRoles","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.listRoomMembers":"WebPubSubChat.WebPubSubChatServiceClient.listRoomMembers","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessage":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClient.updateMessageWithResponse":"WebPubSubChat.WebPubSubChatServiceClient.updateMessage","com.azure.messaging.webpubsub.chat.WebPubSubChatServiceClientBuilder":"Customizations.WebPubSubChatServiceClient","com.azure.messaging.webpubsub.chat.implementation.models.GenerateClientTokenResponse":"Customizations.GenerateClientTokenResponse","com.azure.messaging.webpubsub.chat.models.ChatConversation":"WebPubSubChat.ChatConversation","com.azure.messaging.webpubsub.chat.models.ChatMessage":"WebPubSubChat.ChatMessage","com.azure.messaging.webpubsub.chat.models.ChatPermission":"WebPubSubChat.ChatPermission","com.azure.messaging.webpubsub.chat.models.ChatRole":"WebPubSubChat.ChatRole","com.azure.messaging.webpubsub.chat.models.ChatRoom":"WebPubSubChat.ChatRoom","com.azure.messaging.webpubsub.chat.models.ChatRoomMember":"WebPubSubChat.ChatRoomMember","com.azure.messaging.webpubsub.chat.models.ChatUser":"WebPubSubChat.ChatUser","com.azure.messaging.webpubsub.chat.models.ChatUserKind":"WebPubSubChat.ChatUserKind","com.azure.messaging.webpubsub.chat.models.HumanChatUser":"WebPubSubChat.HumanChatUser","com.azure.messaging.webpubsub.chat.models.MessageContent":"WebPubSubChat.MessageContent"},"generatedFiles":["src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceAsyncClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClient.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceClientBuilder.java","src/main/java/com/azure/messaging/webpubsub/chat/WebPubSubChatServiceVersion.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/JsonMergePatchHelper.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/WebPubSubChatServiceClientImpl.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/GenerateClientTokenResponse.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/implementation/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatConversation.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatMessage.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatPermission.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRole.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoom.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatRoomMember.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/ChatUserKind.java","src/main/java/com/azure/messaging/webpubsub/chat/models/HumanChatUser.java","src/main/java/com/azure/messaging/webpubsub/chat/models/MessageContent.java","src/main/java/com/azure/messaging/webpubsub/chat/models/package-info.java","src/main/java/com/azure/messaging/webpubsub/chat/package-info.java","src/main/java/module-info.java"]}
\ No newline at end of file
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/azure-messaging-webpubsub-chat.properties b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/azure-messaging-webpubsub-chat.properties
new file mode 100644
index 000000000000..ca812989b4f2
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/main/resources/azure-messaging-webpubsub-chat.properties
@@ -0,0 +1,2 @@
+name=${project.artifactId}
+version=${project.version}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/ReadmeSamples.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/ReadmeSamples.java
new file mode 100644
index 000000000000..ef5d31b99fc8
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/ReadmeSamples.java
@@ -0,0 +1,12 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+// Code generated by Microsoft (R) TypeSpec Code Generator.
+
+package com.azure.messaging.webpubsub.chat;
+
+public final class ReadmeSamples {
+ public void readmeSamples() {
+ // BEGIN: com.azure.messaging.webpubsub.chat.readme
+ // END: com.azure.messaging.webpubsub.chat.readme
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java
new file mode 100644
index 000000000000..bcb50ea90d32
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/samples/java/com/azure/messaging/webpubsub/chat/WebPubSubChatSamples.java
@@ -0,0 +1,138 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat;
+
+import com.azure.core.credential.AzureKeyCredential;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles;
+import com.azure.messaging.webpubsub.chat.models.ChatPermission;
+import com.azure.messaging.webpubsub.chat.models.ChatRole;
+import com.azure.messaging.webpubsub.chat.models.ChatRoom;
+import com.azure.messaging.webpubsub.chat.models.ChatRoomMember;
+import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions;
+import com.azure.messaging.webpubsub.chat.models.HumanChatUser;
+import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken;
+
+import java.time.Duration;
+import java.util.Arrays;
+
+/** Code snippets used by the package README. */
+public final class WebPubSubChatSamples {
+ /** Creates a client from a connection string. */
+ public void createClientWithConnectionString() {
+ // BEGIN: readme-sample-createChatClientWithConnectionString
+ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder()
+ .connectionString("")
+ .hub("chat")
+ .buildClient();
+ // END: readme-sample-createChatClientWithConnectionString
+ }
+
+ /** Creates a client from an endpoint and access key. */
+ public void createClientWithKey() {
+ // BEGIN: readme-sample-createChatClientWithKey
+ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder()
+ .endpoint("https://.webpubsub.azure.com")
+ .hub("chat")
+ .credential(new AzureKeyCredential(""))
+ .buildClient();
+ // END: readme-sample-createChatClientWithKey
+ }
+
+ /** Creates a client using Microsoft Entra ID. */
+ public void createClientWithEntraId() {
+ // BEGIN: readme-sample-createChatClientWithEntraId
+ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder()
+ .endpoint("https://.webpubsub.azure.com")
+ .hub("chat")
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+ // END: readme-sample-createChatClientWithEntraId
+ }
+
+ /** Generates a token for a Chat client connection. */
+ public void getClientAccessToken() {
+ WebPubSubChatServiceClient client = createClient();
+
+ // BEGIN: readme-sample-getChatClientAccessToken
+ WebPubSubClientAccessToken accessToken = client.getClientAccessToken(
+ new GetClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofHours(1)));
+ String clientConnectionUrl = accessToken.getUrl();
+ // END: readme-sample-getChatClientAccessToken
+ }
+
+ /** Creates and lists a custom Chat role. */
+ public void manageRoles() {
+ WebPubSubChatServiceClient client = createClient();
+
+ // BEGIN: readme-sample-manageChatRoles
+ ChatRole moderator = new ChatRole(Arrays.asList(ChatPermission.ROOM_HISTORY,
+ ChatPermission.ROOM_REMOVE_USER, ChatPermission.ROOM_PUBLISH_MESSAGE));
+ client.createOrReplaceRole("room.moderator", moderator);
+
+ client.listRoles().forEach(role -> System.out.println(role.getName()));
+ client.deleteRole("room.moderator");
+ // END: readme-sample-manageChatRoles
+ }
+
+ /** Creates a room and assigns a member. */
+ public void manageRooms() {
+ WebPubSubChatServiceClient client = createClient();
+
+ // BEGIN: readme-sample-manageChatRooms
+ client.createOrReplaceRole("user.room_creator",
+ new ChatRole(Arrays.asList(ChatPermission.USER_CREATE_ROOM)));
+ client.createOrReplaceRole("room.contributor",
+ new ChatRole(Arrays.asList(ChatPermission.ROOM_PUBLISH_MESSAGE)));
+ client.createOrReplaceUser("alice", new HumanChatUser("Alice", "user.room_creator"));
+
+ ChatRoom room = client.createOrReplaceRoom("general", new ChatRoom("General"));
+ ChatRoomMember member = client.createOrReplaceRoomMember(
+ room.getId(), "alice", new ChatRoomMember("room.contributor"));
+ System.out.printf("%s: %s%n", member.getUserId(), member.getRoleName());
+
+ client.deleteRoom(room.getId());
+ client.deleteUser("alice");
+ client.deleteRole("room.contributor");
+ client.deleteRole("user.room_creator");
+ // END: readme-sample-manageChatRooms
+ }
+
+ /** Lists persisted messages in a room's default conversation. */
+ public void listMessages() {
+ WebPubSubChatServiceClient client = createClient();
+
+ // BEGIN: readme-sample-listChatMessages
+ ChatRoom room = client.getRoom("general");
+ client.listMessages(room.getDefaultConversation()).forEach(message ->
+ System.out.printf("%s: %s%n", message.getCreatedBy(), message.getContent().getText()));
+ // END: readme-sample-listChatMessages
+ }
+
+ /** Creates an asynchronous client and lists roles. */
+ public void createAsyncClient() {
+ // BEGIN: readme-sample-createAsyncChatClient
+ WebPubSubChatServiceAsyncClient asyncClient = new WebPubSubChatServiceClientBuilder()
+ .connectionString("")
+ .hub("chat")
+ .buildAsyncClient();
+
+ asyncClient.listRoles().subscribe(role -> System.out.println(role.getName()));
+ // END: readme-sample-createAsyncChatClient
+ }
+
+ /** Reads the built-in role and permission values. */
+ public void builtInValues() {
+ // BEGIN: readme-sample-chatBuiltInValues
+ String memberRole = BuiltInChatRoles.ROOM_MEMBER;
+ ChatPermission publishPermission = ChatPermission.ROOM_PUBLISH_MESSAGE;
+ // END: readme-sample-chatBuiltInValues
+ }
+
+ private static WebPubSubChatServiceClient createClient() {
+ return new WebPubSubChatServiceClientBuilder().connectionString("")
+ .hub("chat")
+ .buildClient();
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatMessageSeeder.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatMessageSeeder.java
new file mode 100644
index 000000000000..7b777ebcb07f
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatMessageSeeder.java
@@ -0,0 +1,61 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat;
+
+import reactor.core.publisher.Mono;
+import reactor.core.publisher.Sinks;
+import reactor.netty.http.client.HttpClient;
+import reactor.netty.http.client.WebsocketClientSpec;
+
+import java.time.Duration;
+import java.util.UUID;
+
+final class ChatMessageSeeder {
+ private static final Duration TIMEOUT = Duration.ofSeconds(30);
+
+ private ChatMessageSeeder() {
+ }
+
+ static void sendTextMessage(String clientAccessUrl, String conversationId, String content) {
+ String loginInvocationId = UUID.randomUUID().toString();
+ String sendInvocationId = UUID.randomUUID().toString();
+ String loginFrame = "{\"type\":\"invoke\",\"invocationId\":\"" + loginInvocationId
+ + "\",\"target\":\"event\",\"event\":\"chat.login\",\"dataType\":\"text\",\"data\":\"\"}";
+ String sendFrame = "{\"type\":\"invoke\",\"invocationId\":\"" + sendInvocationId
+ + "\",\"target\":\"event\",\"event\":\"chat.sendTextMessage\",\"dataType\":\"json\","
+ + "\"data\":{\"conversation\":{\"conversationId\":\"" + escape(conversationId) + "\"},\"content\":\""
+ + escape(content) + "\"}}";
+ Sinks.Many outboundFrames = Sinks.many().unicast().onBackpressureBuffer();
+
+ HttpClient.create()
+ .websocket(WebsocketClientSpec.builder().protocols("json.webpubsub.azure.v1").build())
+ .uri(clientAccessUrl)
+ .handle((inbound, outbound) -> Mono.when(outbound.sendString(outboundFrames.asFlux()).then(),
+ inbound.receive().asString().handle((message, sink) -> {
+ if (message.contains("\"type\":\"system\"") && message.contains("\"event\":\"connected\"")) {
+ outboundFrames.tryEmitNext(loginFrame);
+ } else if (message.contains("\"invocationId\":\"" + loginInvocationId + "\"")) {
+ if (message.contains("\"success\":true")) {
+ outboundFrames.tryEmitNext(sendFrame);
+ } else {
+ outboundFrames.tryEmitComplete();
+ sink.error(new IllegalStateException("Chat login invocation failed: " + message));
+ }
+ } else if (message.contains("\"invocationId\":\"" + sendInvocationId + "\"")) {
+ outboundFrames.tryEmitComplete();
+ if (message.contains("\"success\":true")) {
+ sink.complete();
+ } else {
+ sink.error(new IllegalStateException("Chat message invocation failed: " + message));
+ }
+ }
+ }).then()))
+ .then()
+ .block(TIMEOUT);
+ }
+
+ private static String escape(String value) {
+ return value.replace("\\", "\\\\").replace("\"", "\\\"");
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java
new file mode 100644
index 000000000000..385c261f0a98
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceAsyncClientLiveTests.java
@@ -0,0 +1,185 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat;
+
+import com.azure.core.http.rest.PagedResponse;
+import com.azure.core.test.TestMode;
+import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles;
+import com.azure.messaging.webpubsub.chat.models.ChatConversation;
+import com.azure.messaging.webpubsub.chat.models.ChatMessage;
+import com.azure.messaging.webpubsub.chat.models.ChatPermission;
+import com.azure.messaging.webpubsub.chat.models.ChatRole;
+import com.azure.messaging.webpubsub.chat.models.ChatRoom;
+import com.azure.messaging.webpubsub.chat.models.ChatRoomMember;
+import com.azure.messaging.webpubsub.chat.models.ChatUser;
+import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions;
+import com.azure.messaging.webpubsub.chat.models.HumanChatUser;
+import com.azure.messaging.webpubsub.chat.models.MessageContent;
+import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ChatServiceAsyncClientLiveTests extends ChatServiceClientTestBase {
+ @Test
+ public void canManageRolesAndPagination() {
+ String firstRoleName = testResourceNamer.randomName("user.java-async-test-", 55);
+ String secondRoleName = testResourceNamer.randomName("room.java-async-test-", 55);
+
+ try {
+ ChatRole createdRole
+ = asyncClient
+ .createOrReplaceRole(firstRoleName,
+ new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)))
+ .block();
+ assertEquals(firstRoleName, createdRole.getName());
+ assertEquals(firstRoleName, asyncClient.getRole(firstRoleName).block().getName());
+
+ asyncClient
+ .createOrReplaceRole(secondRoleName,
+ new ChatRole(Collections.singletonList(ChatPermission.ROOM_PUBLISH_MESSAGE)))
+ .block();
+ List roles = asyncClient.listRoles().collectList().block();
+ assertTrue(roles.stream().anyMatch(role -> firstRoleName.equals(role.getName())));
+
+ List> pages = asyncClient.listRoles().byPage(1).take(2).collectList().block();
+ assertFalse(pages.isEmpty());
+ PagedResponse firstPage = pages.get(0);
+ assertFalse(firstPage.getValue().isEmpty());
+ if (firstPage.getContinuationToken() != null) {
+ assertEquals(2, pages.size());
+ PagedResponse secondPage = pages.get(1);
+ assertFalse(secondPage.getValue().isEmpty());
+ assertFalse(firstPage.getValue().get(0).getName().equals(secondPage.getValue().get(0).getName()));
+ }
+ } finally {
+ cleanup(() -> asyncClient.deleteRole(firstRoleName).block());
+ cleanup(() -> asyncClient.deleteRole(secondRoleName).block());
+ }
+ }
+
+ @Test
+ public void canManageRoomsAndReadEmptyConversation() {
+ String roomId = testResourceNamer.randomName("java-async-test-room-", 55);
+
+ try {
+ ChatRoom createdRoom
+ = asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java async test room")).block();
+ assertEquals(roomId, createdRoom.getId());
+ assertEquals("Java async test room", asyncClient.getRoom(roomId).block().getTitle());
+
+ ChatConversation conversation = asyncClient.getConversation(createdRoom.getDefaultConversation()).block();
+ assertEquals(createdRoom.getDefaultConversation(), conversation.getId());
+ assertEquals(roomId, conversation.getParentRoom());
+ assertTrue(asyncClient.listMessages(conversation.getId()).collectList().block().isEmpty());
+ assertTrue(asyncClient.listRoomMembers(roomId).collectList().block().isEmpty());
+ } finally {
+ cleanup(() -> asyncClient.deleteRoom(roomId).block());
+ }
+ }
+
+ @Test
+ public void canManageUserRoomAndMember() {
+ String suffix = testResourceNamer.randomName("java", 20);
+ String userId = "java-async-test-user-" + suffix;
+ String roomId = "java-async-test-room-" + suffix;
+
+ try {
+ ChatUser user = asyncClient
+ .createOrReplaceUser(userId, new HumanChatUser("Java test user", BuiltInChatRoles.USER_NORMAL))
+ .block();
+ assertEquals(userId, user.getId());
+ assertEquals(userId, asyncClient.getUser(userId).block().getId());
+
+ ChatRoom room = asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java test room")).block();
+ assertEquals(roomId, room.getId());
+
+ ChatRoomMember member = asyncClient
+ .createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))
+ .block();
+ assertEquals(userId, member.getUserId());
+ assertEquals(BuiltInChatRoles.ROOM_MEMBER, member.getRoleName());
+ assertTrue(asyncClient.listRoomMembers(roomId)
+ .collectList()
+ .block()
+ .stream()
+ .anyMatch(item -> userId.equals(item.getUserId())));
+ asyncClient.deleteRoomMember(roomId, userId).block();
+ } finally {
+ cleanup(() -> asyncClient.deleteRoomMember(roomId, userId).block());
+ cleanup(() -> asyncClient.deleteRoom(roomId).block());
+ cleanup(() -> asyncClient.deleteUser(userId).block());
+ }
+ }
+
+ @Test
+ public void canListUpdateAndDeleteMessages() {
+ String suffix = testResourceNamer.randomName("java", 20);
+ String userId = "java-async-message-user-" + suffix;
+ String roomId = "java-async-message-room-" + suffix;
+ String messageText = "Java async live test message " + suffix;
+ String conversationId = null;
+ String messageId = null;
+
+ try {
+ asyncClient
+ .createOrReplaceUser(userId,
+ new HumanChatUser("Java async message test user", BuiltInChatRoles.USER_NORMAL))
+ .block();
+ ChatRoom room
+ = asyncClient.createOrReplaceRoom(roomId, new ChatRoom("Java async message test room")).block();
+ conversationId = room.getDefaultConversation();
+ asyncClient.createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER))
+ .block();
+
+ WebPubSubClientAccessToken accessToken
+ = entraAsyncClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId)).block();
+ assertNotNull(accessToken.getToken());
+ assertNotNull(accessToken.getUrl());
+ if (getTestMode() != TestMode.PLAYBACK) {
+ ChatMessageSeeder.sendTextMessage(accessToken.getUrl(), conversationId, messageText);
+ }
+
+ ChatMessage createdMessage = asyncClient.listMessages(conversationId)
+ .filter(message -> userId.equals(message.getCreatedBy())
+ && messageText.equals(message.getContent().getText()))
+ .blockFirst();
+ assertNotNull(createdMessage);
+ messageId = createdMessage.getId();
+
+ ChatMessage updatedText
+ = asyncClient
+ .updateMessage(conversationId, messageId,
+ new ChatMessage().setCreatedBy(userId)
+ .setContent(new MessageContent().setText(messageText + " updated")))
+ .block();
+ assertEquals(messageText + " updated", updatedText.getContent().getText());
+
+ byte[] binary = new byte[] { 0, 1, 2, (byte) 254, (byte) 255 };
+ ChatMessage updatedBinary
+ = asyncClient
+ .updateMessage(conversationId, messageId,
+ new ChatMessage().setCreatedBy(userId).setContent(new MessageContent().setBinary(binary)))
+ .block();
+ assertArrayEquals(binary, updatedBinary.getContent().getBinary());
+ asyncClient.deleteMessage(conversationId, messageId).block();
+ } finally {
+ String finalConversationId = conversationId;
+ String finalMessageId = messageId;
+ if (finalConversationId != null && finalMessageId != null) {
+ cleanup(() -> asyncClient.deleteMessage(finalConversationId, finalMessageId).block());
+ }
+ cleanup(() -> asyncClient.deleteRoomMember(roomId, userId).block());
+ cleanup(() -> asyncClient.deleteRoom(roomId).block());
+ cleanup(() -> asyncClient.deleteUser(userId).block());
+ }
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java
new file mode 100644
index 000000000000..960bd7a5ef75
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientLiveTests.java
@@ -0,0 +1,179 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat;
+
+import com.azure.core.exception.HttpResponseException;
+import com.azure.core.http.MatchConditions;
+import com.azure.core.http.rest.PagedResponse;
+import com.azure.core.test.TestMode;
+import com.azure.messaging.webpubsub.chat.models.BuiltInChatRoles;
+import com.azure.messaging.webpubsub.chat.models.ChatConversation;
+import com.azure.messaging.webpubsub.chat.models.ChatMessage;
+import com.azure.messaging.webpubsub.chat.models.ChatPermission;
+import com.azure.messaging.webpubsub.chat.models.ChatRole;
+import com.azure.messaging.webpubsub.chat.models.ChatRoom;
+import com.azure.messaging.webpubsub.chat.models.ChatRoomMember;
+import com.azure.messaging.webpubsub.chat.models.ChatUser;
+import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions;
+import com.azure.messaging.webpubsub.chat.models.HumanChatUser;
+import com.azure.messaging.webpubsub.chat.models.MessageContent;
+import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ChatServiceClientLiveTests extends ChatServiceClientTestBase {
+ @Test
+ public void canManageRolesWithConditionsAndPagination() {
+ String firstRoleName = testResourceNamer.randomName("user.java-test-", 50);
+ String secondRoleName = testResourceNamer.randomName("room.java-test-", 50);
+
+ try {
+ ChatRole createdRole = client.createOrReplaceRole(firstRoleName,
+ new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)));
+ assertEquals(firstRoleName, createdRole.getName());
+ assertEquals(ChatPermission.USER_CREATE_ROOM, client.getRole(firstRoleName).getPermissions().get(0));
+
+ ChatRole replacedRole = client.createOrReplaceRole(firstRoleName,
+ new ChatRole(Arrays.asList(ChatPermission.USER_CREATE_ROOM, ChatPermission.USER_FETCH_ALL_ROOMS)),
+ new MatchConditions().setIfMatch(createdRole.getEtag()));
+ assertFalse(createdRole.getEtag().equals(replacedRole.getEtag()));
+ HttpResponseException staleEtag = assertThrows(HttpResponseException.class,
+ () -> client.createOrReplaceRole(firstRoleName,
+ new ChatRole(Collections.singletonList(ChatPermission.USER_CREATE_ROOM)),
+ new MatchConditions().setIfMatch(createdRole.getEtag())));
+ assertEquals(412, staleEtag.getResponse().getStatusCode());
+
+ client.createOrReplaceRole(secondRoleName,
+ new ChatRole(Collections.singletonList(ChatPermission.ROOM_PUBLISH_MESSAGE)),
+ new MatchConditions().setIfNoneMatch("*"));
+ HttpResponseException alreadyExists = assertThrows(HttpResponseException.class,
+ () -> client.createOrReplaceRole(secondRoleName,
+ new ChatRole(Collections.singletonList(ChatPermission.ROOM_HISTORY)),
+ new MatchConditions().setIfNoneMatch("*")));
+ assertEquals(412, alreadyExists.getResponse().getStatusCode());
+
+ assertTrue(client.listRoles().stream().anyMatch(role -> firstRoleName.equals(role.getName())));
+ Iterator> pages = client.listRoles().iterableByPage(1).iterator();
+ PagedResponse firstPage = pages.next();
+ assertFalse(firstPage.getValue().isEmpty());
+ if (firstPage.getContinuationToken() != null) {
+ assertTrue(pages.hasNext());
+ PagedResponse secondPage = pages.next();
+ assertFalse(secondPage.getValue().isEmpty());
+ assertFalse(firstPage.getValue().get(0).getName().equals(secondPage.getValue().get(0).getName()));
+ }
+ } finally {
+ cleanup(() -> client.deleteRole(firstRoleName));
+ cleanup(() -> client.deleteRole(secondRoleName));
+ }
+ }
+
+ @Test
+ public void canManageRoomsAndReadEmptyConversation() {
+ String roomId = testResourceNamer.randomName("java-test-room-", 50);
+
+ try {
+ ChatRoom createdRoom = client.createOrReplaceRoom(roomId, new ChatRoom("Java test room"));
+ assertEquals(roomId, createdRoom.getId());
+ assertEquals("Java test room", client.getRoom(roomId).getTitle());
+
+ ChatConversation conversation = client.getConversation(createdRoom.getDefaultConversation());
+ assertEquals(createdRoom.getDefaultConversation(), conversation.getId());
+ assertEquals(roomId, conversation.getParentRoom());
+ assertFalse(client.listMessages(conversation.getId()).stream().findAny().isPresent());
+ assertFalse(client.listRoomMembers(roomId).stream().findAny().isPresent());
+ } finally {
+ cleanup(() -> client.deleteRoom(roomId));
+ }
+ }
+
+ @Test
+ public void canManageUsersAndRoomMembers() {
+ String suffix = testResourceNamer.randomName("java", 20);
+ String userId = "java-test-user-" + suffix;
+ String roomId = "java-test-room-" + suffix;
+
+ try {
+ ChatUser createdUser
+ = client.createOrReplaceUser(userId, new HumanChatUser("Java test user", BuiltInChatRoles.USER_NORMAL));
+ assertEquals(userId, createdUser.getId());
+ assertEquals(userId, client.getUser(userId).getId());
+
+ client.createOrReplaceRoom(roomId, new ChatRoom("Java member test room"));
+ ChatRoomMember member
+ = client.createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER));
+ assertEquals(userId, member.getUserId());
+ assertTrue(client.listRoomMembers(roomId).stream().anyMatch(item -> userId.equals(item.getUserId())));
+ client.deleteRoomMember(roomId, userId);
+ } finally {
+ cleanup(() -> client.deleteRoomMember(roomId, userId));
+ cleanup(() -> client.deleteRoom(roomId));
+ cleanup(() -> client.deleteUser(userId));
+ }
+ }
+
+ @Test
+ public void canListUpdateAndDeleteMessages() {
+ String suffix = testResourceNamer.randomName("java", 20);
+ String userId = "java-test-message-user-" + suffix;
+ String roomId = "java-test-message-room-" + suffix;
+ String messageText = "Java live test message " + suffix;
+ String conversationId = null;
+ String messageId = null;
+
+ try {
+ client.createOrReplaceUser(userId,
+ new HumanChatUser("Java message test user", BuiltInChatRoles.USER_NORMAL));
+ ChatRoom room = client.createOrReplaceRoom(roomId, new ChatRoom("Java message test room"));
+ conversationId = room.getDefaultConversation();
+ client.createOrReplaceRoomMember(roomId, userId, new ChatRoomMember(BuiltInChatRoles.ROOM_MEMBER));
+
+ WebPubSubClientAccessToken accessToken
+ = entraClient.getClientAccessToken(new GetClientAccessTokenOptions().setUserId(userId));
+ assertNotNull(accessToken.getToken());
+ assertNotNull(accessToken.getUrl());
+
+ if (getTestMode() != TestMode.PLAYBACK) {
+ ChatMessageSeeder.sendTextMessage(accessToken.getUrl(), conversationId, messageText);
+ }
+ ChatMessage createdMessage = client.listMessages(conversationId)
+ .stream()
+ .filter(message -> userId.equals(message.getCreatedBy())
+ && messageText.equals(message.getContent().getText()))
+ .findFirst()
+ .orElseThrow(() -> new AssertionError("The seeded Chat message was not found."));
+ messageId = createdMessage.getId();
+
+ ChatMessage updatedText
+ = client.updateMessage(conversationId, messageId, new ChatMessage().setCreatedBy(userId)
+ .setContent(new MessageContent().setText(messageText + " updated")));
+ assertEquals(messageText + " updated", updatedText.getContent().getText());
+
+ byte[] binary = new byte[] { 0, 1, 2, (byte) 254, (byte) 255 };
+ ChatMessage updatedBinary = client.updateMessage(conversationId, messageId,
+ new ChatMessage().setCreatedBy(userId).setContent(new MessageContent().setBinary(binary)));
+ assertArrayEquals(binary, updatedBinary.getContent().getBinary());
+ client.deleteMessage(conversationId, messageId);
+ } finally {
+ String finalConversationId = conversationId;
+ String finalMessageId = messageId;
+ if (finalConversationId != null && finalMessageId != null) {
+ cleanup(() -> client.deleteMessage(finalConversationId, finalMessageId));
+ }
+ cleanup(() -> client.deleteRoomMember(roomId, userId));
+ cleanup(() -> client.deleteRoom(roomId));
+ cleanup(() -> client.deleteUser(userId));
+ }
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java
new file mode 100644
index 000000000000..ab8ddc7a6ff0
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/ChatServiceClientTestBase.java
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat;
+
+import com.azure.core.http.HttpClient;
+import com.azure.core.test.TestMode;
+import com.azure.core.test.TestProxyTestBase;
+import com.azure.core.test.models.TestProxySanitizer;
+import com.azure.core.test.models.TestProxySanitizerType;
+import com.azure.core.test.utils.MockTokenCredential;
+import com.azure.core.util.Configuration;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+
+import java.util.Collections;
+
+abstract class ChatServiceClientTestBase extends TestProxyTestBase {
+ private static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
+ .get("WPS_CHAT_CONNECTION_STRING",
+ "Endpoint=https://testendpoint.webpubsubdev.azure.com;AccessKey=LoremIpsumDolorSitAmetConsectetur;Version=1.0;");
+ private static final String ENDPOINT = Configuration.getGlobalConfiguration()
+ .get("WPS_CHAT_ENDPOINT", "https://testendpoint.webpubsubdev.azure.com");
+ private static final String HUB = "chat";
+
+ protected WebPubSubChatServiceClient client;
+ protected WebPubSubChatServiceAsyncClient asyncClient;
+ protected WebPubSubChatServiceClient entraClient;
+ protected WebPubSubChatServiceAsyncClient entraAsyncClient;
+
+ @Override
+ protected void beforeTest() {
+ if (getTestMode() != TestMode.LIVE) {
+ // These values are generated by testResourceNamer and are needed to correlate playback requests.
+ interceptorManager.removeSanitizers("AZSDK3430", "AZSDK3433", "AZSDK3442", "AZSDK3490", "AZSDK3493");
+ interceptorManager.addSanitizers(
+ Collections.singletonList(new TestProxySanitizer("https://(?[^/]+[.]webpubsub[.]azure[.]com)",
+ "REDACTED", TestProxySanitizerType.BODY_REGEX).setGroupForReplace("host")));
+ }
+
+ HttpClient httpClient
+ = getHttpClientOrUsePlayback(getHttpClients().findFirst().orElse(HttpClient.createDefault()));
+ WebPubSubChatServiceClientBuilder builder
+ = new WebPubSubChatServiceClientBuilder().connectionString(CONNECTION_STRING)
+ .hub(HUB)
+ .httpClient(httpClient);
+
+ if (getTestMode() == TestMode.RECORD) {
+ builder.addPolicy(interceptorManager.getRecordPolicy());
+ }
+
+ client = builder.buildClient();
+ asyncClient = builder.buildAsyncClient();
+
+ WebPubSubChatServiceClientBuilder entraBuilder = new WebPubSubChatServiceClientBuilder().endpoint(ENDPOINT)
+ .credential(getTestMode() == TestMode.PLAYBACK
+ ? new MockTokenCredential()
+ : new DefaultAzureCredentialBuilder().build())
+ .hub(HUB)
+ .httpClient(httpClient);
+ if (getTestMode() == TestMode.RECORD) {
+ entraBuilder.addPolicy(interceptorManager.getRecordPolicy());
+ }
+ entraClient = entraBuilder.buildClient();
+ entraAsyncClient = entraBuilder.buildAsyncClient();
+ }
+
+ protected static void cleanup(Runnable cleanup) {
+ try {
+ cleanup.run();
+ } catch (RuntimeException ignored) {
+ // Preserve the original test failure while making a best effort to remove live resources.
+ }
+ }
+}
diff --git a/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java
new file mode 100644
index 000000000000..3526f81a2f3d
--- /dev/null
+++ b/sdk/webpubsub/azure-messaging-webpubsub-chat/src/test/java/com/azure/messaging/webpubsub/chat/WebPubSubChatClientAccessTokenTests.java
@@ -0,0 +1,186 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.messaging.webpubsub.chat;
+
+import com.azure.core.credential.AzureKeyCredential;
+import com.azure.core.http.HttpHeaderName;
+import com.azure.core.http.HttpRequest;
+import com.azure.core.test.http.MockHttpResponse;
+import com.azure.core.test.utils.MockTokenCredential;
+import com.azure.messaging.webpubsub.chat.models.GetClientAccessTokenOptions;
+import com.azure.messaging.webpubsub.chat.models.WebPubSubClientAccessToken;
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.jwt.SignedJWT;
+import org.junit.jupiter.api.Test;
+import reactor.core.publisher.Mono;
+
+import java.nio.charset.StandardCharsets;
+import java.text.ParseException;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class WebPubSubChatClientAccessTokenTests {
+ private static final String ENDPOINT = "https://example.webpubsub.azure.com";
+ private static final String KEY = "01234567890123456789012345678901";
+
+ @Test
+ public void keyCredentialGeneratesChatTokenLocally() throws ParseException {
+ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder().endpoint(ENDPOINT)
+ .hub("chat")
+ .credential(new AzureKeyCredential(KEY))
+ .httpClient(request -> Mono.error(new AssertionError("Local token generation must not send a request.")))
+ .buildClient();
+
+ Instant before = Instant.now();
+ WebPubSubClientAccessToken token
+ = client.getClientAccessToken(new GetClientAccessTokenOptions().setUserId("alice"));
+
+ assertNotNull(token.getToken());
+ assertEquals("wss://example.webpubsub.azure.com/client/hubs/chat?access_token=" + token.getToken(),
+ token.getUrl());
+ JWTClaimsSet claims = SignedJWT.parse(token.getToken()).getJWTClaimsSet();
+ assertEquals("alice", claims.getSubject());
+ assertEquals(Arrays.asList("webpubsub.getGroupState", "webpubsub.setGroupState"), claims.getClaim("role"));
+ assertEquals(ENDPOINT + "/client/hubs/chat", claims.getAudience().get(0));
+ assertTrue(claims.getExpirationTime().toInstant().isAfter(before.plus(Duration.ofMinutes(59))));
+ assertTrue(claims.getExpirationTime().toInstant().isBefore(before.plus(Duration.ofMinutes(61))));
+ }
+
+ @Test
+ public void asyncKeyCredentialUsesSameTokenSemantics() throws ParseException {
+ WebPubSubChatServiceAsyncClient client = new WebPubSubChatServiceClientBuilder().endpoint(ENDPOINT)
+ .hub("chat")
+ .credential(new AzureKeyCredential(KEY))
+ .httpClient(request -> Mono.error(new AssertionError("Local token generation must not send a request.")))
+ .buildAsyncClient();
+
+ WebPubSubClientAccessToken token
+ = client.getClientAccessToken(new GetClientAccessTokenOptions().setUserId("alice")).block();
+
+ assertNotNull(token);
+ JWTClaimsSet claims = SignedJWT.parse(token.getToken()).getJWTClaimsSet();
+ assertEquals("alice", claims.getSubject());
+ assertEquals(Arrays.asList("webpubsub.getGroupState", "webpubsub.setGroupState"), claims.getClaim("role"));
+ }
+
+ @Test
+ public void connectionStringGeneratesTokenLocally() {
+ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder()
+ .connectionString("Endpoint=https://example.webpubsub.azure.com;AccessKey=" + KEY + ";Port=8443")
+ .hub("chat")
+ .httpClient(request -> Mono.error(new AssertionError("Local token generation must not send a request.")))
+ .buildClient();
+
+ WebPubSubClientAccessToken token = client.getClientAccessToken(new GetClientAccessTokenOptions());
+
+ assertTrue(token.getUrl().startsWith("wss://example.webpubsub.azure.com:8443/client/hubs/chat?access_token="));
+ }
+
+ @Test
+ public void signingFailureReturnsNullToken() {
+ WebPubSubChatServiceClient client = new WebPubSubChatServiceClientBuilder().endpoint(ENDPOINT)
+ .hub("chat")
+ .credential(new AzureKeyCredential("short-key"))
+ .buildClient();
+
+ WebPubSubClientAccessToken token = client.getClientAccessToken(new GetClientAccessTokenOptions());
+
+ assertNull(token.getToken());
+ assertEquals("wss://example.webpubsub.azure.com/client/hubs/chat?access_token=null", token.getUrl());
+ }
+
+ @Test
+ public void tokenCredentialCallsGenerateTokenOperation() {
+ AtomicReference sentRequest = new AtomicReference<>();
+ WebPubSubChatServiceClient client = createTokenCredentialClient(sentRequest, null);
+
+ WebPubSubClientAccessToken token = client.getClientAccessToken(
+ new GetClientAccessTokenOptions().setUserId("alice").setExpiresAfter(Duration.ofMinutes(30)));
+
+ assertEquals("server-token", token.getToken());
+ assertEquals("wss://example.webpubsub.azure.com/client/hubs/chat?access_token=server-token", token.getUrl());
+ assertEquals("/api/hubs/chat/:generateToken", sentRequest.get().getUrl().getPath());
+ String query = sentRequest.get().getUrl().getQuery();
+ assertTrue(query.contains("userId=alice"));
+ assertTrue(query.contains("minutesToExpire=30"));
+ assertTrue(query.contains("role=webpubsub.getGroupState"));
+ assertTrue(query.contains("role=webpubsub.setGroupState"));
+ assertTrue(query.contains("api-version=2024-12-01"));
+ assertTrue(query.contains("clientType=default"));
+ assertEquals("Bearer mockToken", sentRequest.get().getHeaders().getValue(HttpHeaderName.AUTHORIZATION));
+ }
+
+ @Test
+ public void asyncTokenCredentialCallsGenerateTokenOperation() {
+ AtomicReference sentRequest = new AtomicReference<>();
+ WebPubSubChatServiceAsyncClient client = new WebPubSubChatServiceClientBuilder().endpoint(ENDPOINT)
+ .hub("chat")
+ .credential(new MockTokenCredential())
+ .httpClient(request -> Mono.defer(() -> {
+ sentRequest.set(request);
+ byte[] body = "{\"token\":\"server-token\"}".getBytes(StandardCharsets.UTF_8);
+ return Mono.just(new MockHttpResponse(request, 200, body));
+ }))
+ .buildAsyncClient();
+
+ WebPubSubClientAccessToken token
+ = client.getClientAccessToken(new GetClientAccessTokenOptions().setUserId("alice")).block();
+
+ assertNotNull(token);
+ assertEquals("server-token", token.getToken());
+ assertEquals("/api/hubs/chat/:generateToken", sentRequest.get().getUrl().getPath());
+ assertTrue(sentRequest.get().getUrl().getQuery().contains("userId=alice"));
+ assertTrue(sentRequest.get().getUrl().getQuery().contains("minutesToExpire=60"));
+ }
+
+ @Test
+ public void tokenCredentialUsesReverseProxyForGenerateTokenOperation() {
+ AtomicReference