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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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. For an example, see [Create a message](https://developers.google.com/chat/api/guides/v1/messages/create). + * Calling this method requires [authentication](https://developers.google.com/chat/api/guides/auth) 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](/chat/api/guides/v1/messages/list). Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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 memberships](https://developers.google.com/chat/api/guides/v1/members/list). Listing memberships with [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with [User authentication](https://developers.google.com/chat/api/guides/auth/users) lists memberships in spaces that the authenticated user has access to. + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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 a membership](https://developers.google.com/chat/api/guides/v1/members/get). + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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 [Read a message](https://developers.google.com/chat/api/guides/v1/messages/get). + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * 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 `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](https://developers.google.com/chat/api/guides/v1/messages/update). + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). 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](https://developers.google.com/chat/api/guides/v1/messages/delete). + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). 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](https://developers.google.com/chat/api/reference/rest/v1/media/download). For an example, see [Get a message attachment](https://developers.google.com/chat/api/guides/v1/media-and-attachments/get). Requires [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/media-and-attachments/upload). Requires user [authentication](https://developers.google.com/chat/api/guides/auth/users). + * You can upload attachments up to 200 MB. Certain file types aren't supported. For details, see [File types blocked by Google Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat). |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/spaces/list). + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed until the first message is sent. |
+ *
+ * Request object method variants only take one parameter, a request object, which must be constructed before the call. + *
"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 a space](https://developers.google.com/chat/api/guides/v1/spaces/get). + * Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/spaces/create). + * 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](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/spaces/set-up). + * To specify the human members to add, add memberships with the appropriate `member.name` in the `SetUpSpaceRequest`. To add a human user, use `users/{user}`, where `{user}` can be the email address for the user. For users in the same Workspace organization `{user}` can also be the `id` for the person from the People API, or the `id` for the user in the Directory API. For example, if the People API Person profile ID for `user{@literal @}example.com` is `123456789`, you can add the user to the space by setting the `membership.member.name` to `users/user{@literal @}example.com` or `users/123456789`. + * For a space or group chat, if the caller blocks or is blocked by some members, then those members aren't added to the created space. + * To create a direct message (DM) between the calling user and another human user, specify exactly one membership to represent the human user. If one user blocks the other, the request fails and the DM isn't created. + * To create a DM between the calling user and the calling app, set `Space.singleUserBotDm` to `true` and don't specify any memberships. You can only use this method to set up a DM with the calling app. To add the calling app as a member of a space or an existing DM between two human users, see [create a membership](https://developers.google.com/chat/api/guides/v1/members/create). + * 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](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/spaces/update). + * 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](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/spaces/delete). Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users) 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](https://developers.google.com/chat/api/guides/import-data) 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](https://developers.google.com/chat/api/guides/authorize-import). |
+ *
+ * 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 `404 NOT_FOUND` error. For an example, see [Find a direct message](/chat/api/guides/v1/spaces/find-direct-message). + * With [user authentication](https://developers.google.com/chat/api/guides/auth/users), returns the direct message space between the specified user and the authenticated user. + * With [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts), returns the direct message space between the specified user and the calling Chat app. + * Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users) or [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). |
+ *
+ * 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 [ Create a membership](https://developers.google.com/chat/api/guides/v1/members/create). 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](https://developers.google.com/chat/api/guides/auth/users). + * To specify the member to add, set the `membership.member.name` in the `CreateMembershipRequest`: + * - To add the calling app to a space or a direct message between two human users, use `users/app`. Unable to add other apps to the space. + * - To add a human user, use `users/{user}`, where `{user}` can be the email address for the user. For users in the same Workspace organization `{user}` can also be the `id` for the person from the People API, or the `id` for the user in the Directory API. For example, if the People API Person profile ID for `user{@literal @}example.com` is `123456789`, you can add the user to the space by setting the `membership.member.name` to `users/user{@literal @}example.com` or `users/123456789`. |
+ *
+ * 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 [Delete a membership](https://developers.google.com/chat/api/guides/v1/members/delete). + * Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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. For an example, see [Create a reaction](https://developers.google.com/chat/api/guides/v1/reactions/create). Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). Only unicode emoji are supported. |
+ *
+ * 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](https://developers.google.com/chat/api/guides/v1/reactions/list). Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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. For an example, see [Delete a reaction](https://developers.google.com/chat/api/guides/v1/reactions/delete). Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). |
+ *
+ * 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require 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. + */ +@Generated("by gapic-generator-java") +public class ChatServiceClient implements BackgroundResource { + private final ChatServiceSettings settings; + private final ChatServiceStub stub; + + /** Constructs an instance of ChatServiceClient with default settings. */ + public static final ChatServiceClient create() throws IOException { + return create(ChatServiceSettings.newBuilder().build()); + } + + /** + * 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. + */ + public static final ChatServiceClient create(ChatServiceSettings settings) throws IOException { + return new ChatServiceClient(settings); + } + + /** + * Constructs an instance of ChatServiceClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(ChatServiceSettings). + */ + public static final ChatServiceClient create(ChatServiceStub stub) { + return new ChatServiceClient(stub); + } + + /** + * 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. + */ + protected ChatServiceClient(ChatServiceSettings settings) throws IOException { + this.settings = settings; + this.stub = ((ChatServiceStubSettings) settings.getStubSettings()).createStub(); + } + + protected ChatServiceClient(ChatServiceStub stub) { + this.settings = null; + this.stub = stub; + } + + public final ChatServiceSettings getSettings() { + return settings; + } + + public ChatServiceStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a message in a Google Chat space. For an example, see [Create a + * message](https://developers.google.com/chat/api/guides/v1/messages/create). + * + *
Calling this method requires + * [authentication](https://developers.google.com/chat/api/guides/auth) 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param parent Required. The resource name of the space in which to create a message. + *
Format: `spaces/{space}` + * @param message Required. Message body. + * @param messageId Optional. A custom ID for a message. Lets Chat apps get, update, or delete a + * message without needing to store the system-assigned ID in the message's resource name + * (represented in the message `name` field). + *
The value for this field must meet the following requirements: + *
For details, see [Name a + * message](https://developers.google.com/chat/api/guides/v1/messages/create#name_a_created_message). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message createMessage(SpaceName parent, Message message, String messageId) { + CreateMessageRequest request = + CreateMessageRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setMessage(message) + .setMessageId(messageId) + .build(); + return createMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a message in a Google Chat space. For an example, see [Create a + * message](https://developers.google.com/chat/api/guides/v1/messages/create). + * + *
Calling this method requires + * [authentication](https://developers.google.com/chat/api/guides/auth) 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param parent Required. The resource name of the space in which to create a message. + *
Format: `spaces/{space}` + * @param message Required. Message body. + * @param messageId Optional. A custom ID for a message. Lets Chat apps get, update, or delete a + * message without needing to store the system-assigned ID in the message's resource name + * (represented in the message `name` field). + *
The value for this field must meet the following requirements: + *
For details, see [Name a + * message](https://developers.google.com/chat/api/guides/v1/messages/create#name_a_created_message). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message createMessage(String parent, Message message, String messageId) { + CreateMessageRequest request = + CreateMessageRequest.newBuilder() + .setParent(parent) + .setMessage(message) + .setMessageId(messageId) + .build(); + return createMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a message in a Google Chat space. For an example, see [Create a + * message](https://developers.google.com/chat/api/guides/v1/messages/create). + * + *
Calling this method requires + * [authentication](https://developers.google.com/chat/api/guides/auth) 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message createMessage(CreateMessageRequest request) { + return createMessageCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a message in a Google Chat space. For an example, see [Create a + * message](https://developers.google.com/chat/api/guides/v1/messages/create). + * + *
Calling this method requires + * [authentication](https://developers.google.com/chat/api/guides/auth) 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: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.createMessageCallable().futureCall(request); + * // Do something. + * Message response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param parent Required. The resource name of the space to list messages from. + *
Format: `spaces/{space}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListMessagesPagedResponse listMessages(SpaceName parent) { + ListMessagesRequest request = + ListMessagesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listMessages(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](/chat/api/guides/v1/messages/list). + * Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param parent Required. The resource name of the space to list messages from. + *
Format: `spaces/{space}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListMessagesPagedResponse listMessages(String parent) { + ListMessagesRequest request = ListMessagesRequest.newBuilder().setParent(parent).build(); + return listMessages(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](/chat/api/guides/v1/messages/list). + * Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListMessagesPagedResponse listMessages(ListMessagesRequest request) { + return listMessagesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](/chat/api/guides/v1/messages/list). + * Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.listMessagesPagedCallable().futureCall(request); + * // Do something. + * for (Message element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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; + * } + * } + * } + * }+ */ + public final UnaryCallable
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param parent Required. The resource name of the space for which to fetch a membership list. + *
Format: spaces/{space} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListMembershipsPagedResponse listMemberships(SpaceName parent) { + ListMembershipsRequest request = + ListMembershipsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listMemberships(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists memberships in a space. For an example, see [List + * memberships](https://developers.google.com/chat/api/guides/v1/members/list). Listing + * memberships with [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) lists + * memberships in spaces that the Chat app has access to, but excludes Chat app memberships, + * including its own. Listing memberships with [User + * authentication](https://developers.google.com/chat/api/guides/auth/users) lists memberships in + * spaces that the authenticated user has access to. + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param parent Required. The resource name of the space for which to fetch a membership list. + *
Format: spaces/{space} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListMembershipsPagedResponse listMemberships(String parent) { + ListMembershipsRequest request = ListMembershipsRequest.newBuilder().setParent(parent).build(); + return listMemberships(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists memberships in a space. For an example, see [List + * memberships](https://developers.google.com/chat/api/guides/v1/members/list). Listing + * memberships with [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) lists + * memberships in spaces that the Chat app has access to, but excludes Chat app memberships, + * including its own. Listing memberships with [User + * authentication](https://developers.google.com/chat/api/guides/auth/users) lists memberships in + * spaces that the authenticated user has access to. + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * ListMembershipsRequest request = + * ListMembershipsRequest.newBuilder() + * .setParent(SpaceName.of("[SPACE]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setShowGroups(true) + * .setShowInvited(true) + * .build(); + * for (Membership element : chatServiceClient.listMemberships(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListMembershipsPagedResponse listMemberships(ListMembershipsRequest request) { + return listMembershipsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists memberships in a space. For an example, see [List + * memberships](https://developers.google.com/chat/api/guides/v1/members/list). Listing + * memberships with [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) lists + * memberships in spaces that the Chat app has access to, but excludes Chat app memberships, + * including its own. Listing memberships with [User + * authentication](https://developers.google.com/chat/api/guides/auth/users) lists memberships in + * spaces that the authenticated user has access to. + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * ListMembershipsRequest request = + * ListMembershipsRequest.newBuilder() + * .setParent(SpaceName.of("[SPACE]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setShowGroups(true) + * .setShowInvited(true) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * chatServiceClient.listMembershipsPagedCallable().futureCall(request); + * // Do something. + * for (Membership element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * ListMembershipsRequest request = + * ListMembershipsRequest.newBuilder() + * .setParent(SpaceName.of("[SPACE]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .setFilter("filter-1274492040") + * .setShowGroups(true) + * .setShowInvited(true) + * .build(); + * while (true) { + * ListMembershipsResponse response = + * chatServiceClient.listMembershipsCallable().call(request); + * for (Membership element : response.getMembershipsList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the membership to retrieve. + *
To get the app's own membership, you can optionally use `spaces/{space}/members/app`. + *
Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app` + *
When [authenticated as a + * user](https://developers.google.com/chat/api/guides/auth/users), you can use the user's + * email as an alias for `{member}`. For example, + * `spaces/{space}/members/example{@literal @}gmail.com` where `example{@literal @}gmail.com` + * is the email of the Google Chat user. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership getMembership(MembershipName name) { + GetMembershipRequest request = + GetMembershipRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getMembership(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a membership. For an example, see [Get a + * membership](https://developers.google.com/chat/api/guides/v1/members/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the membership to retrieve. + *
To get the app's own membership, you can optionally use `spaces/{space}/members/app`. + *
Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app` + *
When [authenticated as a + * user](https://developers.google.com/chat/api/guides/auth/users), you can use the user's + * email as an alias for `{member}`. For example, + * `spaces/{space}/members/example{@literal @}gmail.com` where `example{@literal @}gmail.com` + * is the email of the Google Chat user. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership getMembership(String name) { + GetMembershipRequest request = GetMembershipRequest.newBuilder().setName(name).build(); + return getMembership(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a membership. For an example, see [Get a + * membership](https://developers.google.com/chat/api/guides/v1/members/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * GetMembershipRequest request = + * GetMembershipRequest.newBuilder() + * .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString()) + * .build(); + * Membership response = chatServiceClient.getMembership(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership getMembership(GetMembershipRequest request) { + return getMembershipCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a membership. For an example, see [Get a + * membership](https://developers.google.com/chat/api/guides/v1/members/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * GetMembershipRequest request = + * GetMembershipRequest.newBuilder() + * .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = chatServiceClient.getMembershipCallable().futureCall(request); + * // Do something. + * Membership response = future.get(); + * } + * }
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Note: Might return a message from a blocked member or space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the message. + *
Format: `spaces/{space}/messages/{message}` + *
If you've set a custom ID for your message, you can use the value from the + * `clientAssignedMessageId` field for `{message}`. For details, see [Name a message] + * (https://developers.google.com/chat/api/guides/v1/messages/create#name_a_created_message). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message getMessage(MessageName name) { + GetMessageRequest request = + GetMessageRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a message. For an example, see [Read a + * message](https://developers.google.com/chat/api/guides/v1/messages/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Note: Might return a message from a blocked member or space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the message. + *
Format: `spaces/{space}/messages/{message}` + *
If you've set a custom ID for your message, you can use the value from the + * `clientAssignedMessageId` field for `{message}`. For details, see [Name a message] + * (https://developers.google.com/chat/api/guides/v1/messages/create#name_a_created_message). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message getMessage(String name) { + GetMessageRequest request = GetMessageRequest.newBuilder().setName(name).build(); + return getMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a message. For an example, see [Read a + * message](https://developers.google.com/chat/api/guides/v1/messages/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Note: Might return a message from a blocked member or space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message getMessage(GetMessageRequest request) { + return getMessageCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a message. For an example, see [Read a + * message](https://developers.google.com/chat/api/guides/v1/messages/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Note: Might return a message from a blocked member or space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.getMessageCallable().futureCall(request); + * // Do something. + * Message response = future.get(); + * } + * }
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only update messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param message Required. Message with fields updated. + * @param updateMask Required. The field paths to update. Separate multiple values with commas or + * use `*` to update all field paths. + *
Currently supported field paths: + *
- `text` + *
- `attachment` + *
- `cards` (Requires [app authentication](/chat/api/guides/auth/service-accounts).) + *
- `cards_v2` (Requires [app authentication](/chat/api/guides/auth/service-accounts).) + *
- Developer Preview: `accessory_widgets` (Requires [app + * authentication](/chat/api/guides/auth/service-accounts).) + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message updateMessage(Message message, FieldMask updateMask) { + UpdateMessageRequest request = + UpdateMessageRequest.newBuilder().setMessage(message).setUpdateMask(updateMask).build(); + return updateMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/messages/update). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only update messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Message updateMessage(UpdateMessageRequest request) { + return updateMessageCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/messages/update). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only update messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.updateMessageCallable().futureCall(request); + * // Do something. + * Message response = future.get(); + * } + * }
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only delete messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the message. + *
Format: `spaces/{space}/messages/{message}` + *
If you've set a custom ID for your message, you can use the value from the + * `clientAssignedMessageId` field for `{message}`. For details, see [Name a message] + * (https://developers.google.com/chat/api/guides/v1/messages/create#name_a_created_message). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteMessage(MessageName name) { + DeleteMessageRequest request = + DeleteMessageRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a message. For an example, see [Delete a + * message](https://developers.google.com/chat/api/guides/v1/messages/delete). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only delete messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the message. + *
Format: `spaces/{space}/messages/{message}` + *
If you've set a custom ID for your message, you can use the value from the + * `clientAssignedMessageId` field for `{message}`. For details, see [Name a message] + * (https://developers.google.com/chat/api/guides/v1/messages/create#name_a_created_message). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteMessage(String name) { + DeleteMessageRequest request = DeleteMessageRequest.newBuilder().setName(name).build(); + deleteMessage(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a message. For an example, see [Delete a + * message](https://developers.google.com/chat/api/guides/v1/messages/delete). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only delete messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteMessage(DeleteMessageRequest request) { + deleteMessageCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a message. For an example, see [Delete a + * message](https://developers.google.com/chat/api/guides/v1/messages/delete). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). When using app + * authentication, requests can only delete messages created by the calling Chat app. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.deleteMessageCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the attachment, in the form + * `spaces/*/messages/*/attachments/*`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Attachment getAttachment(AttachmentName name) { + GetAttachmentRequest request = + GetAttachmentRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getAttachment(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the metadata of a message attachment. The attachment data is fetched using the [media + * API](https://developers.google.com/chat/api/reference/rest/v1/media/download). For an example, + * see [Get a message + * attachment](https://developers.google.com/chat/api/guides/v1/media-and-attachments/get). + * Requires [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the attachment, in the form + * `spaces/*/messages/*/attachments/*`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Attachment getAttachment(String name) { + GetAttachmentRequest request = GetAttachmentRequest.newBuilder().setName(name).build(); + return getAttachment(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the metadata of a message attachment. The attachment data is fetched using the [media + * API](https://developers.google.com/chat/api/reference/rest/v1/media/download). For an example, + * see [Get a message + * attachment](https://developers.google.com/chat/api/guides/v1/media-and-attachments/get). + * Requires [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Attachment getAttachment(GetAttachmentRequest request) { + return getAttachmentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the metadata of a message attachment. The attachment data is fetched using the [media + * API](https://developers.google.com/chat/api/reference/rest/v1/media/download). For an example, + * see [Get a message + * attachment](https://developers.google.com/chat/api/guides/v1/media-and-attachments/get). + * Requires [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.getAttachmentCallable().futureCall(request); + * // Do something. + * Attachment response = future.get(); + * } + * }
You can upload attachments up to 200 MB. Certain file types aren't supported. For details, + * see [File types blocked by Google + * Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UploadAttachmentResponse uploadAttachment(UploadAttachmentRequest request) { + return uploadAttachmentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Uploads an attachment. For an example, see [Upload media as a file + * attachment](https://developers.google.com/chat/api/guides/v1/media-and-attachments/upload). + * Requires user [authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
You can upload attachments up to 200 MB. Certain file types aren't supported. For details, + * see [File types blocked by Google + * Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = + * chatServiceClient.uploadAttachmentCallable().futureCall(request); + * // Do something. + * UploadAttachmentResponse response = future.get(); + * } + * }
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed + * until the first message is sent. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSpacesPagedResponse listSpaces() { + ListSpacesRequest request = ListSpacesRequest.newBuilder().build(); + return listSpaces(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/spaces/list). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed + * until the first message is sent. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListSpacesPagedResponse listSpaces(ListSpacesRequest request) { + return listSpacesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/spaces/list). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed + * until the first message is sent. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.listSpacesPagedCallable().futureCall(request); + * // Do something. + * for (Space element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Lists spaces visible to the caller or authenticated user. Group chats and DMs aren't listed + * until the first message is sent. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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; + * } + * } + * } + * }+ */ + public final UnaryCallable
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the space, in the form "spaces/*". + *
Format: `spaces/{space}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space getSpace(SpaceName name) { + GetSpaceRequest request = + GetSpaceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getSpace(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a space. For an example, see [Get a + * space](https://developers.google.com/chat/api/guides/v1/spaces/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the space, in the form "spaces/*". + *
Format: `spaces/{space}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space getSpace(String name) { + GetSpaceRequest request = GetSpaceRequest.newBuilder().setName(name).build(); + return getSpace(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a space. For an example, see [Get a + * space](https://developers.google.com/chat/api/guides/v1/spaces/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * GetSpaceRequest request = + * GetSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build(); + * Space response = chatServiceClient.getSpace(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space getSpace(GetSpaceRequest request) { + return getSpaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Returns details about a space. For an example, see [Get a + * space](https://developers.google.com/chat/api/guides/v1/spaces/get). + * + *
Requires [authentication](https://developers.google.com/chat/api/guides/auth). Supports [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts) and [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * GetSpaceRequest request = + * GetSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build(); + * ApiFuture+ */ + public final UnaryCallablefuture = chatServiceClient.getSpaceCallable().futureCall(request); + * // Do something. + * Space response = future.get(); + * } + * }
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param space Required. The `displayName` and `spaceType` fields must be populated. Only + * `SpaceType.SPACE` is supported. + *
If you receive the error message `ALREADY_EXISTS` when creating a space, try a different + * `displayName`. An existing space within the Google Workspace organization might already use + * this display name. + *
The space `name` is assigned on the server so anything specified in this field will be + * ignored. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space createSpace(Space space) { + CreateSpaceRequest request = CreateSpaceRequest.newBuilder().setSpace(space).build(); + return createSpace(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a named space. Spaces grouped by topics aren't supported. For an example, see [Create a + * space](https://developers.google.com/chat/api/guides/v1/spaces/create). + * + *
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space createSpace(CreateSpaceRequest request) { + return createSpaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a named space. Spaces grouped by topics aren't supported. For an example, see [Create a + * space](https://developers.google.com/chat/api/guides/v1/spaces/create). + * + *
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.createSpaceCallable().futureCall(request); + * // Do something. + * Space response = future.get(); + * } + * }
To specify the human members to add, add memberships with the appropriate `member.name` in + * the `SetUpSpaceRequest`. To add a human user, use `users/{user}`, where `{user}` can be the + * email address for the user. For users in the same Workspace organization `{user}` can also be + * the `id` for the person from the People API, or the `id` for the user in the Directory API. For + * example, if the People API Person profile ID for `user{@literal @}example.com` is `123456789`, + * you can add the user to the space by setting the `membership.member.name` to + * `users/user{@literal @}example.com` or `users/123456789`. + * + *
For a space or group chat, if the caller blocks or is blocked by some members, then those + * members aren't added to the created space. + * + *
To create a direct message (DM) between the calling user and another human user, specify + * exactly one membership to represent the human user. If one user blocks the other, the request + * fails and the DM isn't created. + * + *
To create a DM between the calling user and the calling app, set `Space.singleUserBotDm` to + * `true` and don't specify any memberships. You can only use this method to set up a DM with the + * calling app. To add the calling app as a member of a space or an existing DM between two human + * users, see [create a + * membership](https://developers.google.com/chat/api/guides/v1/members/create). + * + *
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space setUpSpace(SetUpSpaceRequest request) { + return setUpSpaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/spaces/set-up). + * + *()) + * .build(); + * Space response = chatServiceClient.setUpSpace(request); + * } + * }
To specify the human members to add, add memberships with the appropriate `member.name` in + * the `SetUpSpaceRequest`. To add a human user, use `users/{user}`, where `{user}` can be the + * email address for the user. For users in the same Workspace organization `{user}` can also be + * the `id` for the person from the People API, or the `id` for the user in the Directory API. For + * example, if the People API Person profile ID for `user{@literal @}example.com` is `123456789`, + * you can add the user to the space by setting the `membership.member.name` to + * `users/user{@literal @}example.com` or `users/123456789`. + * + *
For a space or group chat, if the caller blocks or is blocked by some members, then those + * members aren't added to the created space. + * + *
To create a direct message (DM) between the calling user and another human user, specify + * exactly one membership to represent the human user. If one user blocks the other, the request + * fails and the DM isn't created. + * + *
To create a DM between the calling user and the calling app, set `Space.singleUserBotDm` to + * `true` and don't specify any memberships. You can only use this method to set up a DM with the + * calling app. To add the calling app as a member of a space or an existing DM between two human + * users, see [create a + * membership](https://developers.google.com/chat/api/guides/v1/members/create). + * + *
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallable()) + * .build(); + * ApiFuture future = chatServiceClient.setUpSpaceCallable().futureCall(request); + * // Do something. + * Space response = future.get(); + * } + * }
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param space Required. Space with fields to be updated. `Space.name` must be populated in the + * form of `spaces/{space}`. Only fields specified by `update_mask` are updated. + * @param updateMask Required. The updated field paths, comma separated if there are multiple. + *
Currently supported field paths: + *
- `display_name` (Only supports changing the display name of a space with the `SPACE` + * type, or when also including the `space_type` mask to change a `GROUP_CHAT` space type to + * `SPACE`. Trying to update the display name of a `GROUP_CHAT` or a `DIRECT_MESSAGE` space + * results in an invalid argument error. If you receive the error message `ALREADY_EXISTS` + * when updating the `displayName`, try a different `displayName`. An existing space within + * the Google Workspace organization might already use this display name.) + *
- `space_type` (Only supports changing a `GROUP_CHAT` space type to `SPACE`. Include + * `display_name` together with `space_type` in the update mask and ensure that the specified + * space has a non-empty display name and the `SPACE` space type. Including the `space_type` + * mask and the `SPACE` type in the specified space when updating the display name is optional + * if the existing space already has the `SPACE` type. Trying to update the space type in + * other ways results in an invalid argument error). + *
- `space_details` + *
- `space_history_state` (Supports [turning history on or off for the + * space](https://support.google.com/chat/answer/7664687) if [the organization allows users to + * change their history setting](https://support.google.com/a/answer/7664184). Warning: + * mutually exclusive with all other field paths.) - Developer Preview: + * `access_settings.audience` (Supports changing the [access + * setting](https://support.google.com/chat/answer/11971020) of a space. If no audience is + * specified in the access setting, the space's access setting is updated to restricted. + * Warning: mutually exclusive with all other field paths.) + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space updateSpace(Space space, FieldMask updateMask) { + UpdateSpaceRequest request = + UpdateSpaceRequest.newBuilder().setSpace(space).setUpdateMask(updateMask).build(); + return updateSpace(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a space. For an example, see [Update a + * space](https://developers.google.com/chat/api/guides/v1/spaces/update). + * + *
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * UpdateSpaceRequest request = + * UpdateSpaceRequest.newBuilder() + * .setSpace(Space.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * Space response = chatServiceClient.updateSpace(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space updateSpace(UpdateSpaceRequest request) { + return updateSpaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a space. For an example, see [Update a + * space](https://developers.google.com/chat/api/guides/v1/spaces/update). + * + *
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](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * UpdateSpaceRequest request = + * UpdateSpaceRequest.newBuilder() + * .setSpace(Space.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = chatServiceClient.updateSpaceCallable().futureCall(request); + * // Do something. + * Space response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the space to delete. + *
Format: `spaces/{space}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSpace(SpaceName name) { + DeleteSpaceRequest request = + DeleteSpaceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteSpace(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/spaces/delete). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users) from a user who has + * permission to delete the space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the space to delete. + *
Format: `spaces/{space}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSpace(String name) { + DeleteSpaceRequest request = DeleteSpaceRequest.newBuilder().setName(name).build(); + deleteSpace(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/spaces/delete). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users) from a user who has + * permission to delete the space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * DeleteSpaceRequest request = + * DeleteSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build(); + * chatServiceClient.deleteSpace(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteSpace(DeleteSpaceRequest request) { + deleteSpaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](https://developers.google.com/chat/api/guides/v1/spaces/delete). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users) from a user who has + * permission to delete the space. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * DeleteSpaceRequest request = + * DeleteSpaceRequest.newBuilder().setName(SpaceName.of("[SPACE]").toString()).build(); + * ApiFuture+ */ + public final UnaryCallablefuture = chatServiceClient.deleteSpaceCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CompleteImportSpaceResponse completeImportSpace(CompleteImportSpaceRequest request) { + return completeImportSpaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Completes the [import process](https://developers.google.com/chat/api/guides/import-data) 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](https://developers.google.com/chat/api/guides/authorize-import). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = + * chatServiceClient.completeImportSpaceCallable().futureCall(request); + * // Do something. + * CompleteImportSpaceResponse response = future.get(); + * } + * }
With [user authentication](https://developers.google.com/chat/api/guides/auth/users), + * returns the direct message space between the specified user and the authenticated user. + * + *
With [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts), returns + * the direct message space between the specified user and the calling Chat app. + * + *
Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users) or + * [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Space findDirectMessage(FindDirectMessageRequest request) { + return findDirectMessageCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * 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](/chat/api/guides/v1/spaces/find-direct-message). + * + *
With [user authentication](https://developers.google.com/chat/api/guides/auth/users), + * returns the direct message space between the specified user and the authenticated user. + * + *
With [app + * authentication](https://developers.google.com/chat/api/guides/auth/service-accounts), returns + * the direct message space between the specified user and the calling Chat app. + * + *
Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users) or + * [app authentication](https://developers.google.com/chat/api/guides/auth/service-accounts). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.findDirectMessageCallable().futureCall(request); + * // Do something. + * Space response = future.get(); + * } + * }
To specify the member to add, set the `membership.member.name` in the + * `CreateMembershipRequest`: + * + *
- To add the calling app to a space or a direct message between two human users, use + * `users/app`. Unable to add other apps to the space. + * + *
- To add a human user, use `users/{user}`, where `{user}` can be the email address for the + * user. For users in the same Workspace organization `{user}` can also be the `id` for the person + * from the People API, or the `id` for the user in the Directory API. For example, if the People + * API Person profile ID for `user{@literal @}example.com` is `123456789`, you can add the user to + * the space by setting the `membership.member.name` to `users/user{@literal @}example.com` or + * `users/123456789`. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param parent Required. The resource name of the space for which to create the membership. + *
Format: spaces/{space} + * @param membership Required. The membership relation to create. The `memberType` field must + * contain a user with the `user.name` and `user.type` fields populated. The server will + * assign a resource name and overwrite anything specified. When a Chat app creates a + * membership relation for a human user, it must use the `chat.memberships` scope, set + * `user.type` to `HUMAN`, and set `user.name` with format `users/{user}`, where `{user}` can + * be the email address for the user. For users in the same Workspace organization `{user}` + * can also be the `id` of the + * [person](https://developers.google.com/people/api/rest/v1/people) 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{@literal @}example.com` is `123456789`, you can add the user to the space by + * setting the `membership.member.name` to `users/user{@literal @}example.com` or + * `users/123456789`. When a Chat app creates a membership relation for itself, it must use + * the `chat.memberships.app` scope, set `user.type` to `BOT`, and set `user.name` to + * `users/app`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership createMembership(SpaceName parent, Membership membership) { + CreateMembershipRequest request = + CreateMembershipRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setMembership(membership) + .build(); + return createMembership(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a human membership or app membership for the calling app. Creating memberships for + * other apps isn't supported. For an example, see [ Create a + * membership](https://developers.google.com/chat/api/guides/v1/members/create). 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](https://developers.google.com/chat/api/guides/auth/users). + * + *
To specify the member to add, set the `membership.member.name` in the + * `CreateMembershipRequest`: + * + *
- To add the calling app to a space or a direct message between two human users, use + * `users/app`. Unable to add other apps to the space. + * + *
- To add a human user, use `users/{user}`, where `{user}` can be the email address for the + * user. For users in the same Workspace organization `{user}` can also be the `id` for the person + * from the People API, or the `id` for the user in the Directory API. For example, if the People + * API Person profile ID for `user{@literal @}example.com` is `123456789`, you can add the user to + * the space by setting the `membership.member.name` to `users/user{@literal @}example.com` or + * `users/123456789`. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param parent Required. The resource name of the space for which to create the membership. + *
Format: spaces/{space} + * @param membership Required. The membership relation to create. The `memberType` field must + * contain a user with the `user.name` and `user.type` fields populated. The server will + * assign a resource name and overwrite anything specified. When a Chat app creates a + * membership relation for a human user, it must use the `chat.memberships` scope, set + * `user.type` to `HUMAN`, and set `user.name` with format `users/{user}`, where `{user}` can + * be the email address for the user. For users in the same Workspace organization `{user}` + * can also be the `id` of the + * [person](https://developers.google.com/people/api/rest/v1/people) 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{@literal @}example.com` is `123456789`, you can add the user to the space by + * setting the `membership.member.name` to `users/user{@literal @}example.com` or + * `users/123456789`. When a Chat app creates a membership relation for itself, it must use + * the `chat.memberships.app` scope, set `user.type` to `BOT`, and set `user.name` to + * `users/app`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership createMembership(String parent, Membership membership) { + CreateMembershipRequest request = + CreateMembershipRequest.newBuilder().setParent(parent).setMembership(membership).build(); + return createMembership(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a human membership or app membership for the calling app. Creating memberships for + * other apps isn't supported. For an example, see [ Create a + * membership](https://developers.google.com/chat/api/guides/v1/members/create). 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](https://developers.google.com/chat/api/guides/auth/users). + * + *
To specify the member to add, set the `membership.member.name` in the + * `CreateMembershipRequest`: + * + *
- To add the calling app to a space or a direct message between two human users, use + * `users/app`. Unable to add other apps to the space. + * + *
- To add a human user, use `users/{user}`, where `{user}` can be the email address for the + * user. For users in the same Workspace organization `{user}` can also be the `id` for the person + * from the People API, or the `id` for the user in the Directory API. For example, if the People + * API Person profile ID for `user{@literal @}example.com` is `123456789`, you can add the user to + * the space by setting the `membership.member.name` to `users/user{@literal @}example.com` or + * `users/123456789`. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * CreateMembershipRequest request = + * CreateMembershipRequest.newBuilder() + * .setParent(SpaceName.of("[SPACE]").toString()) + * .setMembership(Membership.newBuilder().build()) + * .build(); + * Membership response = chatServiceClient.createMembership(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership createMembership(CreateMembershipRequest request) { + return createMembershipCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a human membership or app membership for the calling app. Creating memberships for + * other apps isn't supported. For an example, see [ Create a + * membership](https://developers.google.com/chat/api/guides/v1/members/create). 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](https://developers.google.com/chat/api/guides/auth/users). + * + *
To specify the member to add, set the `membership.member.name` in the + * `CreateMembershipRequest`: + * + *
- To add the calling app to a space or a direct message between two human users, use + * `users/app`. Unable to add other apps to the space. + * + *
- To add a human user, use `users/{user}`, where `{user}` can be the email address for the + * user. For users in the same Workspace organization `{user}` can also be the `id` for the person + * from the People API, or the `id` for the user in the Directory API. For example, if the People + * API Person profile ID for `user{@literal @}example.com` is `123456789`, you can add the user to + * the space by setting the `membership.member.name` to `users/user{@literal @}example.com` or + * `users/123456789`. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * CreateMembershipRequest request = + * CreateMembershipRequest.newBuilder() + * .setParent(SpaceName.of("[SPACE]").toString()) + * .setMembership(Membership.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * chatServiceClient.createMembershipCallable().futureCall(request); + * // Do something. + * Membership response = future.get(); + * } + * }
Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the membership to delete. Chat apps can delete human + * users' or their own memberships. Chat apps can't delete other apps' memberships. + *
When deleting a human membership, requires the `chat.memberships` scope and + * `spaces/{space}/members/{member}` format. You can use the email as an alias for `{member}`. + * For example, `spaces/{space}/members/example{@literal @}gmail.com` where + * `example{@literal @}gmail.com` is the email of the Google Chat user. + *
When deleting an app membership, requires the `chat.memberships.app` scope and + * `spaces/{space}/members/app` format. + *
Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership deleteMembership(MembershipName name) { + DeleteMembershipRequest request = + DeleteMembershipRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return deleteMembership(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a membership. For an example, see [Delete a + * membership](https://developers.google.com/chat/api/guides/v1/members/delete). + * + *
Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Resource name of the membership to delete. Chat apps can delete human + * users' or their own memberships. Chat apps can't delete other apps' memberships. + *
When deleting a human membership, requires the `chat.memberships` scope and + * `spaces/{space}/members/{member}` format. You can use the email as an alias for `{member}`. + * For example, `spaces/{space}/members/example{@literal @}gmail.com` where + * `example{@literal @}gmail.com` is the email of the Google Chat user. + *
When deleting an app membership, requires the `chat.memberships.app` scope and + * `spaces/{space}/members/app` format. + *
Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership deleteMembership(String name) { + DeleteMembershipRequest request = DeleteMembershipRequest.newBuilder().setName(name).build(); + return deleteMembership(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a membership. For an example, see [Delete a + * membership](https://developers.google.com/chat/api/guides/v1/members/delete). + * + *
Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * DeleteMembershipRequest request = + * DeleteMembershipRequest.newBuilder() + * .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString()) + * .build(); + * Membership response = chatServiceClient.deleteMembership(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Membership deleteMembership(DeleteMembershipRequest request) { + return deleteMembershipCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a membership. For an example, see [Delete a + * membership](https://developers.google.com/chat/api/guides/v1/members/delete). + * + *
Requires [user authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating the service client as shown in + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library + * try (ChatServiceClient chatServiceClient = ChatServiceClient.create()) { + * DeleteMembershipRequest request = + * DeleteMembershipRequest.newBuilder() + * .setName(MembershipName.of("[SPACE]", "[MEMBER]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * chatServiceClient.deleteMembershipCallable().futureCall(request); + * // Do something. + * Membership response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param parent Required. The message where the reaction is created. + *
Format: `spaces/{space}/messages/{message}` + * @param reaction Required. The reaction to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Reaction createReaction(MessageName parent, Reaction reaction) { + CreateReactionRequest request = + CreateReactionRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setReaction(reaction) + .build(); + return createReaction(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a reaction and adds it to a message. For an example, see [Create a + * reaction](https://developers.google.com/chat/api/guides/v1/reactions/create). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). Only unicode emoji + * are supported. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param parent Required. The message where the reaction is created. + *
Format: `spaces/{space}/messages/{message}` + * @param reaction Required. The reaction to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Reaction createReaction(String parent, Reaction reaction) { + CreateReactionRequest request = + CreateReactionRequest.newBuilder().setParent(parent).setReaction(reaction).build(); + return createReaction(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a reaction and adds it to a message. For an example, see [Create a + * reaction](https://developers.google.com/chat/api/guides/v1/reactions/create). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). Only unicode emoji + * are supported. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Reaction createReaction(CreateReactionRequest request) { + return createReactionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a reaction and adds it to a message. For an example, see [Create a + * reaction](https://developers.google.com/chat/api/guides/v1/reactions/create). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). Only unicode emoji + * are supported. + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.createReactionCallable().futureCall(request); + * // Do something. + * Reaction response = future.get(); + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param parent Required. The message users reacted to. + *
Format: `spaces/{space}/messages/{message}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListReactionsPagedResponse listReactions(MessageName parent) { + ListReactionsRequest request = + ListReactionsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listReactions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists reactions to a message. For an example, see [List + * reactions](https://developers.google.com/chat/api/guides/v1/reactions/list). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param parent Required. The message users reacted to. + *
Format: `spaces/{space}/messages/{message}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListReactionsPagedResponse listReactions(String parent) { + ListReactionsRequest request = ListReactionsRequest.newBuilder().setParent(parent).build(); + return listReactions(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists reactions to a message. For an example, see [List + * reactions](https://developers.google.com/chat/api/guides/v1/reactions/list). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListReactionsPagedResponse listReactions(ListReactionsRequest request) { + return listReactionsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists reactions to a message. For an example, see [List + * reactions](https://developers.google.com/chat/api/guides/v1/reactions/list). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = + * chatServiceClient.listReactionsPagedCallable().futureCall(request); + * // Do something. + * for (Reaction element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Name of the reaction to delete. + *
Format: `spaces/{space}/messages/{message}/reactions/{reaction}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteReaction(ReactionName name) { + DeleteReactionRequest request = + DeleteReactionRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteReaction(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a reaction to a message. For an example, see [Delete a + * reaction](https://developers.google.com/chat/api/guides/v1/reactions/delete). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param name Required. Name of the reaction to delete. + *
Format: `spaces/{space}/messages/{message}/reactions/{reaction}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteReaction(String name) { + DeleteReactionRequest request = DeleteReactionRequest.newBuilder().setName(name).build(); + deleteReaction(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a reaction to a message. For an example, see [Delete a + * reaction](https://developers.google.com/chat/api/guides/v1/reactions/delete). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteReaction(DeleteReactionRequest request) { + deleteReactionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a reaction to a message. For an example, see [Delete a + * reaction](https://developers.google.com/chat/api/guides/v1/reactions/delete). Requires [user + * authentication](https://developers.google.com/chat/api/guides/auth/users). + * + *
Sample code: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require specifying regional endpoints when creating 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+ */ + public final UnaryCallablefuture = chatServiceClient.deleteReactionCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *
For example, to set the total timeout of createMessage to 30 seconds: + * + *
{@code + * // This snippet has been automatically generated and should be regarded as a code template only. + * // It will require modifications to work: + * // - It may require correct/in-range values for request initialization. + * // - It may require 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.Builder chatServiceSettingsBuilder = ChatServiceSettings.newBuilder(); + * chatServiceSettingsBuilder + * .createMessageSettings() + * .setRetrySettings( + * chatServiceSettingsBuilder + * .createMessageSettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * ChatServiceSettings chatServiceSettings = chatServiceSettingsBuilder.build(); + * }+ */ +@Generated("by gapic-generator-java") +public class ChatServiceSettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction The interfaces provided are listed below, along with usage samples.
+ *
+ * ======================= ChatServiceClient =======================
+ *
+ * Service Description: Enables developers to build Chat apps and integrations on Google Chat
+ * Platform.
+ *
+ * Sample for ChatServiceClient:
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+public abstract class ChatServiceStub implements BackgroundResource {
+
+ public UnaryCallable The default instance has everything set to sensible defaults:
+ *
+ * The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ * For example, to set the total timeout of createMessage to 30 seconds:
+ *
+ * Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating 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);
+ * }
+ * }
+ */
+@Generated("by gapic-generator-java")
+package com.google.chat.v1;
+
+import javax.annotation.Generated;
diff --git a/java-chat/google-cloud-chat/src/main/java/com/google/chat/v1/stub/ChatServiceStub.java b/java-chat/google-cloud-chat/src/main/java/com/google/chat/v1/stub/ChatServiceStub.java
new file mode 100644
index 000000000000..32142b905e11
--- /dev/null
+++ b/java-chat/google-cloud-chat/src/main/java/com/google/chat/v1/stub/ChatServiceStub.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2024 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.chat.v1.stub;
+
+import static com.google.chat.v1.ChatServiceClient.ListMembershipsPagedResponse;
+import static com.google.chat.v1.ChatServiceClient.ListMessagesPagedResponse;
+import static com.google.chat.v1.ChatServiceClient.ListReactionsPagedResponse;
+import static com.google.chat.v1.ChatServiceClient.ListSpacesPagedResponse;
+
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.chat.v1.Attachment;
+import com.google.chat.v1.CompleteImportSpaceRequest;
+import com.google.chat.v1.CompleteImportSpaceResponse;
+import com.google.chat.v1.CreateMembershipRequest;
+import com.google.chat.v1.CreateMessageRequest;
+import com.google.chat.v1.CreateReactionRequest;
+import com.google.chat.v1.CreateSpaceRequest;
+import com.google.chat.v1.DeleteMembershipRequest;
+import com.google.chat.v1.DeleteMessageRequest;
+import com.google.chat.v1.DeleteReactionRequest;
+import com.google.chat.v1.DeleteSpaceRequest;
+import com.google.chat.v1.FindDirectMessageRequest;
+import com.google.chat.v1.GetAttachmentRequest;
+import com.google.chat.v1.GetMembershipRequest;
+import com.google.chat.v1.GetMessageRequest;
+import com.google.chat.v1.GetSpaceRequest;
+import com.google.chat.v1.ListMembershipsRequest;
+import com.google.chat.v1.ListMembershipsResponse;
+import com.google.chat.v1.ListMessagesRequest;
+import com.google.chat.v1.ListMessagesResponse;
+import com.google.chat.v1.ListReactionsRequest;
+import com.google.chat.v1.ListReactionsResponse;
+import com.google.chat.v1.ListSpacesRequest;
+import com.google.chat.v1.ListSpacesResponse;
+import com.google.chat.v1.Membership;
+import com.google.chat.v1.Message;
+import com.google.chat.v1.Reaction;
+import com.google.chat.v1.SetUpSpaceRequest;
+import com.google.chat.v1.Space;
+import com.google.chat.v1.UpdateMessageRequest;
+import com.google.chat.v1.UpdateSpaceRequest;
+import com.google.chat.v1.UploadAttachmentRequest;
+import com.google.chat.v1.UploadAttachmentResponse;
+import com.google.protobuf.Empty;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the ChatService service API.
+ *
+ *
+ *
+ *
+ * {@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * ChatServiceStubSettings.Builder chatServiceSettingsBuilder =
+ * ChatServiceStubSettings.newBuilder();
+ * chatServiceSettingsBuilder
+ * .createMessageSettings()
+ * .setRetrySettings(
+ * chatServiceSettingsBuilder
+ * .createMessageSettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * ChatServiceStubSettings chatServiceSettings = chatServiceSettingsBuilder.build();
+ * }
+ */
+@Generated("by gapic-generator-java")
+public class ChatServiceStubSettings extends StubSettings