Class ChatServiceClient (0.19.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.

The create() method requires either user authentication or app authentication. Chat attributes the message sender differently depending on the type of authentication that you use in your request.

The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text), cards (cardsV2), and accessory widgets (accessoryWidgets).

!Message sent with app authentication

The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text).

!Message sent with user authentication

The maximum message size, including the message contents, is 32,000 bytes.

For webhook requests, the response doesn't contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

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. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. 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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- User authentication

To list all named spaces by Google Workspace organization, use the spaces.search() method using Workspace administrator privileges instead.

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()

SearchSpaces

Returns a list of spaces in a Google Workspace organization based on an administrator's search.

Requires user authentication with administrator privileges. In the request, set use_admin_access to true.

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

  • searchSpaces(SearchSpacesRequest request)

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

  • searchSpaces()

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

  • searchSpacesPagedCallable()

  • searchSpacesCallable()

GetSpace

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

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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 space with no members. Can be used to create a named space, or a group chat in Import mode. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication

When authenticating as an app, the space.customer field must be set in the request.

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 membership.member.name. 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.

To specify the Google groups to add, add memberships with the appropriate membership.group_member.name. To add or invite a Google group, use groups/{group}, where {group} is the id for the group from the Cloud Identity Groups API. For example, you can use Cloud Identity Groups lookup API to retrieve the ID 123456789 for group email group@example.com, then you can add the group to the space by setting the membership.group_member.name to groups/123456789. Group email is not supported, and Google groups can only be added as members in named spaces.

For a named space or group chat, if the caller blocks, or is blocked by some members, or doesn't have permission to add 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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 app authentication, returns the direct message space between the specified user and the calling Chat app.

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

// Supports the following types of authentication:

- App authentication

- User 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 membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

For example usage, see:

- Invite or add a user to a space.

- Invite or add a Google Group to a space.

- Add the Chat app to a space.

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. For an example, see Update a user's membership in a space.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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. For an example, see Get details about a user's space read state.

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. For an example, see Update a user's space read state.

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. For an example, see Get details about a user's thread read state.

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()

GetSpaceEvent

Returns an event from a Google Chat space. The event payload contains the most recent version of the resource that changed. For example, if you request an event about a new message but the message was later updated, the server returns the updated Message resource in the event payload.

Note: The permissionSettings field is not returned in the Space object of the Space event data for this request.

Requires user authentication. To get an event, the authenticated user must be a member of the space.

For an example, see Get details about an event from a Google Chat space.

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

  • getSpaceEvent(GetSpaceEventRequest request)

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

  • getSpaceEvent(SpaceEventName name)

  • getSpaceEvent(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.

  • getSpaceEventCallable()

ListSpaceEvents

Lists events from a Google Chat space. For each event, the payload contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires user authentication. To list events, the authenticated user must be a member of the space.

For an example, see List events from a Google Chat space.

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

  • listSpaceEvents(ListSpaceEventsRequest request)

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

  • listSpaceEvents(SpaceName parent, String filter)

  • listSpaceEvents(String parent, String filter)

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

  • listSpaceEventsPagedCallable()

  • listSpaceEventsCallable()

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 membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

For example usage, see:

- Invite or add a user to a space.

- Invite or add a Google Group to a space.

- Add the Chat app to a 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()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setMembership(Membership.newBuilder().build())
           .setUseAdminAccess(true)
           .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 membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

For example usage, see:

- Invite or add a user to a space.

- Invite or add a Google Group to a space.

- Add the Chat app to a 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 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 certain authorization scopes and set specific values for certain fields:

- When authenticating as a user, the chat.memberships authorization scope is required.

- When authenticating as an app, the chat.app.memberships authorization scope is required. Authenticating as an app is available in Developer Preview.

- 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.

Inviting users external to the Workspace organization that owns the space requires user authentication.

When a Chat app creates a membership relation for itself, it must authenticate as a user and 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 membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

For example usage, see:

- Invite or add a user to a space.

- Invite or add a Google Group to a space.

- Add the Chat app to a 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 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 certain authorization scopes and set specific values for certain fields:

- When authenticating as a user, the chat.memberships authorization scope is required.

- When authenticating as an app, the chat.app.memberships authorization scope is required. Authenticating as an app is available in Developer Preview.

- 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.

Inviting users external to the Workspace organization that owns the space requires user authentication.

When a Chat app creates a membership relation for itself, it must authenticate as a user and 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 membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

For example usage, see:

- Invite or add a user to a space.

- Invite or add a Google Group to a space.

- Add the Chat app to a 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()) {
   CreateMembershipRequest request =
       CreateMembershipRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setMembership(Membership.newBuilder().build())
           .setUseAdminAccess(true)
           .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.

The create() method requires either user authentication or app authentication. Chat attributes the message sender differently depending on the type of authentication that you use in your request.

The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text), cards (cardsV2), and accessory widgets (accessoryWidgets).

