Class ChatServiceClient (0.6.0)

GitHub RepositoryProduct ReferenceREST Documentation

Service Description: Enables developers to build Chat apps and integrations on Google Chat Platform.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName parent = SpaceName.of("[SPACE]");
   Message message = Message.newBuilder().build();
   String messageId = "messageId-1440013438";
   Message response = chatServiceClient.createMessage(parent, message, messageId);
 }
 

Note: close() needs to be called on the ChatServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

CreateMessage

Creates a message in a Google Chat space. For an example, see Send a message.

Calling this method requires authentication and supports the following authentication types:

- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createMessage(CreateMessageRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createMessage(SpaceName parent, Message message, String messageId)

  • createMessage(String parent, Message message, String messageId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createMessageCallable()

ListMessages

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listMessages(ListMessagesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listMessages(SpaceName parent)

  • listMessages(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listMessagesPagedCallable()

  • listMessagesCallable()

ListMemberships

Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.

Requires authentication. Supports app authentication and user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listMemberships(ListMembershipsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listMemberships(SpaceName parent)

  • listMemberships(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listMembershipsPagedCallable()

  • listMembershipsCallable()

GetMembership

Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.

Requires authentication. Supports app authentication and user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getMembership(GetMembershipRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getMembership(MembershipName name)

  • getMembership(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getMembershipCallable()

GetMessage

Returns details about a message. For an example, see Get details about a message.

Requires authentication. Supports app authentication and user authentication.

Note: Might return a message from a blocked member or space.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getMessage(GetMessageRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getMessage(MessageName name)

  • getMessage(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getMessageCallable()

UpdateMessage

Updates a message. There's a difference between the patch and update methods. The patch method uses a patch request while the update method uses a put request. We recommend using the patch method. For an example, see Update a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateMessage(UpdateMessageRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateMessage(Message message, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateMessageCallable()

DeleteMessage

Deletes a message. For an example, see Delete a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteMessage(DeleteMessageRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteMessage(MessageName name)

  • deleteMessage(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteMessageCallable()

GetAttachment

Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getAttachment(GetAttachmentRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getAttachment(AttachmentName name)

  • getAttachment(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getAttachmentCallable()

UploadAttachment

Uploads an attachment. For an example, see Upload media as a file attachment. Requires user authentication.

You can upload attachments up to 200 MB. Certain file types aren't supported. For details, see File types blocked by Google Chat.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • uploadAttachment(UploadAttachmentRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • uploadAttachmentCallable()

ListSpaces

Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see List spaces.

Requires authentication. Supports app authentication and user authentication.

Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listSpaces(ListSpacesRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listSpaces()

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listSpacesPagedCallable()

  • listSpacesCallable()

GetSpace

Returns details about a space. For an example, see Get details about a space.

Requires authentication. Supports app authentication and user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSpace(GetSpaceRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSpace(SpaceName name)

  • getSpace(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSpaceCallable()

CreateSpace

Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.

If you receive the error message ALREADY_EXISTS when creating a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createSpace(CreateSpaceRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createSpace(Space space)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createSpaceCallable()

SetUpSpace

Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified as a membership in the request. For an example, see Set up a space with initial members.

To specify the human members to add, add memberships with the appropriate member.name in the SetUpSpaceRequest. To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

For a space or group chat, if the caller blocks or is blocked by some members, then those members aren't added to the created space.

To create a direct message (DM) between the calling user and another human user, specify exactly one membership to represent the human user. If one user blocks the other, the request fails and the DM isn't created.

To create a DM between the calling user and the calling app, set Space.singleUserBotDm to true and don't specify any memberships. You can only use this method to set up a DM with the calling app. To add the calling app as a member of a space or an existing DM between two human users, see Invite or add a user or app to a space.

If a DM already exists between two users, even when one user blocks the other at the time a request is made, then the existing DM is returned.

Spaces with threaded replies aren't supported. If you receive the error message ALREADY_EXISTS when setting up a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • setUpSpace(SetUpSpaceRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • setUpSpaceCallable()

UpdateSpace

Updates a space. For an example, see Update a space.

If you're updating the displayName field and receive the error message ALREADY_EXISTS, try a different display name.. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSpace(UpdateSpaceRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSpace(Space space, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSpaceCallable()

DeleteSpace

Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteSpace(DeleteSpaceRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteSpace(SpaceName name)

  • deleteSpace(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteSpaceCallable()

CompleteImportSpace

Completes the import process for the specified space and makes it visible to users. Requires app authentication and domain-wide delegation. For more information, see Authorize Google Chat apps to import data.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • completeImportSpace(CompleteImportSpaceRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • completeImportSpaceCallable()

FindDirectMessage

Returns the existing direct message with the specified user. If no direct message space is found, returns a 404 NOT_FOUND error. For an example, see Find a direct message.

With user authentication, returns the direct message space between the specified user and the authenticated user.

With app authentication, returns the direct message space between the specified user and the calling Chat app.

Requires user authentication or app authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • findDirectMessage(FindDirectMessageRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • findDirectMessageCallable()

CreateMembership

Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.

To specify the member to add, set the membership.member.name in the CreateMembershipRequest:

- To add the calling app to a space or a direct message between two human users, use users/app. Unable to add other apps to the space.

- To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createMembership(CreateMembershipRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createMembership(SpaceName parent, Membership membership)

  • createMembership(String parent, Membership membership)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createMembershipCallable()

UpdateMembership

Updates a membership. Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateMembership(UpdateMembershipRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateMembership(Membership membership, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateMembershipCallable()

DeleteMembership

Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteMembership(DeleteMembershipRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteMembership(MembershipName name)

  • deleteMembership(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteMembershipCallable()

CreateReaction

Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createReaction(CreateReactionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createReaction(MessageName parent, Reaction reaction)

  • createReaction(String parent, Reaction reaction)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createReactionCallable()

ListReactions

Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listReactions(ListReactionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listReactions(MessageName parent)

  • listReactions(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listReactionsPagedCallable()

  • listReactionsCallable()

DeleteReaction

Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteReaction(DeleteReactionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteReaction(ReactionName name)

  • deleteReaction(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteReactionCallable()

GetSpaceReadState

Returns details about a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSpaceReadState(GetSpaceReadStateRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSpaceReadState(SpaceReadStateName name)

  • getSpaceReadState(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSpaceReadStateCallable()

UpdateSpaceReadState

Updates a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSpaceReadState(UpdateSpaceReadStateRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSpaceReadState(SpaceReadState spaceReadState, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSpaceReadStateCallable()

GetThreadReadState

Returns details about a user's read state within a thread, used to identify read and unread messages.

Requires user authentication.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getThreadReadState(GetThreadReadStateRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getThreadReadState(ThreadReadStateName name)

  • getThreadReadState(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getThreadReadStateCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of ChatServiceSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ChatServiceSettings chatServiceSettings =
     ChatServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 ChatServiceClient chatServiceClient = ChatServiceClient.create(chatServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ChatServiceSettings chatServiceSettings =
     ChatServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 ChatServiceClient chatServiceClient = ChatServiceClient.create(chatServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 ChatServiceSettings chatServiceSettings = ChatServiceSettings.newHttpJsonBuilder().build();
 ChatServiceClient chatServiceClient = ChatServiceClient.create(chatServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > ChatServiceClient

Static Methods

create()

public static final ChatServiceClient create()

Constructs an instance of ChatServiceClient with default settings.

Returns
Type Description
ChatServiceClient
Exceptions
Type Description
IOException

create(ChatServiceSettings settings)

public static final ChatServiceClient create(ChatServiceSettings settings)

Constructs an instance of ChatServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings ChatServiceSettings
Returns
Type Description
ChatServiceClient
Exceptions
Type Description
IOException

create(ChatServiceStub stub)

public static final ChatServiceClient create(ChatServiceStub stub)

Constructs an instance of ChatServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ChatServiceSettings).

Parameter
Name Description
stub ChatServiceStub
Returns
Type Description
ChatServiceClient

Constructors

ChatServiceClient(ChatServiceSettings settings)

protected ChatServiceClient(ChatServiceSettings settings)

Constructs an instance of ChatServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings ChatServiceSettings

ChatServiceClient(ChatServiceStub stub)

protected ChatServiceClient(ChatServiceStub stub)
Parameter
Name Description
stub ChatServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

completeImportSpace(CompleteImportSpaceRequest request)

public final CompleteImportSpaceResponse completeImportSpace(CompleteImportSpaceRequest request)

Completes the import process for the specified space and makes it visible to users. Requires app authentication and domain-wide delegation. For more information, see Authorize Google Chat apps to import data.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CompleteImportSpaceRequest request =
       CompleteImportSpaceRequest.newBuilder()
           .setName(SpaceName.of("[SPACE]").toString())
           .build();
   CompleteImportSpaceResponse response = chatServiceClient.completeImportSpace(request);
 }
 
Parameter
Name Description
request CompleteImportSpaceRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
CompleteImportSpaceResponse

completeImportSpaceCallable()

public final UnaryCallable<CompleteImportSpaceRequest,CompleteImportSpaceResponse> completeImportSpaceCallable()

Completes the import process for the specified space and makes it visible to users. Requires app authentication and domain-wide delegation. For more information, see Authorize Google Chat apps to import data.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CompleteImportSpaceRequest request =
       CompleteImportSpaceRequest.newBuilder()
           .setName(SpaceName.of("[SPACE]").toString())
           .build();
   ApiFuture<CompleteImportSpaceResponse> future =
       chatServiceClient.completeImportSpaceCallable().futureCall(request);
   // Do something.
   CompleteImportSpaceResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CompleteImportSpaceRequest,CompleteImportSpaceResponse>

createMembership(CreateMembershipRequest request)

public final Membership createMembership(CreateMembershipRequest request)

Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.

To specify the member to add, set the membership.member.name in the CreateMembershipRequest:

- To add the calling app to a space or a direct message between two human users, use users/app. Unable to add other apps to the space.

- To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setMembership(Membership.newBuilder().build())
           .build();
   Membership response = chatServiceClient.createMembership(request);
 }
 
Parameter
Name Description
request CreateMembershipRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Membership

createMembership(SpaceName parent, Membership membership)

public final Membership createMembership(SpaceName parent, Membership membership)

Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.

To specify the member to add, set the membership.member.name in the CreateMembershipRequest:

- To add the calling app to a space or a direct message between two human users, use users/app. Unable to add other apps to the space.

- To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName parent = SpaceName.of("[SPACE]");
   Membership membership = Membership.newBuilder().build();
   Membership response = chatServiceClient.createMembership(parent, membership);
 }
 
Parameters
Name Description
parent SpaceName

Required. The resource name of the space for which to create the membership.

Format: spaces/{space}

membership Membership

Required. The membership relation to create. The memberType field must contain a user with the user.name and user.type fields populated. The server will assign a resource name and overwrite anything specified. When a Chat app creates a membership relation for a human user, it must use the chat.memberships scope, set user.type to HUMAN, and set user.name with format users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id of the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789. When a Chat app creates a membership relation for itself, it must use the chat.memberships.app scope, set user.type to BOT, and set user.name to users/app.

Returns
Type Description
Membership

createMembership(String parent, Membership membership)

public final Membership createMembership(String parent, Membership membership)

Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.

To specify the member to add, set the membership.member.name in the CreateMembershipRequest:

- To add the calling app to a space or a direct message between two human users, use users/app. Unable to add other apps to the space.

- To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String parent = SpaceName.of("[SPACE]").toString();
   Membership membership = Membership.newBuilder().build();
   Membership response = chatServiceClient.createMembership(parent, membership);
 }
 
Parameters
Name Description
parent String

Required. The resource name of the space for which to create the membership.

Format: spaces/{space}

membership Membership

Required. The membership relation to create. The memberType field must contain a user with the user.name and user.type fields populated. The server will assign a resource name and overwrite anything specified. When a Chat app creates a membership relation for a human user, it must use the chat.memberships scope, set user.type to HUMAN, and set user.name with format users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id of the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789. When a Chat app creates a membership relation for itself, it must use the chat.memberships.app scope, set user.type to BOT, and set user.name to users/app.

Returns
Type Description
Membership

createMembershipCallable()

public final UnaryCallable<CreateMembershipRequest,Membership> createMembershipCallable()

Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.

To specify the member to add, set the membership.member.name in the CreateMembershipRequest:

- To add the calling app to a space or a direct message between two human users, use users/app. Unable to add other apps to the space.

- To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setMembership(Membership.newBuilder().build())
           .build();
   ApiFuture<Membership> future =
       chatServiceClient.createMembershipCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateMembershipRequest,Membership>

createMessage(CreateMessageRequest request)

public final Message createMessage(CreateMessageRequest request)

Creates a message in a Google Chat space. For an example, see Send a message.

Calling this method requires authentication and supports the following authentication types:

- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateMessageRequest request =
       CreateMessageRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setMessage(Message.newBuilder().build())
           .setThreadKey("threadKey-1562254347")
           .setRequestId("requestId693933066")
           .setMessageId("messageId-1440013438")
           .build();
   Message response = chatServiceClient.createMessage(request);
 }
 
Parameter
Name Description
request CreateMessageRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Message

createMessage(SpaceName parent, Message message, String messageId)

public final Message createMessage(SpaceName parent, Message message, String messageId)

Creates a message in a Google Chat space. For an example, see Send a message.

Calling this method requires authentication and supports the following authentication types:

- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName parent = SpaceName.of("[SPACE]");
   Message message = Message.newBuilder().build();
   String messageId = "messageId-1440013438";
   Message response = chatServiceClient.createMessage(parent, message, messageId);
 }
 
Parameters
Name Description
parent SpaceName

Required. The resource name of the space in which to create a message.

Format: spaces/{space}

message Message

Required. Message body.

messageId String

Optional. A custom ID for a message. Lets Chat apps get, update, or delete a message without needing to store the system-assigned ID in the message's resource name (represented in the message name field).

The value for this field must meet the following requirements:

  • Begins with client-. For example, client-custom-name is a valid custom ID, but custom-name is not.
  • Contains up to 63 characters and only lowercase letters, numbers, and hyphens.
  • Is unique within a space. A Chat app can't use the same custom ID for different messages.

For details, see Name a message.

Returns
Type Description
Message

createMessage(String parent, Message message, String messageId)

public final Message createMessage(String parent, Message message, String messageId)

Creates a message in a Google Chat space. For an example, see Send a message.

Calling this method requires authentication and supports the following authentication types:

- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String parent = SpaceName.of("[SPACE]").toString();
   Message message = Message.newBuilder().build();
   String messageId = "messageId-1440013438";
   Message response = chatServiceClient.createMessage(parent, message, messageId);
 }
 
Parameters
Name Description
parent String

Required. The resource name of the space in which to create a message.

Format: spaces/{space}

message Message

Required. Message body.

messageId String

Optional. A custom ID for a message. Lets Chat apps get, update, or delete a message without needing to store the system-assigned ID in the message's resource name (represented in the message name field).

The value for this field must meet the following requirements:

  • Begins with client-. For example, client-custom-name is a valid custom ID, but custom-name is not.
  • Contains up to 63 characters and only lowercase letters, numbers, and hyphens.
  • Is unique within a space. A Chat app can't use the same custom ID for different messages.

For details, see Name a message.

Returns
Type Description
Message

createMessageCallable()

public final UnaryCallable<CreateMessageRequest,Message> createMessageCallable()

Creates a message in a Google Chat space. For an example, see Send a message.

Calling this method requires authentication and supports the following authentication types:

- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateMessageRequest request =
       CreateMessageRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setMessage(Message.newBuilder().build())
           .setThreadKey("threadKey-1562254347")
           .setRequestId("requestId693933066")
           .setMessageId("messageId-1440013438")
           .build();
   ApiFuture<Message> future = chatServiceClient.createMessageCallable().futureCall(request);
   // Do something.
   Message response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateMessageRequest,Message>

createReaction(CreateReactionRequest request)

public final Reaction createReaction(CreateReactionRequest request)

Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateReactionRequest request =
       CreateReactionRequest.newBuilder()
           .setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setReaction(Reaction.newBuilder().build())
           .build();
   Reaction response = chatServiceClient.createReaction(request);
 }
 
Parameter
Name Description
request CreateReactionRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Reaction

createReaction(MessageName parent, Reaction reaction)

public final Reaction createReaction(MessageName parent, Reaction reaction)

Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   MessageName parent = MessageName.of("[SPACE]", "[MESSAGE]");
   Reaction reaction = Reaction.newBuilder().build();
   Reaction response = chatServiceClient.createReaction(parent, reaction);
 }
 
Parameters
Name Description
parent MessageName

Required. The message where the reaction is created.

Format: spaces/{space}/messages/{message}

reaction Reaction

Required. The reaction to create.

Returns
Type Description
Reaction

createReaction(String parent, Reaction reaction)

public final Reaction createReaction(String parent, Reaction reaction)

Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String parent = MessageName.of("[SPACE]", "[MESSAGE]").toString();
   Reaction reaction = Reaction.newBuilder().build();
   Reaction response = chatServiceClient.createReaction(parent, reaction);
 }
 
Parameters
Name Description
parent String

Required. The message where the reaction is created.

Format: spaces/{space}/messages/{message}

reaction Reaction

Required. The reaction to create.

Returns
Type Description
Reaction

createReactionCallable()

public final UnaryCallable<CreateReactionRequest,Reaction> createReactionCallable()

Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateReactionRequest request =
       CreateReactionRequest.newBuilder()
           .setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setReaction(Reaction.newBuilder().build())
           .build();
   ApiFuture<Reaction> future = chatServiceClient.createReactionCallable().futureCall(request);
   // Do something.
   Reaction response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateReactionRequest,Reaction>

createSpace(CreateSpaceRequest request)

public final Space createSpace(CreateSpaceRequest request)

Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.

If you receive the error message ALREADY_EXISTS when creating a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateSpaceRequest request =
       CreateSpaceRequest.newBuilder()
           .setSpace(Space.newBuilder().build())
           .setRequestId("requestId693933066")
           .build();
   Space response = chatServiceClient.createSpace(request);
 }
 
Parameter
Name Description
request CreateSpaceRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Space

createSpace(Space space)

public final Space createSpace(Space space)

Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.

If you receive the error message ALREADY_EXISTS when creating a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   Space space = Space.newBuilder().build();
   Space response = chatServiceClient.createSpace(space);
 }
 
Parameter
Name Description
space Space

Required. The displayName and spaceType fields must be populated. Only SpaceType.SPACE is supported.

If you receive the error message ALREADY_EXISTS when creating a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

The space name is assigned on the server so anything specified in this field will be ignored.

Returns
Type Description
Space

createSpaceCallable()

public final UnaryCallable<CreateSpaceRequest,Space> createSpaceCallable()

Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.

If you receive the error message ALREADY_EXISTS when creating a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   CreateSpaceRequest request =
       CreateSpaceRequest.newBuilder()
           .setSpace(Space.newBuilder().build())
           .setRequestId("requestId693933066")
           .build();
   ApiFuture<Space> future = chatServiceClient.createSpaceCallable().futureCall(request);
   // Do something.
   Space response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateSpaceRequest,Space>

deleteMembership(DeleteMembershipRequest request)

public final Membership deleteMembership(DeleteMembershipRequest request)

Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteMembershipRequest request =
       DeleteMembershipRequest.newBuilder()
           .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
           .build();
   Membership response = chatServiceClient.deleteMembership(request);
 }
 
Parameter
Name Description
request DeleteMembershipRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Membership

deleteMembership(MembershipName name)

public final Membership deleteMembership(MembershipName name)

Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   MembershipName name = MembershipName.of("[SPACE]", "[MEMBER]");
   Membership response = chatServiceClient.deleteMembership(name);
 }
 
Parameter
Name Description
name MembershipName

Required. Resource name of the membership to delete. Chat apps can delete human users' or their own memberships. Chat apps can't delete other apps' memberships.

When deleting a human membership, requires the chat.memberships scope and spaces/{space}/members/{member} format. You can use the email as an alias for {member}. For example, spaces/{space}/members/example@gmail.com where example@gmail.com is the email of the Google Chat user.

When deleting an app membership, requires the chat.memberships.app scope and spaces/{space}/members/app format.

Format: spaces/{space}/members/{member} or spaces/{space}/members/app.

Returns
Type Description
Membership

deleteMembership(String name)

public final Membership deleteMembership(String name)

Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = MembershipName.of("[SPACE]", "[MEMBER]").toString();
   Membership response = chatServiceClient.deleteMembership(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the membership to delete. Chat apps can delete human users' or their own memberships. Chat apps can't delete other apps' memberships.

When deleting a human membership, requires the chat.memberships scope and spaces/{space}/members/{member} format. You can use the email as an alias for {member}. For example, spaces/{space}/members/example@gmail.com where example@gmail.com is the email of the Google Chat user.

When deleting an app membership, requires the chat.memberships.app scope and spaces/{space}/members/app format.

Format: spaces/{space}/members/{member} or spaces/{space}/members/app.

Returns
Type Description
Membership

deleteMembershipCallable()

public final UnaryCallable<DeleteMembershipRequest,Membership> deleteMembershipCallable()

Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteMembershipRequest request =
       DeleteMembershipRequest.newBuilder()
           .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
           .build();
   ApiFuture<Membership> future =
       chatServiceClient.deleteMembershipCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteMembershipRequest,Membership>

deleteMessage(DeleteMessageRequest request)

public final void deleteMessage(DeleteMessageRequest request)

Deletes a message. For an example, see Delete a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteMessageRequest request =
       DeleteMessageRequest.newBuilder()
           .setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setForce(true)
           .build();
   chatServiceClient.deleteMessage(request);
 }
 
Parameter
Name Description
request DeleteMessageRequest

The request object containing all of the parameters for the API call.

deleteMessage(MessageName name)

public final void deleteMessage(MessageName name)

Deletes a message. For an example, see Delete a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   MessageName name = MessageName.of("[SPACE]", "[MESSAGE]");
   chatServiceClient.deleteMessage(name);
 }
 
Parameter
Name Description
name MessageName

Required. Resource name of the message.

Format: spaces/{space}/messages/{message}

If you've set a custom ID for your message, you can use the value from the clientAssignedMessageId field for {message}. For details, see Name a message.

deleteMessage(String name)

public final void deleteMessage(String name)

Deletes a message. For an example, see Delete a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = MessageName.of("[SPACE]", "[MESSAGE]").toString();
   chatServiceClient.deleteMessage(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the message.

Format: spaces/{space}/messages/{message}

If you've set a custom ID for your message, you can use the value from the clientAssignedMessageId field for {message}. For details, see Name a message.

deleteMessageCallable()

public final UnaryCallable<DeleteMessageRequest,Empty> deleteMessageCallable()

Deletes a message. For an example, see Delete a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteMessageRequest request =
       DeleteMessageRequest.newBuilder()
           .setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setForce(true)
           .build();
   ApiFuture<Empty> future = chatServiceClient.deleteMessageCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteMessageRequest,Empty>

deleteReaction(DeleteReactionRequest request)

public final void deleteReaction(DeleteReactionRequest request)

Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteReactionRequest request =
       DeleteReactionRequest.newBuilder()
           .setName(ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]").toString())
           .build();
   chatServiceClient.deleteReaction(request);
 }
 
Parameter
Name Description
request DeleteReactionRequest

The request object containing all of the parameters for the API call.

deleteReaction(ReactionName name)

public final void deleteReaction(ReactionName name)

Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ReactionName name = ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]");
   chatServiceClient.deleteReaction(name);
 }
 
Parameter
Name Description
name ReactionName

Required. Name of the reaction to delete.

Format: spaces/{space}/messages/{message}/reactions/{reaction}

deleteReaction(String name)

public final void deleteReaction(String name)

Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]").toString();
   chatServiceClient.deleteReaction(name);
 }
 
Parameter
Name Description
name String

Required. Name of the reaction to delete.

Format: spaces/{space}/messages/{message}/reactions/{reaction}

deleteReactionCallable()

public final UnaryCallable<DeleteReactionRequest,Empty> deleteReactionCallable()

Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteReactionRequest request =
       DeleteReactionRequest.newBuilder()
           .setName(ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]").toString())
           .build();
   ApiFuture<Empty> future = chatServiceClient.deleteReactionCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteReactionRequest,Empty>

deleteSpace(DeleteSpaceRequest request)

public final void deleteSpace(DeleteSpaceRequest request)

Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteSpaceRequest request =
       DeleteSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build();
   chatServiceClient.deleteSpace(request);
 }
 
Parameter
Name Description
request DeleteSpaceRequest

The request object containing all of the parameters for the API call.

deleteSpace(SpaceName name)

public final void deleteSpace(SpaceName name)

Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName name = SpaceName.of("[SPACE]");
   chatServiceClient.deleteSpace(name);
 }
 
Parameter
Name Description
name SpaceName

Required. Resource name of the space to delete.

Format: spaces/{space}

deleteSpace(String name)

public final void deleteSpace(String name)

Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = SpaceName.of("[SPACE]").toString();
   chatServiceClient.deleteSpace(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the space to delete.

Format: spaces/{space}

deleteSpaceCallable()

public final UnaryCallable<DeleteSpaceRequest,Empty> deleteSpaceCallable()

Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   DeleteSpaceRequest request =
       DeleteSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build();
   ApiFuture<Empty> future = chatServiceClient.deleteSpaceCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteSpaceRequest,Empty>

findDirectMessage(FindDirectMessageRequest request)

public final Space findDirectMessage(FindDirectMessageRequest request)

Returns the existing direct message with the specified user. If no direct message space is found, returns a 404 NOT_FOUND error. For an example, see Find a direct message.

With user authentication, returns the direct message space between the specified user and the authenticated user.

With app authentication, returns the direct message space between the specified user and the calling Chat app.

Requires user authentication or app authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   FindDirectMessageRequest request =
       FindDirectMessageRequest.newBuilder().setName("name3373707").build();
   Space response = chatServiceClient.findDirectMessage(request);
 }
 
Parameter
Name Description
request FindDirectMessageRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Space

findDirectMessageCallable()

public final UnaryCallable<FindDirectMessageRequest,Space> findDirectMessageCallable()

Returns the existing direct message with the specified user. If no direct message space is found, returns a 404 NOT_FOUND error. For an example, see Find a direct message.

With user authentication, returns the direct message space between the specified user and the authenticated user.

With app authentication, returns the direct message space between the specified user and the calling Chat app.

Requires user authentication or app authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   FindDirectMessageRequest request =
       FindDirectMessageRequest.newBuilder().setName("name3373707").build();
   ApiFuture<Space> future = chatServiceClient.findDirectMessageCallable().futureCall(request);
   // Do something.
   Space response = future.get();
 }
 
Returns
Type Description
UnaryCallable<FindDirectMessageRequest,Space>

getAttachment(AttachmentName name)

public final Attachment getAttachment(AttachmentName name)

Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   AttachmentName name = AttachmentName.of("[SPACE]", "[MESSAGE]", "[ATTACHMENT]");
   Attachment response = chatServiceClient.getAttachment(name);
 }
 
Parameter
Name Description
name AttachmentName

Required. Resource name of the attachment, in the form spaces/*/messages/*/attachments/*.

Returns
Type Description
Attachment

getAttachment(GetAttachmentRequest request)

public final Attachment getAttachment(GetAttachmentRequest request)

Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetAttachmentRequest request =
       GetAttachmentRequest.newBuilder()
           .setName(AttachmentName.of("[SPACE]", "[MESSAGE]", "[ATTACHMENT]").toString())
           .build();
   Attachment response = chatServiceClient.getAttachment(request);
 }
 
Parameter
Name Description
request GetAttachmentRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Attachment

getAttachment(String name)

public final Attachment getAttachment(String name)

Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = AttachmentName.of("[SPACE]", "[MESSAGE]", "[ATTACHMENT]").toString();
   Attachment response = chatServiceClient.getAttachment(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the attachment, in the form spaces/*/messages/*/attachments/*.

Returns
Type Description
Attachment

getAttachmentCallable()

public final UnaryCallable<GetAttachmentRequest,Attachment> getAttachmentCallable()

Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetAttachmentRequest request =
       GetAttachmentRequest.newBuilder()
           .setName(AttachmentName.of("[SPACE]", "[MESSAGE]", "[ATTACHMENT]").toString())
           .build();
   ApiFuture<Attachment> future = chatServiceClient.getAttachmentCallable().futureCall(request);
   // Do something.
   Attachment response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetAttachmentRequest,Attachment>

getMembership(GetMembershipRequest request)

public final Membership getMembership(GetMembershipRequest request)

Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetMembershipRequest request =
       GetMembershipRequest.newBuilder()
           .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
           .build();
   Membership response = chatServiceClient.getMembership(request);
 }
 
Parameter
Name Description
request GetMembershipRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Membership

getMembership(MembershipName name)

public final Membership getMembership(MembershipName name)

Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   MembershipName name = MembershipName.of("[SPACE]", "[MEMBER]");
   Membership response = chatServiceClient.getMembership(name);
 }
 
Parameter
Name Description
name MembershipName

Required. Resource name of the membership to retrieve.

To get the app's own membership, you can optionally use spaces/{space}/members/app.

Format: spaces/{space}/members/{member} or spaces/{space}/members/app

When authenticated as a user, you can use the user's email as an alias for {member}. For example, spaces/{space}/members/example@gmail.com where example@gmail.com is the email of the Google Chat user.

Returns
Type Description
Membership

getMembership(String name)

public final Membership getMembership(String name)

Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = MembershipName.of("[SPACE]", "[MEMBER]").toString();
   Membership response = chatServiceClient.getMembership(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the membership to retrieve.

To get the app's own membership, you can optionally use spaces/{space}/members/app.

Format: spaces/{space}/members/{member} or spaces/{space}/members/app

When authenticated as a user, you can use the user's email as an alias for {member}. For example, spaces/{space}/members/example@gmail.com where example@gmail.com is the email of the Google Chat user.

Returns
Type Description
Membership

getMembershipCallable()

public final UnaryCallable<GetMembershipRequest,Membership> getMembershipCallable()

Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetMembershipRequest request =
       GetMembershipRequest.newBuilder()
           .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
           .build();
   ApiFuture<Membership> future = chatServiceClient.getMembershipCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetMembershipRequest,Membership>

getMessage(GetMessageRequest request)

public final Message getMessage(GetMessageRequest request)

Returns details about a message. For an example, see Get details about a message.

Requires authentication. Supports app authentication and user authentication.

Note: Might return a message from a blocked member or space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetMessageRequest request =
       GetMessageRequest.newBuilder()
           .setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .build();
   Message response = chatServiceClient.getMessage(request);
 }
 
Parameter
Name Description
request GetMessageRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Message

getMessage(MessageName name)

public final Message getMessage(MessageName name)

Returns details about a message. For an example, see Get details about a message.

Requires authentication. Supports app authentication and user authentication.

Note: Might return a message from a blocked member or space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   MessageName name = MessageName.of("[SPACE]", "[MESSAGE]");
   Message response = chatServiceClient.getMessage(name);
 }
 
Parameter
Name Description
name MessageName

Required. Resource name of the message.

Format: spaces/{space}/messages/{message}

If you've set a custom ID for your message, you can use the value from the clientAssignedMessageId field for {message}. For details, see Name a message.

Returns
Type Description
Message

getMessage(String name)

public final Message getMessage(String name)

Returns details about a message. For an example, see Get details about a message.

Requires authentication. Supports app authentication and user authentication.

Note: Might return a message from a blocked member or space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = MessageName.of("[SPACE]", "[MESSAGE]").toString();
   Message response = chatServiceClient.getMessage(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the message.

Format: spaces/{space}/messages/{message}

If you've set a custom ID for your message, you can use the value from the clientAssignedMessageId field for {message}. For details, see Name a message.

Returns
Type Description
Message

getMessageCallable()

public final UnaryCallable<GetMessageRequest,Message> getMessageCallable()

Returns details about a message. For an example, see Get details about a message.

Requires authentication. Supports app authentication and user authentication.

Note: Might return a message from a blocked member or space.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetMessageRequest request =
       GetMessageRequest.newBuilder()
           .setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .build();
   ApiFuture<Message> future = chatServiceClient.getMessageCallable().futureCall(request);
   // Do something.
   Message response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetMessageRequest,Message>

getSettings()

public final ChatServiceSettings getSettings()
Returns
Type Description
ChatServiceSettings

getSpace(GetSpaceRequest request)

public final Space getSpace(GetSpaceRequest request)

Returns details about a space. For an example, see Get details about a space.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetSpaceRequest request =
       GetSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build();
   Space response = chatServiceClient.getSpace(request);
 }
 
Parameter
Name Description
request GetSpaceRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Space

getSpace(SpaceName name)

public final Space getSpace(SpaceName name)

Returns details about a space. For an example, see Get details about a space.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName name = SpaceName.of("[SPACE]");
   Space response = chatServiceClient.getSpace(name);
 }
 
Parameter
Name Description
name SpaceName

Required. Resource name of the space, in the form "spaces/*".

Format: spaces/{space}

Returns
Type Description
Space

getSpace(String name)

public final Space getSpace(String name)

Returns details about a space. For an example, see Get details about a space.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = SpaceName.of("[SPACE]").toString();
   Space response = chatServiceClient.getSpace(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the space, in the form "spaces/*".

Format: spaces/{space}

Returns
Type Description
Space

getSpaceCallable()

public final UnaryCallable<GetSpaceRequest,Space> getSpaceCallable()

Returns details about a space. For an example, see Get details about a space.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetSpaceRequest request =
       GetSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build();
   ApiFuture<Space> future = chatServiceClient.getSpaceCallable().futureCall(request);
   // Do something.
   Space response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetSpaceRequest,Space>

getSpaceReadState(GetSpaceReadStateRequest request)

public final SpaceReadState getSpaceReadState(GetSpaceReadStateRequest request)

Returns details about a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetSpaceReadStateRequest request =
       GetSpaceReadStateRequest.newBuilder()
           .setName(SpaceReadStateName.of("[USER]", "[SPACE]").toString())
           .build();
   SpaceReadState response = chatServiceClient.getSpaceReadState(request);
 }
 
Parameter
Name Description
request GetSpaceReadStateRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
SpaceReadState

getSpaceReadState(SpaceReadStateName name)

public final SpaceReadState getSpaceReadState(SpaceReadStateName name)

Returns details about a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceReadStateName name = SpaceReadStateName.of("[USER]", "[SPACE]");
   SpaceReadState response = chatServiceClient.getSpaceReadState(name);
 }
 
Parameter
Name Description
name SpaceReadStateName

Required. Resource name of the space read state to retrieve.

Only supports getting read state for the calling user.

To refer to the calling user, set one of the following:

- The me alias. For example, users/me/spaces/{space}/spaceReadState.

- Their Workspace email address. For example, users/user@example.com/spaces/{space}/spaceReadState.

- Their user id. For example, users/123456789/spaces/{space}/spaceReadState.

Format: users/{user}/spaces/{space}/spaceReadState

Returns
Type Description
SpaceReadState

getSpaceReadState(String name)

public final SpaceReadState getSpaceReadState(String name)

Returns details about a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = SpaceReadStateName.of("[USER]", "[SPACE]").toString();
   SpaceReadState response = chatServiceClient.getSpaceReadState(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the space read state to retrieve.

Only supports getting read state for the calling user.

To refer to the calling user, set one of the following:

- The me alias. For example, users/me/spaces/{space}/spaceReadState.

- Their Workspace email address. For example, users/user@example.com/spaces/{space}/spaceReadState.

- Their user id. For example, users/123456789/spaces/{space}/spaceReadState.

Format: users/{user}/spaces/{space}/spaceReadState

Returns
Type Description
SpaceReadState

getSpaceReadStateCallable()

public final UnaryCallable<GetSpaceReadStateRequest,SpaceReadState> getSpaceReadStateCallable()

Returns details about a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetSpaceReadStateRequest request =
       GetSpaceReadStateRequest.newBuilder()
           .setName(SpaceReadStateName.of("[USER]", "[SPACE]").toString())
           .build();
   ApiFuture<SpaceReadState> future =
       chatServiceClient.getSpaceReadStateCallable().futureCall(request);
   // Do something.
   SpaceReadState response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetSpaceReadStateRequest,SpaceReadState>

getStub()

public ChatServiceStub getStub()
Returns
Type Description
ChatServiceStub

getThreadReadState(GetThreadReadStateRequest request)

public final ThreadReadState getThreadReadState(GetThreadReadStateRequest request)

Returns details about a user's read state within a thread, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetThreadReadStateRequest request =
       GetThreadReadStateRequest.newBuilder()
           .setName(ThreadReadStateName.of("[USER]", "[SPACE]", "[THREAD]").toString())
           .build();
   ThreadReadState response = chatServiceClient.getThreadReadState(request);
 }
 
Parameter
Name Description
request GetThreadReadStateRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ThreadReadState

getThreadReadState(ThreadReadStateName name)

public final ThreadReadState getThreadReadState(ThreadReadStateName name)

Returns details about a user's read state within a thread, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ThreadReadStateName name = ThreadReadStateName.of("[USER]", "[SPACE]", "[THREAD]");
   ThreadReadState response = chatServiceClient.getThreadReadState(name);
 }
 
Parameter
Name Description
name ThreadReadStateName

Required. Resource name of the thread read state to retrieve.

Only supports getting read state for the calling user.

To refer to the calling user, set one of the following:

- The me alias. For example, users/me/spaces/{space}/threads/{thread}/threadReadState.

- Their Workspace email address. For example, users/user@example.com/spaces/{space}/threads/{thread}/threadReadState.

- Their user id. For example, users/123456789/spaces/{space}/threads/{thread}/threadReadState.

Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState

Returns
Type Description
ThreadReadState

getThreadReadState(String name)

public final ThreadReadState getThreadReadState(String name)

Returns details about a user's read state within a thread, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String name = ThreadReadStateName.of("[USER]", "[SPACE]", "[THREAD]").toString();
   ThreadReadState response = chatServiceClient.getThreadReadState(name);
 }
 
Parameter
Name Description
name String

Required. Resource name of the thread read state to retrieve.

Only supports getting read state for the calling user.

To refer to the calling user, set one of the following:

- The me alias. For example, users/me/spaces/{space}/threads/{thread}/threadReadState.

- Their Workspace email address. For example, users/user@example.com/spaces/{space}/threads/{thread}/threadReadState.

- Their user id. For example, users/123456789/spaces/{space}/threads/{thread}/threadReadState.

Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState

Returns
Type Description
ThreadReadState

getThreadReadStateCallable()

public final UnaryCallable<GetThreadReadStateRequest,ThreadReadState> getThreadReadStateCallable()

Returns details about a user's read state within a thread, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   GetThreadReadStateRequest request =
       GetThreadReadStateRequest.newBuilder()
           .setName(ThreadReadStateName.of("[USER]", "[SPACE]", "[THREAD]").toString())
           .build();
   ApiFuture<ThreadReadState> future =
       chatServiceClient.getThreadReadStateCallable().futureCall(request);
   // Do something.
   ThreadReadState response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetThreadReadStateRequest,ThreadReadState>

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listMemberships(ListMembershipsRequest request)

public final ChatServiceClient.ListMembershipsPagedResponse listMemberships(ListMembershipsRequest request)

Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListMembershipsRequest request =
       ListMembershipsRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setShowGroups(true)
           .setShowInvited(true)
           .build();
   for (Membership element : chatServiceClient.listMemberships(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListMembershipsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ChatServiceClient.ListMembershipsPagedResponse

listMemberships(SpaceName parent)

public final ChatServiceClient.ListMembershipsPagedResponse listMemberships(SpaceName parent)

Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName parent = SpaceName.of("[SPACE]");
   for (Membership element : chatServiceClient.listMemberships(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent SpaceName

Required. The resource name of the space for which to fetch a membership list.

Format: spaces/{space}

Returns
Type Description
ChatServiceClient.ListMembershipsPagedResponse

listMemberships(String parent)

public final ChatServiceClient.ListMembershipsPagedResponse listMemberships(String parent)

Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String parent = SpaceName.of("[SPACE]").toString();
   for (Membership element : chatServiceClient.listMemberships(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The resource name of the space for which to fetch a membership list.

Format: spaces/{space}

Returns
Type Description
ChatServiceClient.ListMembershipsPagedResponse

listMembershipsCallable()

public final UnaryCallable<ListMembershipsRequest,ListMembershipsResponse> listMembershipsCallable()

Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListMembershipsRequest request =
       ListMembershipsRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setShowGroups(true)
           .setShowInvited(true)
           .build();
   while (true) {
     ListMembershipsResponse response =
         chatServiceClient.listMembershipsCallable().call(request);
     for (Membership element : response.getMembershipsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListMembershipsRequest,ListMembershipsResponse>

listMembershipsPagedCallable()

public final UnaryCallable<ListMembershipsRequest,ChatServiceClient.ListMembershipsPagedResponse> listMembershipsPagedCallable()

Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.

Requires authentication. Supports app authentication and user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListMembershipsRequest request =
       ListMembershipsRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setShowGroups(true)
           .setShowInvited(true)
           .build();
   ApiFuture<Membership> future =
       chatServiceClient.listMembershipsPagedCallable().futureCall(request);
   // Do something.
   for (Membership element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListMembershipsRequest,ListMembershipsPagedResponse>

listMessages(ListMessagesRequest request)

public final ChatServiceClient.ListMessagesPagedResponse listMessages(ListMessagesRequest request)

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListMessagesRequest request =
       ListMessagesRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setShowDeleted(true)
           .build();
   for (Message element : chatServiceClient.listMessages(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListMessagesRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ChatServiceClient.ListMessagesPagedResponse

listMessages(SpaceName parent)

public final ChatServiceClient.ListMessagesPagedResponse listMessages(SpaceName parent)

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceName parent = SpaceName.of("[SPACE]");
   for (Message element : chatServiceClient.listMessages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent SpaceName

Required. The resource name of the space to list messages from.

Format: spaces/{space}

Returns
Type Description
ChatServiceClient.ListMessagesPagedResponse

listMessages(String parent)

public final ChatServiceClient.ListMessagesPagedResponse listMessages(String parent)

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String parent = SpaceName.of("[SPACE]").toString();
   for (Message element : chatServiceClient.listMessages(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The resource name of the space to list messages from.

Format: spaces/{space}

Returns
Type Description
ChatServiceClient.ListMessagesPagedResponse

listMessagesCallable()

public final UnaryCallable<ListMessagesRequest,ListMessagesResponse> listMessagesCallable()

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListMessagesRequest request =
       ListMessagesRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setShowDeleted(true)
           .build();
   while (true) {
     ListMessagesResponse response = chatServiceClient.listMessagesCallable().call(request);
     for (Message element : response.getMessagesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListMessagesRequest,ListMessagesResponse>

listMessagesPagedCallable()

public final UnaryCallable<ListMessagesRequest,ChatServiceClient.ListMessagesPagedResponse> listMessagesPagedCallable()

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListMessagesRequest request =
       ListMessagesRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .setOrderBy("orderBy-1207110587")
           .setShowDeleted(true)
           .build();
   ApiFuture<Message> future = chatServiceClient.listMessagesPagedCallable().futureCall(request);
   // Do something.
   for (Message element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListMessagesRequest,ListMessagesPagedResponse>

listReactions(ListReactionsRequest request)

public final ChatServiceClient.ListReactionsPagedResponse listReactions(ListReactionsRequest request)

Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListReactionsRequest request =
       ListReactionsRequest.newBuilder()
           .setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (Reaction element : chatServiceClient.listReactions(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListReactionsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ChatServiceClient.ListReactionsPagedResponse

listReactions(MessageName parent)

public final ChatServiceClient.ListReactionsPagedResponse listReactions(MessageName parent)

Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   MessageName parent = MessageName.of("[SPACE]", "[MESSAGE]");
   for (Reaction element : chatServiceClient.listReactions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent MessageName

Required. The message users reacted to.

Format: spaces/{space}/messages/{message}

Returns
Type Description
ChatServiceClient.ListReactionsPagedResponse

listReactions(String parent)

public final ChatServiceClient.ListReactionsPagedResponse listReactions(String parent)

Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   String parent = MessageName.of("[SPACE]", "[MESSAGE]").toString();
   for (Reaction element : chatServiceClient.listReactions(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The message users reacted to.

Format: spaces/{space}/messages/{message}

Returns
Type Description
ChatServiceClient.ListReactionsPagedResponse

listReactionsCallable()

public final UnaryCallable<ListReactionsRequest,ListReactionsResponse> listReactionsCallable()

Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListReactionsRequest request =
       ListReactionsRequest.newBuilder()
           .setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListReactionsResponse response = chatServiceClient.listReactionsCallable().call(request);
     for (Reaction element : response.getReactionsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListReactionsRequest,ListReactionsResponse>

listReactionsPagedCallable()

public final UnaryCallable<ListReactionsRequest,ChatServiceClient.ListReactionsPagedResponse> listReactionsPagedCallable()

Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListReactionsRequest request =
       ListReactionsRequest.newBuilder()
           .setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<Reaction> future =
       chatServiceClient.listReactionsPagedCallable().futureCall(request);
   // Do something.
   for (Reaction element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListReactionsRequest,ListReactionsPagedResponse>

listSpaces()

public final ChatServiceClient.ListSpacesPagedResponse listSpaces()

Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see List spaces.

Requires authentication. Supports app authentication and user authentication.

Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   for (Space element : chatServiceClient.listSpaces().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
ChatServiceClient.ListSpacesPagedResponse

listSpaces(ListSpacesRequest request)

public final ChatServiceClient.ListSpacesPagedResponse listSpaces(ListSpacesRequest request)

Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see List spaces.

Requires authentication. Supports app authentication and user authentication.

Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListSpacesRequest request =
       ListSpacesRequest.newBuilder()
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (Space element : chatServiceClient.listSpaces(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListSpacesRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ChatServiceClient.ListSpacesPagedResponse

listSpacesCallable()

public final UnaryCallable<ListSpacesRequest,ListSpacesResponse> listSpacesCallable()

Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see List spaces.

Requires authentication. Supports app authentication and user authentication.

Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListSpacesRequest request =
       ListSpacesRequest.newBuilder()
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListSpacesResponse response = chatServiceClient.listSpacesCallable().call(request);
     for (Space element : response.getSpacesList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListSpacesRequest,ListSpacesResponse>

listSpacesPagedCallable()

public final UnaryCallable<ListSpacesRequest,ChatServiceClient.ListSpacesPagedResponse> listSpacesPagedCallable()

Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see List spaces.

Requires authentication. Supports app authentication and user authentication.

Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   ListSpacesRequest request =
       ListSpacesRequest.newBuilder()
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<Space> future = chatServiceClient.listSpacesPagedCallable().futureCall(request);
   // Do something.
   for (Space element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListSpacesRequest,ListSpacesPagedResponse>

setUpSpace(SetUpSpaceRequest request)

public final Space setUpSpace(SetUpSpaceRequest request)

Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified as a membership in the request. For an example, see Set up a space with initial members.

To specify the human members to add, add memberships with the appropriate member.name in the SetUpSpaceRequest. To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

For a space or group chat, if the caller blocks or is blocked by some members, then those members aren't added to the created space.

To create a direct message (DM) between the calling user and another human user, specify exactly one membership to represent the human user. If one user blocks the other, the request fails and the DM isn't created.

To create a DM between the calling user and the calling app, set Space.singleUserBotDm to true and don't specify any memberships. You can only use this method to set up a DM with the calling app. To add the calling app as a member of a space or an existing DM between two human users, see Invite or add a user or app to a space.

If a DM already exists between two users, even when one user blocks the other at the time a request is made, then the existing DM is returned.

Spaces with threaded replies aren't supported. If you receive the error message ALREADY_EXISTS when setting up a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SetUpSpaceRequest request =
       SetUpSpaceRequest.newBuilder()
           .setSpace(Space.newBuilder().build())
           .setRequestId("requestId693933066")
           .addAllMemberships(new ArrayList<Membership>())
           .build();
   Space response = chatServiceClient.setUpSpace(request);
 }
 
Parameter
Name Description
request SetUpSpaceRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Space

setUpSpaceCallable()

public final UnaryCallable<SetUpSpaceRequest,Space> setUpSpaceCallable()

Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified as a membership in the request. For an example, see Set up a space with initial members.

To specify the human members to add, add memberships with the appropriate member.name in the SetUpSpaceRequest. To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

For a space or group chat, if the caller blocks or is blocked by some members, then those members aren't added to the created space.

To create a direct message (DM) between the calling user and another human user, specify exactly one membership to represent the human user. If one user blocks the other, the request fails and the DM isn't created.

To create a DM between the calling user and the calling app, set Space.singleUserBotDm to true and don't specify any memberships. You can only use this method to set up a DM with the calling app. To add the calling app as a member of a space or an existing DM between two human users, see Invite or add a user or app to a space.

If a DM already exists between two users, even when one user blocks the other at the time a request is made, then the existing DM is returned.

Spaces with threaded replies aren't supported. If you receive the error message ALREADY_EXISTS when setting up a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SetUpSpaceRequest request =
       SetUpSpaceRequest.newBuilder()
           .setSpace(Space.newBuilder().build())
           .setRequestId("requestId693933066")
           .addAllMemberships(new ArrayList<Membership>())
           .build();
   ApiFuture<Space> future = chatServiceClient.setUpSpaceCallable().futureCall(request);
   // Do something.
   Space response = future.get();
 }
 
Returns
Type Description
UnaryCallable<SetUpSpaceRequest,Space>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

updateMembership(Membership membership, FieldMask updateMask)

public final Membership updateMembership(Membership membership, FieldMask updateMask)

Updates a membership. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   Membership membership = Membership.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Membership response = chatServiceClient.updateMembership(membership, updateMask);
 }
 
Parameters
Name Description
membership Membership

Required. The membership to update. Only fields specified by update_mask are updated.

updateMask FieldMask

Required. The field paths to update. Separate multiple values with commas or use * to update all field paths.

Currently supported field paths:

- role

Returns
Type Description
Membership

updateMembership(UpdateMembershipRequest request)

public final Membership updateMembership(UpdateMembershipRequest request)

Updates a membership. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateMembershipRequest request =
       UpdateMembershipRequest.newBuilder()
           .setMembership(Membership.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Membership response = chatServiceClient.updateMembership(request);
 }
 
Parameter
Name Description
request UpdateMembershipRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Membership

updateMembershipCallable()

public final UnaryCallable<UpdateMembershipRequest,Membership> updateMembershipCallable()

Updates a membership. Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateMembershipRequest request =
       UpdateMembershipRequest.newBuilder()
           .setMembership(Membership.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Membership> future =
       chatServiceClient.updateMembershipCallable().futureCall(request);
   // Do something.
   Membership response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateMembershipRequest,Membership>

updateMessage(Message message, FieldMask updateMask)

public final Message updateMessage(Message message, FieldMask updateMask)

Updates a message. There's a difference between the patch and update methods. The patch method uses a patch request while the update method uses a put request. We recommend using the patch method. For an example, see Update a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   Message message = Message.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Message response = chatServiceClient.updateMessage(message, updateMask);
 }
 
Parameters
Name Description
message Message

Required. Message with fields updated.

updateMask FieldMask

Required. The field paths to update. Separate multiple values with commas or use * to update all field paths.

Currently supported field paths:

- text

- attachment

- cards (Requires app authentication.)

- cards_v2 (Requires app authentication.)

- accessory_widgets (Requires app authentication.)

Returns
Type Description
Message

updateMessage(UpdateMessageRequest request)

public final Message updateMessage(UpdateMessageRequest request)

Updates a message. There's a difference between the patch and update methods. The patch method uses a patch request while the update method uses a put request. We recommend using the patch method. For an example, see Update a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateMessageRequest request =
       UpdateMessageRequest.newBuilder()
           .setMessage(Message.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setAllowMissing(true)
           .build();
   Message response = chatServiceClient.updateMessage(request);
 }
 
Parameter
Name Description
request UpdateMessageRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Message

updateMessageCallable()

public final UnaryCallable<UpdateMessageRequest,Message> updateMessageCallable()

Updates a message. There's a difference between the patch and update methods. The patch method uses a patch request while the update method uses a put request. We recommend using the patch method. For an example, see Update a message.

Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateMessageRequest request =
       UpdateMessageRequest.newBuilder()
           .setMessage(Message.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .setAllowMissing(true)
           .build();
   ApiFuture<Message> future = chatServiceClient.updateMessageCallable().futureCall(request);
   // Do something.
   Message response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateMessageRequest,Message>

updateSpace(Space space, FieldMask updateMask)

public final Space updateSpace(Space space, FieldMask updateMask)

Updates a space. For an example, see Update a space.

If you're updating the displayName field and receive the error message ALREADY_EXISTS, try a different display name.. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   Space space = Space.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Space response = chatServiceClient.updateSpace(space, updateMask);
 }
 
Parameters
Name Description
space Space

Required. Space with fields to be updated. Space.name must be populated in the form of spaces/{space}. Only fields specified by update_mask are updated.

updateMask FieldMask

Required. The updated field paths, comma separated if there are multiple.

Currently supported field paths:

- display_name (Only supports changing the display name of a space with the SPACE type, or when also including the space_type mask to change a GROUP_CHAT space type to SPACE. Trying to update the display name of a GROUP_CHAT or a DIRECT_MESSAGE space results in an invalid argument error. If you receive the error message ALREADY_EXISTS when updating the displayName, try a different displayName. An existing space within the Google Workspace organization might already use this display name.)

- space_type (Only supports changing a GROUP_CHAT space type to SPACE. Include display_name together with space_type in the update mask and ensure that the specified space has a non-empty display name and the SPACE space type. Including the space_type mask and the SPACE type in the specified space when updating the display name is optional if the existing space already has the SPACE type. Trying to update the space type in other ways results in an invalid argument error).

- space_details

- space_history_state (Supports turning history on or off for the space if the organization allows users to change their history setting. Warning: mutually exclusive with all other field paths.)

- Developer Preview: access_settings.audience (Supports changing the access setting of a space. If no audience is specified in the access setting, the space's access setting is updated to restricted. Warning: mutually exclusive with all other field paths.)

Returns
Type Description
Space

updateSpace(UpdateSpaceRequest request)

public final Space updateSpace(UpdateSpaceRequest request)

Updates a space. For an example, see Update a space.

If you're updating the displayName field and receive the error message ALREADY_EXISTS, try a different display name.. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateSpaceRequest request =
       UpdateSpaceRequest.newBuilder()
           .setSpace(Space.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Space response = chatServiceClient.updateSpace(request);
 }
 
Parameter
Name Description
request UpdateSpaceRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Space

updateSpaceCallable()

public final UnaryCallable<UpdateSpaceRequest,Space> updateSpaceCallable()

Updates a space. For an example, see Update a space.

If you're updating the displayName field and receive the error message ALREADY_EXISTS, try a different display name.. An existing space within the Google Workspace organization might already use this display name.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateSpaceRequest request =
       UpdateSpaceRequest.newBuilder()
           .setSpace(Space.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Space> future = chatServiceClient.updateSpaceCallable().futureCall(request);
   // Do something.
   Space response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateSpaceRequest,Space>

updateSpaceReadState(SpaceReadState spaceReadState, FieldMask updateMask)

public final SpaceReadState updateSpaceReadState(SpaceReadState spaceReadState, FieldMask updateMask)

Updates a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   SpaceReadState spaceReadState = SpaceReadState.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   SpaceReadState response = chatServiceClient.updateSpaceReadState(spaceReadState, updateMask);
 }
 
Parameters
Name Description
spaceReadState SpaceReadState

Required. The space read state and fields to update.

Only supports updating read state for the calling user.

To refer to the calling user, set one of the following:

- The me alias. For example, users/me/spaces/{space}/spaceReadState.

- Their Workspace email address. For example, users/user@example.com/spaces/{space}/spaceReadState.

- Their user id. For example, users/123456789/spaces/{space}/spaceReadState.

Format: users/{user}/spaces/{space}/spaceReadState

updateMask FieldMask

Required. The field paths to update. Currently supported field paths:

- last_read_time

When the last_read_time is before the latest message create time, the space appears as unread in the UI.

To mark the space as read, set last_read_time to any value later (larger) than the latest message create time. The last_read_time is coerced to match the latest message create time. Note that the space read state only affects the read state of messages that are visible in the space's top-level conversation. Replies in threads are unaffected by this timestamp, and instead rely on the thread read state.

Returns
Type Description
SpaceReadState

updateSpaceReadState(UpdateSpaceReadStateRequest request)

public final SpaceReadState updateSpaceReadState(UpdateSpaceReadStateRequest request)

Updates a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateSpaceReadStateRequest request =
       UpdateSpaceReadStateRequest.newBuilder()
           .setSpaceReadState(SpaceReadState.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   SpaceReadState response = chatServiceClient.updateSpaceReadState(request);
 }
 
Parameter
Name Description
request UpdateSpaceReadStateRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
SpaceReadState

updateSpaceReadStateCallable()

public final UnaryCallable<UpdateSpaceReadStateRequest,SpaceReadState> updateSpaceReadStateCallable()

Updates a user's read state within a space, used to identify read and unread messages.

Requires user authentication.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UpdateSpaceReadStateRequest request =
       UpdateSpaceReadStateRequest.newBuilder()
           .setSpaceReadState(SpaceReadState.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<SpaceReadState> future =
       chatServiceClient.updateSpaceReadStateCallable().futureCall(request);
   // Do something.
   SpaceReadState response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateSpaceReadStateRequest,SpaceReadState>

uploadAttachment(UploadAttachmentRequest request)

public final UploadAttachmentResponse uploadAttachment(UploadAttachmentRequest request)

Uploads an attachment. For an example, see Upload media as a file attachment. Requires user authentication.

You can upload attachments up to 200 MB. Certain file types aren't supported. For details, see File types blocked by Google Chat.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UploadAttachmentRequest request =
       UploadAttachmentRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setFilename("filename-734768633")
           .build();
   UploadAttachmentResponse response = chatServiceClient.uploadAttachment(request);
 }
 
Parameter
Name Description
request UploadAttachmentRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
UploadAttachmentResponse

uploadAttachmentCallable()

public final UnaryCallable<UploadAttachmentRequest,UploadAttachmentResponse> uploadAttachmentCallable()

Uploads an attachment. For an example, see Upload media as a file attachment. Requires user authentication.

You can upload attachments up to 200 MB. Certain file types aren't supported. For details, see File types blocked by Google Chat.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
   UploadAttachmentRequest request =
       UploadAttachmentRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setFilename("filename-734768633")
           .build();
   ApiFuture<UploadAttachmentResponse> future =
       chatServiceClient.uploadAttachmentCallable().futureCall(request);
   // Do something.
   UploadAttachmentResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UploadAttachmentRequest,UploadAttachmentResponse>