GitHub Repository | Product Reference | REST 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().
Method | Description | Method Variants |
---|---|---|
CreateMessage |
Creates a message in a Google Chat space. The maximum message size, including text and cards, is 32,000 bytes. For an example, see Send a message. Calling this method requires authentication and supports the following authentication types: - For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.) |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListMessages |
Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListMemberships |
Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to. Requires authentication. Supports app authentication and user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetMembership |
Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership. Requires authentication. Supports app authentication and user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetMessage |
Returns details about a message. For an example, see Get details about a message. Requires authentication. Supports app authentication and user authentication. Note: Might return a message from a blocked member or space. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateMessage |
Updates a message. There's a difference between the Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteMessage |
Deletes a message. For an example, see Delete a message. Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
ListSpaces |
Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see List spaces. Requires authentication. Supports app authentication and user authentication. Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent. To list all named spaces by Google Workspace organization, use the |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetSpace |
Returns details about a space. For an example, see Get details about a space. Requires authentication. Supports app authentication and user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateSpace |
Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space. If you receive the error message Requires user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 To specify the Google groups to add, add memberships with the appropriate 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 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 Requires user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateSpace |
Updates a space. For an example, see Update a space. If you're updating the Requires user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteSpace |
Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
FindDirectMessage |
Returns the existing direct message with the specified user. If no direct message space is found, returns a With user authentication, returns the direct message space between the specified user and the authenticated user. With app authentication, returns the direct message space between the specified user and the calling Chat app. Requires user authentication or app authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
CreateMembership |
Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication. To specify the member to add, set the - To add the calling app to a space or a direct message between two human users, use - To add a human user, use - To add or invite a Google group in a named space, use |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateMembership |
Updates a membership. For an example, see Update a user's membership in a space. Requires user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
DeleteMembership |
Deletes a membership. For an example, see Remove a user or a Google Chat app from a space. Requires user authentication. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 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.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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.
Static Methods
create()
public static final ChatServiceClient create()
Constructs an instance of ChatServiceClient with default settings.
Returns | |
---|---|
Type | Description |
ChatServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(ChatServiceSettings settings)
public static final ChatServiceClient create(ChatServiceSettings settings)
Constructs an instance of ChatServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Parameter | |
---|---|
Name | Description |
settings |
ChatServiceSettings |
Returns | |
---|---|
Type | Description |
ChatServiceClient |
Exceptions | |
---|---|
Type | Description |
IOException |
create(ChatServiceStub stub)
public static final ChatServiceClient create(ChatServiceStub stub)
Constructs an instance of ChatServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(ChatServiceSettings).
Parameter | |
---|---|
Name | Description |
stub |
ChatServiceStub |
Returns | |
---|---|
Type | Description |
ChatServiceClient |
Constructors
ChatServiceClient(ChatServiceSettings settings)
protected ChatServiceClient(ChatServiceSettings settings)
Constructs an instance of ChatServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Parameter | |
---|---|
Name | Description |
settings |
ChatServiceSettings |
ChatServiceClient(ChatServiceStub stub)
protected ChatServiceClient(ChatServiceStub stub)
Parameter | |
---|---|
Name | Description |
stub |
ChatServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Parameters | |
---|---|
Name | Description |
duration |
long |
unit |
TimeUnit |
Returns | |
---|---|
Type | Description |
boolean |
Exceptions | |
---|---|
Type | Description |
InterruptedException |
close()
public final void close()
completeImportSpace(CompleteImportSpaceRequest request)
public final CompleteImportSpaceResponse completeImportSpace(CompleteImportSpaceRequest request)
Completes the import process for the specified space and makes it visible to users. Requires app authentication and domain-wide delegation. For more information, see Authorize Google Chat apps to import data.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CompleteImportSpaceRequest request =
CompleteImportSpaceRequest.newBuilder()
.setName(SpaceName.of("[SPACE]").toString())
.build();
CompleteImportSpaceResponse response = chatServiceClient.completeImportSpace(request);
}
Parameter | |
---|---|
Name | Description |
request |
CompleteImportSpaceRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
CompleteImportSpaceResponse |
completeImportSpaceCallable()
public final UnaryCallable<CompleteImportSpaceRequest,CompleteImportSpaceResponse> completeImportSpaceCallable()
Completes the import process for the specified space and makes it visible to users. Requires app authentication and domain-wide delegation. For more information, see Authorize Google Chat apps to import data.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CompleteImportSpaceRequest request =
CompleteImportSpaceRequest.newBuilder()
.setName(SpaceName.of("[SPACE]").toString())
.build();
ApiFuture<CompleteImportSpaceResponse> future =
chatServiceClient.completeImportSpaceCallable().futureCall(request);
// Do something.
CompleteImportSpaceResponse response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CompleteImportSpaceRequest,CompleteImportSpaceResponse> |
createMembership(CreateMembershipRequest request)
public final Membership createMembership(CreateMembershipRequest request)
Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.
To specify the member to add, set the membership.member.name
for the human or app member,
or set the membership.group_member.name
for the group member.
- To add the calling app to a space or a direct message between two human users, use
users/app
. Unable to add other apps to the space.
- To add a human user, use users/{user}
, where {user}
can be the email address for the
user. For users in the same Workspace organization {user}
can also be the id
for the person
from the People API, or the id
for the user in the Directory API. For example, if the People
API Person profile ID for user@example.com
is 123456789
, you can add the user to
the space by setting the membership.member.name
to users/user@example.com
or
users/123456789
.
- To add or invite a Google group in a named space, 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 or invite the
group to a named 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.
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 human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.
To specify the member to add, set the membership.member.name
for the human or app member,
or set the membership.group_member.name
for the group member.
- To add the calling app to a space or a direct message between two human users, use
users/app
. Unable to add other apps to the space.
- To add a human user, use users/{user}
, where {user}
can be the email address for the
user. For users in the same Workspace organization {user}
can also be the id
for the person
from the People API, or the id
for the user in the Directory API. For example, if the People
API Person profile ID for user@example.com
is 123456789
, you can add the user to
the space by setting the membership.member.name
to users/user@example.com
or
users/123456789
.
- To add or invite a Google group in a named space, 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 or invite the
group to a named 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.
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 |
Returns | |
---|---|
Type | Description |
Membership |
createMembership(String parent, Membership membership)
public final Membership createMembership(String parent, Membership membership)
Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.
To specify the member to add, set the membership.member.name
for the human or app member,
or set the membership.group_member.name
for the group member.
- To add the calling app to a space or a direct message between two human users, use
users/app
. Unable to add other apps to the space.
- To add a human user, use users/{user}
, where {user}
can be the email address for the
user. For users in the same Workspace organization {user}
can also be the id
for the person
from the People API, or the id
for the user in the Directory API. For example, if the People
API Person profile ID for user@example.com
is 123456789
, you can add the user to
the space by setting the membership.member.name
to users/user@example.com
or
users/123456789
.
- To add or invite a Google group in a named space, 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 or invite the
group to a named 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.
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 |
Returns | |
---|---|
Type | Description |
Membership |
createMembershipCallable()
public final UnaryCallable<CreateMembershipRequest,Membership> createMembershipCallable()
Creates a human membership or app membership for the calling app. Creating memberships for other apps isn't supported. For an example, see Invite or add a user or a Google Chat app to a space. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.
To specify the member to add, set the membership.member.name
for the human or app member,
or set the membership.group_member.name
for the group member.
- To add the calling app to a space or a direct message between two human users, use
users/app
. Unable to add other apps to the space.
- To add a human user, use users/{user}
, where {user}
can be the email address for the
user. For users in the same Workspace organization {user}
can also be the id
for the person
from the People API, or the id
for the user in the Directory API. For example, if the People
API Person profile ID for user@example.com
is 123456789
, you can add the user to
the space by setting the membership.member.name
to users/user@example.com
or
users/123456789
.
- To add or invite a Google group in a named space, 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 or invite the
group to a named 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.
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. The maximum message size, including text and cards, is 32,000 bytes. For an example, see Send a message.
Calling this method requires authentication and supports the following authentication types:
- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CreateMessageRequest request =
CreateMessageRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setMessage(Message.newBuilder().build())
.setThreadKey("threadKey-1562254347")
.setRequestId("requestId693933066")
.setMessageId("messageId-1440013438")
.build();
Message response = chatServiceClient.createMessage(request);
}
Parameter | |
---|---|
Name | Description |
request |
CreateMessageRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Message |
createMessage(SpaceName parent, Message message, String messageId)
public final Message createMessage(SpaceName parent, Message message, String messageId)
Creates a message in a Google Chat space. The maximum message size, including text and cards, is 32,000 bytes. For an example, see Send a message.
Calling this method requires authentication and supports the following authentication types:
- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
SpaceName parent = SpaceName.of("[SPACE]");
Message message = Message.newBuilder().build();
String messageId = "messageId-1440013438";
Message response = chatServiceClient.createMessage(parent, message, messageId);
}
Parameters | |
---|---|
Name | Description |
parent |
SpaceName Required. The resource name of the space in which to create a message. Format: |
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 The value for this field must meet the following requirements:
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. The maximum message size, including text and cards, is 32,000 bytes. For an example, see Send a message.
Calling this method requires authentication and supports the following authentication types:
- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String parent = SpaceName.of("[SPACE]").toString();
Message message = Message.newBuilder().build();
String messageId = "messageId-1440013438";
Message response = chatServiceClient.createMessage(parent, message, messageId);
}
Parameters | |
---|---|
Name | Description |
parent |
String Required. The resource name of the space in which to create a message. Format: |
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 The value for this field must meet the following requirements:
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. The maximum message size, including text and cards, is 32,000 bytes. For an example, see Send a message.
Calling this method requires authentication and supports the following authentication types:
- For text messages, user authentication or app authentication are supported. - For card messages, only app authentication is supported. (Only Chat apps can create card messages.)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CreateMessageRequest request =
CreateMessageRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setMessage(Message.newBuilder().build())
.setThreadKey("threadKey-1562254347")
.setRequestId("requestId693933066")
.setMessageId("messageId-1440013438")
.build();
ApiFuture<Message> future = chatServiceClient.createMessageCallable().futureCall(request);
// Do something.
Message response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateMessageRequest,Message> |
createReaction(CreateReactionRequest request)
public final Reaction createReaction(CreateReactionRequest request)
Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CreateReactionRequest request =
CreateReactionRequest.newBuilder()
.setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.setReaction(Reaction.newBuilder().build())
.build();
Reaction response = chatServiceClient.createReaction(request);
}
Parameter | |
---|---|
Name | Description |
request |
CreateReactionRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Reaction |
createReaction(MessageName parent, Reaction reaction)
public final Reaction createReaction(MessageName parent, Reaction reaction)
Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
MessageName parent = MessageName.of("[SPACE]", "[MESSAGE]");
Reaction reaction = Reaction.newBuilder().build();
Reaction response = chatServiceClient.createReaction(parent, reaction);
}
Parameters | |
---|---|
Name | Description |
parent |
MessageName Required. The message where the reaction is created. Format: |
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: |
reaction |
Reaction Required. The reaction to create. |
Returns | |
---|---|
Type | Description |
Reaction |
createReactionCallable()
public final UnaryCallable<CreateReactionRequest,Reaction> createReactionCallable()
Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see Add a reaction to a message. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CreateReactionRequest request =
CreateReactionRequest.newBuilder()
.setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.setReaction(Reaction.newBuilder().build())
.build();
ApiFuture<Reaction> future = chatServiceClient.createReactionCallable().futureCall(request);
// Do something.
Reaction response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateReactionRequest,Reaction> |
createSpace(CreateSpaceRequest request)
public final Space createSpace(CreateSpaceRequest request)
Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.
If you receive the error message ALREADY_EXISTS
when creating a space, try a different
displayName
. An existing space within the Google Workspace organization might already use
this display name.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CreateSpaceRequest request =
CreateSpaceRequest.newBuilder()
.setSpace(Space.newBuilder().build())
.setRequestId("requestId693933066")
.build();
Space response = chatServiceClient.createSpace(request);
}
Parameter | |
---|---|
Name | Description |
request |
CreateSpaceRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Space |
createSpace(Space space)
public final Space createSpace(Space space)
Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.
If you receive the error message ALREADY_EXISTS
when creating a space, try a different
displayName
. An existing space within the Google Workspace organization might already use
this display name.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
Space space = Space.newBuilder().build();
Space response = chatServiceClient.createSpace(space);
}
Parameter | |
---|---|
Name | Description |
space |
Space Required. The If you receive the error message The space |
Returns | |
---|---|
Type | Description |
Space |
createSpaceCallable()
public final UnaryCallable<CreateSpaceRequest,Space> createSpaceCallable()
Creates a named space. Spaces grouped by topics aren't supported. For an example, see Create a space.
If you receive the error message ALREADY_EXISTS
when creating a space, try a different
displayName
. An existing space within the Google Workspace organization might already use
this display name.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
CreateSpaceRequest request =
CreateSpaceRequest.newBuilder()
.setSpace(Space.newBuilder().build())
.setRequestId("requestId693933066")
.build();
ApiFuture<Space> future = chatServiceClient.createSpaceCallable().futureCall(request);
// Do something.
Space response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<CreateSpaceRequest,Space> |
deleteMembership(DeleteMembershipRequest request)
public final Membership deleteMembership(DeleteMembershipRequest request)
Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteMembershipRequest request =
DeleteMembershipRequest.newBuilder()
.setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
.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.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
MembershipName name = MembershipName.of("[SPACE]", "[MEMBER]");
Membership response = chatServiceClient.deleteMembership(name);
}
Parameter | |
---|---|
Name | Description |
name |
MembershipName Required. Resource name of the membership to delete. Chat apps can delete human users' or their own memberships. Chat apps can't delete other apps' memberships. When deleting a human membership, requires the When deleting an app membership, requires the Format: |
Returns | |
---|---|
Type | Description |
Membership |
deleteMembership(String name)
public final Membership deleteMembership(String name)
Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String name = MembershipName.of("[SPACE]", "[MEMBER]").toString();
Membership response = chatServiceClient.deleteMembership(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. Resource name of the membership to delete. Chat apps can delete human users' or their own memberships. Chat apps can't delete other apps' memberships. When deleting a human membership, requires the When deleting an app membership, requires the Format: |
Returns | |
---|---|
Type | Description |
Membership |
deleteMembershipCallable()
public final UnaryCallable<DeleteMembershipRequest,Membership> deleteMembershipCallable()
Deletes a membership. For an example, see Remove a user or a Google Chat app from a space.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteMembershipRequest request =
DeleteMembershipRequest.newBuilder()
.setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
.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.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteMessageRequest request =
DeleteMessageRequest.newBuilder()
.setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.setForce(true)
.build();
chatServiceClient.deleteMessage(request);
}
Parameter | |
---|---|
Name | Description |
request |
DeleteMessageRequest The request object containing all of the parameters for the API call. |
deleteMessage(MessageName name)
public final void deleteMessage(MessageName name)
Deletes a message. For an example, see Delete a message.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
MessageName name = MessageName.of("[SPACE]", "[MESSAGE]");
chatServiceClient.deleteMessage(name);
}
Parameter | |
---|---|
Name | Description |
name |
MessageName Required. Resource name of the message. Format: If you've set a custom ID for your message, you can use the value from the
|
deleteMessage(String name)
public final void deleteMessage(String name)
Deletes a message. For an example, see Delete a message.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String name = MessageName.of("[SPACE]", "[MESSAGE]").toString();
chatServiceClient.deleteMessage(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. Resource name of the message. Format: If you've set a custom ID for your message, you can use the value from the
|
deleteMessageCallable()
public final UnaryCallable<DeleteMessageRequest,Empty> deleteMessageCallable()
Deletes a message. For an example, see Delete a message.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only delete messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteMessageRequest request =
DeleteMessageRequest.newBuilder()
.setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.setForce(true)
.build();
ApiFuture<Empty> future = chatServiceClient.deleteMessageCallable().futureCall(request);
// Do something.
future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<DeleteMessageRequest,Empty> |
deleteReaction(DeleteReactionRequest request)
public final void deleteReaction(DeleteReactionRequest request)
Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteReactionRequest request =
DeleteReactionRequest.newBuilder()
.setName(ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]").toString())
.build();
chatServiceClient.deleteReaction(request);
}
Parameter | |
---|---|
Name | Description |
request |
DeleteReactionRequest The request object containing all of the parameters for the API call. |
deleteReaction(ReactionName name)
public final void deleteReaction(ReactionName name)
Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ReactionName name = ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]");
chatServiceClient.deleteReaction(name);
}
Parameter | |
---|---|
Name | Description |
name |
ReactionName Required. Name of the reaction to delete. Format: |
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: |
deleteReactionCallable()
public final UnaryCallable<DeleteReactionRequest,Empty> deleteReactionCallable()
Deletes a reaction to a message. Only unicode emojis are supported. For an example, see Delete a reaction. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteReactionRequest request =
DeleteReactionRequest.newBuilder()
.setName(ReactionName.of("[SPACE]", "[MESSAGE]", "[REACTION]").toString())
.build();
ApiFuture<Empty> future = chatServiceClient.deleteReactionCallable().futureCall(request);
// Do something.
future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<DeleteReactionRequest,Empty> |
deleteSpace(DeleteSpaceRequest request)
public final void deleteSpace(DeleteSpaceRequest request)
Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteSpaceRequest request =
DeleteSpaceRequest.newBuilder()
.setName(SpaceName.of("[SPACE]").toString())
.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. Requires user authentication from a user who has permission to delete the space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
SpaceName name = SpaceName.of("[SPACE]");
chatServiceClient.deleteSpace(name);
}
Parameter | |
---|---|
Name | Description |
name |
SpaceName Required. Resource name of the space to delete. Format: |
deleteSpace(String name)
public final void deleteSpace(String name)
Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String name = SpaceName.of("[SPACE]").toString();
chatServiceClient.deleteSpace(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. Resource name of the space to delete. Format: |
deleteSpaceCallable()
public final UnaryCallable<DeleteSpaceRequest,Empty> deleteSpaceCallable()
Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see Delete a space. Requires user authentication from a user who has permission to delete the space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
DeleteSpaceRequest request =
DeleteSpaceRequest.newBuilder()
.setName(SpaceName.of("[SPACE]").toString())
.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 user authentication, returns the direct message space between the specified user and the authenticated user.
With app authentication, returns the direct message space between the specified user and the calling Chat app.
Requires user authentication or app authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
FindDirectMessageRequest request =
FindDirectMessageRequest.newBuilder().setName("name3373707").build();
Space response = chatServiceClient.findDirectMessage(request);
}
Parameter | |
---|---|
Name | Description |
request |
FindDirectMessageRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Space |
findDirectMessageCallable()
public final UnaryCallable<FindDirectMessageRequest,Space> findDirectMessageCallable()
Returns the existing direct message with the specified user. If no direct message space is
found, returns a 404 NOT_FOUND
error. For an example, see Find a direct
message.
With user authentication, returns the direct message space between the specified user and the authenticated user.
With app authentication, returns the direct message space between the specified user and the calling Chat app.
Requires user authentication or app authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
FindDirectMessageRequest request =
FindDirectMessageRequest.newBuilder().setName("name3373707").build();
ApiFuture<Space> future = chatServiceClient.findDirectMessageCallable().futureCall(request);
// Do something.
Space response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<FindDirectMessageRequest,Space> |
getAttachment(AttachmentName name)
public final Attachment getAttachment(AttachmentName name)
Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
AttachmentName name = AttachmentName.of("[SPACE]", "[MESSAGE]", "[ATTACHMENT]");
Attachment response = chatServiceClient.getAttachment(name);
}
Parameter | |
---|---|
Name | Description |
name |
AttachmentName Required. Resource name of the attachment, in the form
|
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
|
Returns | |
---|---|
Type | Description |
Attachment |
getAttachmentCallable()
public final UnaryCallable<GetAttachmentRequest,Attachment> getAttachmentCallable()
Gets the metadata of a message attachment. The attachment data is fetched using the media API. For an example, see Get metadata about a message attachment. Requires app authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetAttachmentRequest request =
GetAttachmentRequest.newBuilder()
.setName(AttachmentName.of("[SPACE]", "[MESSAGE]", "[ATTACHMENT]").toString())
.build();
ApiFuture<Attachment> future = chatServiceClient.getAttachmentCallable().futureCall(request);
// Do something.
Attachment response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GetAttachmentRequest,Attachment> |
getMembership(GetMembershipRequest request)
public final Membership getMembership(GetMembershipRequest request)
Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetMembershipRequest request =
GetMembershipRequest.newBuilder()
.setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
.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.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
MembershipName name = MembershipName.of("[SPACE]", "[MEMBER]");
Membership response = chatServiceClient.getMembership(name);
}
Parameter | |
---|---|
Name | Description |
name |
MembershipName Required. Resource name of the membership to retrieve. To get the app's own membership by using user
authentication,
you can optionally use Format: When authenticated as a
user, you
can use the user's email as an alias for |
Returns | |
---|---|
Type | Description |
Membership |
getMembership(String name)
public final Membership getMembership(String name)
Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String name = MembershipName.of("[SPACE]", "[MEMBER]").toString();
Membership response = chatServiceClient.getMembership(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. Resource name of the membership to retrieve. To get the app's own membership by using user
authentication,
you can optionally use Format: When authenticated as a
user, you
can use the user's email as an alias for |
Returns | |
---|---|
Type | Description |
Membership |
getMembershipCallable()
public final UnaryCallable<GetMembershipRequest,Membership> getMembershipCallable()
Returns details about a membership. For an example, see Get details about a user's or Google Chat app's membership.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetMembershipRequest request =
GetMembershipRequest.newBuilder()
.setName(MembershipName.of("[SPACE]", "[MEMBER]").toString())
.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.
Requires authentication. Supports app authentication and user authentication.
Note: Might return a message from a blocked member or space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetMessageRequest request =
GetMessageRequest.newBuilder()
.setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.build();
Message response = chatServiceClient.getMessage(request);
}
Parameter | |
---|---|
Name | Description |
request |
GetMessageRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Message |
getMessage(MessageName name)
public final Message getMessage(MessageName name)
Returns details about a message. For an example, see Get details about a message.
Requires authentication. Supports app authentication and user authentication.
Note: Might return a message from a blocked member or space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
MessageName name = MessageName.of("[SPACE]", "[MESSAGE]");
Message response = chatServiceClient.getMessage(name);
}
Parameter | |
---|---|
Name | Description |
name |
MessageName Required. Resource name of the message. Format: If you've set a custom ID for your message, you can use the value from the
|
Returns | |
---|---|
Type | Description |
Message |
getMessage(String name)
public final Message getMessage(String name)
Returns details about a message. For an example, see Get details about a message.
Requires authentication. Supports app authentication and user authentication.
Note: Might return a message from a blocked member or space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String name = MessageName.of("[SPACE]", "[MESSAGE]").toString();
Message response = chatServiceClient.getMessage(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. Resource name of the message. Format: If you've set a custom ID for your message, you can use the value from the
|
Returns | |
---|---|
Type | Description |
Message |
getMessageCallable()
public final UnaryCallable<GetMessageRequest,Message> getMessageCallable()
Returns details about a message. For an example, see Get details about a message.
Requires authentication. Supports app authentication and user authentication.
Note: Might return a message from a blocked member or space.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetMessageRequest request =
GetMessageRequest.newBuilder()
.setName(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.build();
ApiFuture<Message> future = chatServiceClient.getMessageCallable().futureCall(request);
// Do something.
Message response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<GetMessageRequest,Message> |
getSettings()
public final ChatServiceSettings getSettings()
Returns | |
---|---|
Type | Description |
ChatServiceSettings |
getSpace(GetSpaceRequest request)
public final Space getSpace(GetSpaceRequest request)
Returns details about a space. For an example, see Get details about a space.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetSpaceRequest request =
GetSpaceRequest.newBuilder()
.setName(SpaceName.of("[SPACE]").toString())
.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.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
SpaceName name = SpaceName.of("[SPACE]");
Space response = chatServiceClient.getSpace(name);
}
Parameter | |
---|---|
Name | Description |
name |
SpaceName Required. Resource name of the space, in the form Format: |
Returns | |
---|---|
Type | Description |
Space |
getSpace(String name)
public final Space getSpace(String name)
Returns details about a space. For an example, see Get details about a space.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String name = SpaceName.of("[SPACE]").toString();
Space response = chatServiceClient.getSpace(name);
}
Parameter | |
---|---|
Name | Description |
name |
String Required. Resource name of the space, in the form Format: |
Returns | |
---|---|
Type | Description |
Space |
getSpaceCallable()
public final UnaryCallable<GetSpaceRequest,Space> getSpaceCallable()
Returns details about a space. For an example, see Get details about a space.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
GetSpaceRequest request =
GetSpaceRequest.newBuilder()
.setName(SpaceName.of("[SPACE]").toString())
.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.
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.
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: |
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.
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: |
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.
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 - Their Workspace email address. For example,
- Their user id. For example, 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 - Their Workspace email address. For example,
- Their user id. For example, 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 - Their Workspace email address. For example,
- Their user id. For example,
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 - Their Workspace email address. For example,
- Their user id. For example,
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.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListMembershipsRequest request =
ListMembershipsRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setShowGroups(true)
.setShowInvited(true)
.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.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
SpaceName parent = SpaceName.of("[SPACE]");
for (Membership element : chatServiceClient.listMemberships(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
SpaceName Required. The resource name of the space for which to fetch a membership list. Format: spaces/{space} |
Returns | |
---|---|
Type | Description |
ChatServiceClient.ListMembershipsPagedResponse |
listMemberships(String parent)
public final ChatServiceClient.ListMembershipsPagedResponse listMemberships(String parent)
Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String parent = SpaceName.of("[SPACE]").toString();
for (Membership element : chatServiceClient.listMemberships(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
String Required. The resource name of the space for which to fetch a membership list. Format: spaces/{space} |
Returns | |
---|---|
Type | Description |
ChatServiceClient.ListMembershipsPagedResponse |
listMembershipsCallable()
public final UnaryCallable<ListMembershipsRequest,ListMembershipsResponse> listMembershipsCallable()
Lists memberships in a space. For an example, see List users and Google Chat apps in a space. Listing memberships with app authentication lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with User authentication lists memberships in spaces that the authenticated user has access to.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListMembershipsRequest request =
ListMembershipsRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setShowGroups(true)
.setShowInvited(true)
.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.
Requires authentication. Supports app authentication and user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListMembershipsRequest request =
ListMembershipsRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setShowGroups(true)
.setShowInvited(true)
.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. For an example, see List messages. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListMessagesRequest request =
ListMessagesRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setShowDeleted(true)
.build();
for (Message element : chatServiceClient.listMessages(request).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
request |
ListMessagesRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
ChatServiceClient.ListMessagesPagedResponse |
listMessages(SpaceName parent)
public final ChatServiceClient.ListMessagesPagedResponse listMessages(SpaceName parent)
Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
SpaceName parent = SpaceName.of("[SPACE]");
for (Message element : chatServiceClient.listMessages(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
SpaceName Required. The resource name of the space to list messages from. Format: |
Returns | |
---|---|
Type | Description |
ChatServiceClient.ListMessagesPagedResponse |
listMessages(String parent)
public final ChatServiceClient.ListMessagesPagedResponse listMessages(String parent)
Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
String parent = SpaceName.of("[SPACE]").toString();
for (Message element : chatServiceClient.listMessages(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
String Required. The resource name of the space to list messages from. Format: |
Returns | |
---|---|
Type | Description |
ChatServiceClient.ListMessagesPagedResponse |
listMessagesCallable()
public final UnaryCallable<ListMessagesRequest,ListMessagesResponse> listMessagesCallable()
Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListMessagesRequest request =
ListMessagesRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setShowDeleted(true)
.build();
while (true) {
ListMessagesResponse response = chatServiceClient.listMessagesCallable().call(request);
for (Message element : response.getMessagesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListMessagesRequest,ListMessagesResponse> |
listMessagesPagedCallable()
public final UnaryCallable<ListMessagesRequest,ChatServiceClient.ListMessagesPagedResponse> listMessagesPagedCallable()
Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. For an example, see List messages. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListMessagesRequest request =
ListMessagesRequest.newBuilder()
.setParent(SpaceName.of("[SPACE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setOrderBy("orderBy-1207110587")
.setShowDeleted(true)
.build();
ApiFuture<Message> future = chatServiceClient.listMessagesPagedCallable().futureCall(request);
// Do something.
for (Message element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Returns | |
---|---|
Type | Description |
UnaryCallable<ListMessagesRequest,ListMessagesPagedResponse> |
listReactions(ListReactionsRequest request)
public final ChatServiceClient.ListReactionsPagedResponse listReactions(ListReactionsRequest request)
Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
ListReactionsRequest request =
ListReactionsRequest.newBuilder()
.setParent(MessageName.of("[SPACE]", "[MESSAGE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.build();
for (Reaction element : chatServiceClient.listReactions(request).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
request |
ListReactionsRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
ChatServiceClient.ListReactionsPagedResponse |
listReactions(MessageName parent)
public final ChatServiceClient.ListReactionsPagedResponse listReactions(MessageName parent)
Lists reactions to a message. For an example, see List reactions for a message. Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
MessageName parent = MessageName.of("[SPACE]", "[MESSAGE]");
for (Reaction element : chatServiceClient.listReactions(parent).iterateAll()) {
// doThingsWith(element);
}
}
Parameter | |
---|---|
Name | Description |
parent |
MessageName Required. The message users reacted to. Format: |
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: |
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: |
filter |
String Required. A query filter. You must specify at least one event type ( Optionally, you can also filter by start time (
To specify a start or end time, use the equals For example, the following queries are valid:
|
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: |
filter |
String Required. A query filter. You must specify at least one event type ( Optionally, you can also filter by start time (
To specify a start or end time, use the equals For example, the following queries are valid:
|
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.
Requires authentication. Supports app authentication and user authentication.
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.
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.
Requires authentication. Supports app authentication and user authentication.
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.
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.
Requires authentication. Supports app authentication and user authentication.
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.
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.
Requires authentication. Supports app authentication and user authentication.
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent.
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.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
Membership membership = Membership.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Membership response = chatServiceClient.updateMembership(membership, updateMask);
}
Parameters | |
---|---|
Name | Description |
membership |
Membership Required. The membership to update. Only fields specified by |
updateMask |
FieldMask Required. The field paths to update. Separate multiple values with commas or
use Currently supported field paths: - |
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.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
UpdateMembershipRequest request =
UpdateMembershipRequest.newBuilder()
.setMembership(Membership.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.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.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
UpdateMembershipRequest request =
UpdateMembershipRequest.newBuilder()
.setMembership(Membership.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.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.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
Message message = Message.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Message response = chatServiceClient.updateMessage(message, updateMask);
}
Parameters | |
---|---|
Name | Description |
message |
Message Required. Message with fields updated. |
updateMask |
FieldMask Required. The field paths to update. Separate multiple values with commas or
use Currently supported field paths: - - - - - |
Returns | |
---|---|
Type | Description |
Message |
updateMessage(UpdateMessageRequest request)
public final Message updateMessage(UpdateMessageRequest request)
Updates a message. There's a difference between the patch
and update
methods. The patch
method uses a patch
request while the update
method uses a put
request. We recommend
using the patch
method. For an example, see Update a
message.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
UpdateMessageRequest request =
UpdateMessageRequest.newBuilder()
.setMessage(Message.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setAllowMissing(true)
.build();
Message response = chatServiceClient.updateMessage(request);
}
Parameter | |
---|---|
Name | Description |
request |
UpdateMessageRequest The request object containing all of the parameters for the API call. |
Returns | |
---|---|
Type | Description |
Message |
updateMessageCallable()
public final UnaryCallable<UpdateMessageRequest,Message> updateMessageCallable()
Updates a message. There's a difference between the patch
and update
methods. The patch
method uses a patch
request while the update
method uses a put
request. We recommend
using the patch
method. For an example, see Update a
message.
Requires authentication. Supports app authentication and user authentication. When using app authentication, requests can only update messages created by the calling Chat app.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
UpdateMessageRequest request =
UpdateMessageRequest.newBuilder()
.setMessage(Message.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.setAllowMissing(true)
.build();
ApiFuture<Message> future = chatServiceClient.updateMessageCallable().futureCall(request);
// Do something.
Message response = future.get();
}
Returns | |
---|---|
Type | Description |
UnaryCallable<UpdateMessageRequest,Message> |
updateSpace(Space space, FieldMask updateMask)
public final Space updateSpace(Space space, FieldMask updateMask)
Updates a space. For an example, see Update a space.
If you're updating the displayName
field and receive the error message ALREADY_EXISTS
,
try a different display name.. An existing space within the Google Workspace organization might
already use this display name.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
Space space = Space.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Space response = chatServiceClient.updateSpace(space, updateMask);
}
Parameters | |
---|---|
Name | Description |
space |
Space Required. Space with fields to be updated. |
updateMask |
FieldMask Required. The updated field paths, comma separated if there are multiple. Currently supported field paths: - - - - - - Developer Preview: Supports changing the permission
settings of a space, supported field
paths include: |
Returns | |
---|---|
Type | Description |
Space |
updateSpace(UpdateSpaceRequest request)
public final Space updateSpace(UpdateSpaceRequest request)
Updates a space. For an example, see Update a space.
If you're updating the displayName
field and receive the error message ALREADY_EXISTS
,
try a different display name.. An existing space within the Google Workspace organization might
already use this display name.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
UpdateSpaceRequest request =
UpdateSpaceRequest.newBuilder()
.setSpace(Space.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.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.
Requires user authentication.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) {
UpdateSpaceRequest request =
UpdateSpaceRequest.newBuilder()
.setSpace(Space.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.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 - Their Workspace email address. For example,
- Their user id. For example, Format: users/{user}/spaces/{space}/spaceReadState |
updateMask |
FieldMask Required. The field paths to update. Currently supported field paths: - When the To mark the space as read, set |
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> |