!Message sent with app authentication

The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text).

!Message sent with user authentication

The maximum message size, including the message contents, is 32,000 bytes.

For webhook requests, the response doesn't contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

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.

The create() method requires either user authentication or app authentication. Chat attributes the message sender differently depending on the type of authentication that you use in your request.

The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text), cards (cardsV2), and accessory widgets (accessoryWidgets).

!Message sent with app authentication

The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text).

!Message sent with user authentication

The maximum message size, including the message contents, is 32,000 bytes.

For webhook requests, the response doesn't contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

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.

The create() method requires either user authentication or app authentication. Chat attributes the message sender differently depending on the type of authentication that you use in your request.

The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text), cards (cardsV2), and accessory widgets (accessoryWidgets).

!Message sent with app authentication

The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text).

!Message sent with user authentication

The maximum message size, including the message contents, is 32,000 bytes.

For webhook requests, the response doesn't contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

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.

The create() method requires either user authentication or app authentication. Chat attributes the message sender differently depending on the type of authentication that you use in your request.

The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text), cards (cardsV2), and accessory widgets (accessoryWidgets).

!Message sent with app authentication

The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text).

!Message sent with user authentication

The maximum message size, including the message contents, is 32,000 bytes.

For webhook requests, the response doesn't contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

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 space with no members. Can be used to create a named space, or a group chat in Import mode. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication

When authenticating as an app, the space.customer field must be set in the request.

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 space with no members. Can be used to create a named space, or a group chat in Import mode. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication

When authenticating as an app, the space.customer field must be set in the request.

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 and SpaceType.GROUP_CHAT are supported. SpaceType.GROUP_CHAT can only be used if importMode is set to true.

If you receive the error message ALREADY_EXISTS, 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 space with no members. Can be used to create a named space, or a group chat in Import mode. 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication

When authenticating as an app, the space.customer field must be set in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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 app authentication, returns the direct message space between the specified user and the calling Chat app.

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

// Supports the following types of authentication:

- App authentication

- 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()) {
   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 app authentication, returns the direct message space between the specified user and the calling Chat app.

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

// Supports the following types of authentication:

- App authentication

- 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()) {
   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/{space}/messages/{message}/attachments/{attachment}.

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/{space}/messages/{message}/attachments/{attachment}.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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 by using user authentication, you can optionally use spaces/{space}/members/app.

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

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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 by using user authentication, you can optionally use spaces/{space}/members/app.

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

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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/{space}.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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/{space}.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .build();
   ApiFuture<Space> future = chatServiceClient.getSpaceCallable().futureCall(request);
   // Do something.
   Space response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetSpaceRequest,Space>

getSpaceEvent(GetSpaceEventRequest request)

public final SpaceEvent getSpaceEvent(GetSpaceEventRequest request)

Returns an event from a Google Chat space. The event payload contains the most recent version of the resource that changed. For example, if you request an event about a new message but the message was later updated, the server returns the updated Message resource in the event payload.

Note: The permissionSettings field is not returned in the Space object of the Space event data for this request.

Requires user authentication. To get an event, the authenticated user must be a member of the space.

For an example, see Get details about an event from a Google Chat 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()) {
   GetSpaceEventRequest request =
       GetSpaceEventRequest.newBuilder()
           .setName(SpaceEventName.of("[SPACE]", "[SPACE_EVENT]").toString())
           .build();
   SpaceEvent response = chatServiceClient.getSpaceEvent(request);
 }
 
Parameter
Name Description
request GetSpaceEventRequest

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

Returns
Type Description
SpaceEvent

getSpaceEvent(SpaceEventName name)

public final SpaceEvent getSpaceEvent(SpaceEventName name)

Returns an event from a Google Chat space. The event payload contains the most recent version of the resource that changed. For example, if you request an event about a new message but the message was later updated, the server returns the updated Message resource in the event payload.

Note: The permissionSettings field is not returned in the Space object of the Space event data for this request.

Requires user authentication. To get an event, the authenticated user must be a member of the space.

For an example, see Get details about an event from a Google Chat 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()) {
   SpaceEventName name = SpaceEventName.of("[SPACE]", "[SPACE_EVENT]");
   SpaceEvent response = chatServiceClient.getSpaceEvent(name);
 }
 
Parameter
Name Description
name SpaceEventName

Required. The resource name of the space event.

Format: spaces/{space}/spaceEvents/{spaceEvent}

Returns
Type Description
SpaceEvent

getSpaceEvent(String name)

public final SpaceEvent getSpaceEvent(String name)

Returns an event from a Google Chat space. The event payload contains the most recent version of the resource that changed. For example, if you request an event about a new message but the message was later updated, the server returns the updated Message resource in the event payload.

Note: The permissionSettings field is not returned in the Space object of the Space event data for this request.

Requires user authentication. To get an event, the authenticated user must be a member of the space.

For an example, see Get details about an event from a Google Chat 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 = SpaceEventName.of("[SPACE]", "[SPACE_EVENT]").toString();
   SpaceEvent response = chatServiceClient.getSpaceEvent(name);
 }
 
Parameter
Name Description
name String

Required. The resource name of the space event.

Format: spaces/{space}/spaceEvents/{spaceEvent}

Returns
Type Description
SpaceEvent

getSpaceEventCallable()

public final UnaryCallable<GetSpaceEventRequest,SpaceEvent> getSpaceEventCallable()

Returns an event from a Google Chat space. The event payload contains the most recent version of the resource that changed. For example, if you request an event about a new message but the message was later updated, the server returns the updated Message resource in the event payload.

Note: The permissionSettings field is not returned in the Space object of the Space event data for this request.

Requires user authentication. To get an event, the authenticated user must be a member of the space.

For an example, see Get details about an event from a Google Chat 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()) {
   GetSpaceEventRequest request =
       GetSpaceEventRequest.newBuilder()
           .setName(SpaceEventName.of("[SPACE]", "[SPACE_EVENT]").toString())
           .build();
   ApiFuture<SpaceEvent> future = chatServiceClient.getSpaceEventCallable().futureCall(request);
   // Do something.
   SpaceEvent response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetSpaceEventRequest,SpaceEvent>

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. For an example, see Get details about a user's space read state.

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. For an example, see Get details about a user's space read state.

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. For an example, see Get details about a user's space read state.

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. For an example, see Get details about a user's space read state.

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. For an example, see Get details about a user's thread read state.

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. For an example, see Get details about a user's thread read state.

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. For an example, see Get details about a user's thread read state.

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. For an example, see Get details about a user's thread read state.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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)
           .setUseAdminAccess(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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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)
           .setUseAdminAccess(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.

Supports the following types of authentication:

- App authentication

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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)
           .setUseAdminAccess(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. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. 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. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. 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. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. 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. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. 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. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. 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>

listSpaceEvents(ListSpaceEventsRequest request)

public final ChatServiceClient.ListSpaceEventsPagedResponse listSpaceEvents(ListSpaceEventsRequest request)

Lists events from a Google Chat space. For each event, the payload contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires user authentication. To list events, the authenticated user must be a member of the space.

For an example, see List events from a Google Chat 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()) {
   ListSpaceEventsRequest request =
       ListSpaceEventsRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   for (SpaceEvent element : chatServiceClient.listSpaceEvents(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListSpaceEventsRequest

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

Returns
Type Description
ChatServiceClient.ListSpaceEventsPagedResponse

listSpaceEvents(SpaceName parent, String filter)

public final ChatServiceClient.ListSpaceEventsPagedResponse listSpaceEvents(SpaceName parent, String filter)

Lists events from a Google Chat space. For each event, the payload contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires user authentication. To list events, the authenticated user must be a member of the space.

For an example, see List events from a Google Chat 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 parent = SpaceName.of("[SPACE]");
   String filter = "filter-1274492040";
   for (SpaceEvent element : chatServiceClient.listSpaceEvents(parent, filter).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
Name Description
parent SpaceName

Required. Resource name of the Google Chat space where the events occurred.

Format: spaces/{space}.

filter String

Required. A query filter.

You must specify at least one event type (event_type) using the has : operator. To filter by multiple event types, use the OR operator. Omit batch event types in your filter. The request automatically returns any related batch events. For example, if you filter by new reactions (google.workspace.chat.reaction.v1.created), the server also returns batch new reactions events (google.workspace.chat.reaction.v1.batchCreated). For a list of supported event types, see the SpaceEvents reference documentation.

Optionally, you can also filter by start time (start_time) and end time (end_time):

  • start_time: Exclusive timestamp from which to start listing space events. You can list events that occurred up to 28 days ago. If unspecified, lists space events from the past 28 days.
  • end_time: Inclusive timestamp until which space events are listed. If unspecified, lists events up to the time of the request.

To specify a start or end time, use the equals = operator and format in RFC-3339. To filter by both start_time and end_time, use the AND operator.

For example, the following queries are valid:

`<code> start_time="2023-08-23T19:20:33+00:00" AND end_time="2023-08-23T19:21:54+00:00" </code> <code> start_time="2023-08-23T19:20:33+00:00" AND (event_types:"google.workspace.chat.space.v1.updated" OR event_types:"google.workspace.chat.message.v1.created") </code>

The following queries are invalid:

<code> start_time="2023-08-23T19:20:33+00:00" OR end_time="2023-08-23T19:21:54+00:00" </code> <code> event_types:"google.workspace.chat.space.v1.updated" AND event_types:"google.workspace.chat.message.v1.created" </code>

Invalid queries are rejected by the server with an INVALID_ARGUMENT` error.

Returns
Type Description
ChatServiceClient.ListSpaceEventsPagedResponse

listSpaceEvents(String parent, String filter)

public final ChatServiceClient.ListSpaceEventsPagedResponse listSpaceEvents(String parent, String filter)

Lists events from a Google Chat space. For each event, the payload contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires user authentication. To list events, the authenticated user must be a member of the space.

For an example, see List events from a Google Chat 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 parent = SpaceName.of("[SPACE]").toString();
   String filter = "filter-1274492040";
   for (SpaceEvent element : chatServiceClient.listSpaceEvents(parent, filter).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameters
Name Description
parent String

Required. Resource name of the Google Chat space where the events occurred.

Format: spaces/{space}.

filter String

Required. A query filter.

You must specify at least one event type (event_type) using the has : operator. To filter by multiple event types, use the OR operator. Omit batch event types in your filter. The request automatically returns any related batch events. For example, if you filter by new reactions (google.workspace.chat.reaction.v1.created), the server also returns batch new reactions events (google.workspace.chat.reaction.v1.batchCreated). For a list of supported event types, see the SpaceEvents reference documentation.

Optionally, you can also filter by start time (start_time) and end time (end_time):

  • start_time: Exclusive timestamp from which to start listing space events. You can list events that occurred up to 28 days ago. If unspecified, lists space events from the past 28 days.
  • end_time: Inclusive timestamp until which space events are listed. If unspecified, lists events up to the time of the request.

To specify a start or end time, use the equals = operator and format in RFC-3339. To filter by both start_time and end_time, use the AND operator.

For example, the following queries are valid:

`<code> start_time="2023-08-23T19:20:33+00:00" AND end_time="2023-08-23T19:21:54+00:00" </code> <code> start_time="2023-08-23T19:20:33+00:00" AND (event_types:"google.workspace.chat.space.v1.updated" OR event_types:"google.workspace.chat.message.v1.created") </code>

The following queries are invalid:

<code> start_time="2023-08-23T19:20:33+00:00" OR end_time="2023-08-23T19:21:54+00:00" </code> <code> event_types:"google.workspace.chat.space.v1.updated" AND event_types:"google.workspace.chat.message.v1.created" </code>

Invalid queries are rejected by the server with an INVALID_ARGUMENT` error.

Returns
Type Description
ChatServiceClient.ListSpaceEventsPagedResponse

listSpaceEventsCallable()

public final UnaryCallable<ListSpaceEventsRequest,ListSpaceEventsResponse> listSpaceEventsCallable()

Lists events from a Google Chat space. For each event, the payload contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires user authentication. To list events, the authenticated user must be a member of the space.

For an example, see List events from a Google Chat 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()) {
   ListSpaceEventsRequest request =
       ListSpaceEventsRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   while (true) {
     ListSpaceEventsResponse response =
         chatServiceClient.listSpaceEventsCallable().call(request);
     for (SpaceEvent element : response.getSpaceEventsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListSpaceEventsRequest,ListSpaceEventsResponse>

listSpaceEventsPagedCallable()

public final UnaryCallable<ListSpaceEventsRequest,ChatServiceClient.ListSpaceEventsPagedResponse> listSpaceEventsPagedCallable()

Lists events from a Google Chat space. For each event, the payload contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires user authentication. To list events, the authenticated user must be a member of the space.

For an example, see List events from a Google Chat 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()) {
   ListSpaceEventsRequest request =
       ListSpaceEventsRequest.newBuilder()
           .setParent(SpaceName.of("[SPACE]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setFilter("filter-1274492040")
           .build();
   ApiFuture<SpaceEvent> future =
       chatServiceClient.listSpaceEventsPagedCallable().futureCall(request);
   // Do something.
   for (SpaceEvent element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListSpaceEventsRequest,ListSpaceEventsPagedResponse>

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.

Supports the following types of authentication:

- App authentication

- User authentication

To list all named spaces by Google Workspace organization, use the spaces.search() method using Workspace administrator privileges instead.

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.

Supports the following types of authentication:

- App authentication

- User authentication

To list all named spaces by Google Workspace organization, use the spaces.search() method using Workspace administrator privileges instead.

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.

Supports the following types of authentication:

- App authentication

- User authentication

To list all named spaces by Google Workspace organization, use the spaces.search() method using Workspace administrator privileges instead.

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.

Supports the following types of authentication:

- App authentication

- User authentication

To list all named spaces by Google Workspace organization, use the spaces.search() method using Workspace administrator privileges instead.

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>

searchSpaces()

public final ChatServiceClient.SearchSpacesPagedResponse searchSpaces()

Returns a list of spaces in a Google Workspace organization based on an administrator's search.

Requires user authentication with administrator privileges. In the request, set use_admin_access to true.

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.searchSpaces().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
ChatServiceClient.SearchSpacesPagedResponse

searchSpaces(SearchSpacesRequest request)

public final ChatServiceClient.SearchSpacesPagedResponse searchSpaces(SearchSpacesRequest request)

Returns a list of spaces in a Google Workspace organization based on an administrator's search.

Requires user authentication with administrator privileges. In the request, set use_admin_access to true.

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()) {
   SearchSpacesRequest request =
       SearchSpacesRequest.newBuilder()
           .setUseAdminAccess(true)
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setQuery("query107944136")
           .setOrderBy("orderBy-1207110587")
           .build();
   for (Space element : chatServiceClient.searchSpaces(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request SearchSpacesRequest

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

Returns
Type Description
ChatServiceClient.SearchSpacesPagedResponse

searchSpacesCallable()

public final UnaryCallable<SearchSpacesRequest,SearchSpacesResponse> searchSpacesCallable()

Returns a list of spaces in a Google Workspace organization based on an administrator's search.

Requires user authentication with administrator privileges. In the request, set use_admin_access to true.

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()) {
   SearchSpacesRequest request =
       SearchSpacesRequest.newBuilder()
           .setUseAdminAccess(true)
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setQuery("query107944136")
           .setOrderBy("orderBy-1207110587")
           .build();
   while (true) {
     SearchSpacesResponse response = chatServiceClient.searchSpacesCallable().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<SearchSpacesRequest,SearchSpacesResponse>

searchSpacesPagedCallable()

public final UnaryCallable<SearchSpacesRequest,ChatServiceClient.SearchSpacesPagedResponse> searchSpacesPagedCallable()

Returns a list of spaces in a Google Workspace organization based on an administrator's search.

Requires user authentication with administrator privileges. In the request, set use_admin_access to true.

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()) {
   SearchSpacesRequest request =
       SearchSpacesRequest.newBuilder()
           .setUseAdminAccess(true)
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setQuery("query107944136")
           .setOrderBy("orderBy-1207110587")
           .build();
   ApiFuture<Space> future = chatServiceClient.searchSpacesPagedCallable().futureCall(request);
   // Do something.
   for (Space element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<SearchSpacesRequest,SearchSpacesPagedResponse>

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 membership.member.name. 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.

To specify the Google groups to add, add memberships with the appropriate membership.group_member.name. To add or invite a Google group, use groups/{group}, where {group} is the id for the group from the Cloud Identity Groups API. For example, you can use Cloud Identity Groups lookup API to retrieve the ID 123456789 for group email group@example.com, then you can add the group to the space by setting the membership.group_member.name to groups/123456789. Group email is not supported, and Google groups can only be added as members in named spaces.

For a named space or group chat, if the caller blocks, or is blocked by some members, or doesn't have permission to add 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 membership.member.name. 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.

To specify the Google groups to add, add memberships with the appropriate membership.group_member.name. To add or invite a Google group, use groups/{group}, where {group} is the id for the group from the Cloud Identity Groups API. For example, you can use Cloud Identity Groups lookup API to retrieve the ID 123456789 for group email group@example.com, then you can add the group to the space by setting the membership.group_member.name to groups/123456789. Group email is not supported, and Google groups can only be added as members in named spaces.

For a named space or group chat, if the caller blocks, or is blocked by some members, or doesn't have permission to add 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. For an example, see Update a user's membership in a space.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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. For an example, see Update a user's membership in a space.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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. For an example, see Update a user's membership in a space.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication

- 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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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.

You can update the following fields for a space:

space_details: Updates the space's description. Supports up to 150 characters.

display_name: Only supports updating the display name for spaces where spaceType field is SPACE. If you receive the error message ALREADY_EXISTS, try a different value. 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_type is not supported with useAdminAccess.

space_history_state: Updates space history settings by turning history on or off for the space. Only supported if history settings are enabled for the Google Workspace organization. To update the space history state, you must omit all other field masks in your request. space_history_state is not supported with useAdminAccess.

access_settings.audience: Updates the access setting of who can discover the space, join the space, and preview the messages in named space where spaceType field is SPACE. If the existing space has a target audience, you can remove the audience and restrict space access by omitting a value for this field mask. To update access settings for a space, the authenticating user must be a space manager and omit all other field masks in your request. You can't update this field if the space is in import mode. To learn more, see Make a space discoverable to specific users. access_settings.audience is not supported with useAdminAccess.

permission_settings: Supports changing the permission settings of a space. When updating permission settings, you can only specify permissionSettings field masks; you cannot update other field masks at the same time. permissionSettings is not supported with useAdminAccess. The supported field masks include:

- permission_settings.manageMembersAndGroups - permission_settings.modifySpaceDetails - permission_settings.toggleHistory - permission_settings.useAtMentionAll - permission_settings.manageApps - permission_settings.manageWebhooks - permission_settings.replyMessages

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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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.

Supports the following types of authentication:

- App authentication with administrator approval in Developer Preview

- User authentication You can authenticate and authorize this method with administrator privileges by setting the use_admin_access field in the request.

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())
           .setUseAdminAccess(true)
           .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. For an example, see Update a user's space read state.

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. For an example, see Update a user's space read state.

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. For an example, see Update a user's space read state.

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>