Google Apps Chat V1 Client - Class ChatServiceClient (0.6.0)

Reference documentation and code samples for the Google Apps Chat V1 Client class ChatServiceClient.

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

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

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 parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Apps \ Chat \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

completeImportSpace

Completes the import process for the specified space and makes it visible to users.

Requires app authentication and domain-wide delegation. For more information, see Authorize Google Chat apps to import data.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::completeImportSpaceAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\CompleteImportSpaceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\CompleteImportSpaceResponse
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\CompleteImportSpaceRequest;
use Google\Apps\Chat\V1\CompleteImportSpaceResponse;

/**
 * @param string $formattedName Resource name of the import mode space.
 *
 *                              Format: `spaces/{space}`
 *                              Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function complete_import_space_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new CompleteImportSpaceRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var CompleteImportSpaceResponse $response */
        $response = $chatServiceClient->completeImportSpace($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::spaceName('[SPACE]');

    complete_import_space_sample($formattedName);
}

createMembership

Creates a membership for the calling Chat app, a user, or a Google Group.

Creating memberships for other Chat apps isn't supported. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space. Requires user authentication.

For example usage, see:

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::createMembershipAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\CreateMembershipRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Membership
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\CreateMembershipRequest;
use Google\Apps\Chat\V1\Membership;

/**
 * @param string $formattedParent The resource name of the space for which to create the
 *                                membership.
 *
 *                                Format: spaces/{space}
 *                                Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function create_membership_sample(string $formattedParent): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $membership = new Membership();
    $request = (new CreateMembershipRequest())
        ->setParent($formattedParent)
        ->setMembership($membership);

    // Call the API and handle any network failures.
    try {
        /** @var Membership $response */
        $response = $chatServiceClient->createMembership($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::spaceName('[SPACE]');

    create_membership_sample($formattedParent);
}

createMessage

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

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

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

Message sent with app
authentication

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

Message sent with user
authentication

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::createMessageAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\CreateMessageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Message
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\CreateMessageRequest;
use Google\Apps\Chat\V1\Message;

/**
 * @param string $formattedParent The resource name of the space in which to create a message.
 *
 *                                Format: `spaces/{space}`
 *                                Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function create_message_sample(string $formattedParent): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $message = new Message();
    $request = (new CreateMessageRequest())
        ->setParent($formattedParent)
        ->setMessage($message);

    // Call the API and handle any network failures.
    try {
        /** @var Message $response */
        $response = $chatServiceClient->createMessage($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::spaceName('[SPACE]');

    create_message_sample($formattedParent);
}

createReaction

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

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::createReactionAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\CreateReactionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Reaction
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\CreateReactionRequest;
use Google\Apps\Chat\V1\Reaction;

/**
 * @param string $formattedParent The message where the reaction is created.
 *
 *                                Format: `spaces/{space}/messages/{message}`
 *                                Please see {@see ChatServiceClient::messageName()} for help formatting this field.
 */
function create_reaction_sample(string $formattedParent): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $reaction = new Reaction();
    $request = (new CreateReactionRequest())
        ->setParent($formattedParent)
        ->setReaction($reaction);

    // Call the API and handle any network failures.
    try {
        /** @var Reaction $response */
        $response = $chatServiceClient->createReaction($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::messageName('[SPACE]', '[MESSAGE]');

    create_reaction_sample($formattedParent);
}

createSpace

Creates a space with no members. Can be used to create a named space.

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

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

If you're a member of the Developer Preview program, you can create a group chat in import mode using spaceType.GROUP_CHAT.

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::createSpaceAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\CreateSpaceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Space
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\CreateSpaceRequest;
use Google\Apps\Chat\V1\Space;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function create_space_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $space = new Space();
    $request = (new CreateSpaceRequest())
        ->setSpace($space);

    // Call the API and handle any network failures.
    try {
        /** @var Space $response */
        $response = $chatServiceClient->createSpace($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

deleteMembership

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteMembershipRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Membership
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\DeleteMembershipRequest;
use Google\Apps\Chat\V1\Membership;

/**
 * @param string $formattedName Resource name of the membership to delete. Chat apps can delete
 *                              human users' or their own memberships. Chat apps can't delete other apps'
 *                              memberships.
 *
 *                              When deleting a human membership, requires the `chat.memberships` scope and
 *                              `spaces/{space}/members/{member}` format. You can use the email as an
 *                              alias for `{member}`. For example,
 *                              `spaces/{space}/members/example@gmail.com` where `example@gmail.com` is the
 *                              email of the Google Chat user.
 *
 *                              When deleting an app membership, requires the `chat.memberships.app` scope
 *                              and `spaces/{space}/members/app` format.
 *
 *                              Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`. Please see
 *                              {@see ChatServiceClient::membershipName()} for help formatting this field.
 */
function delete_membership_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new DeleteMembershipRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Membership $response */
        $response = $chatServiceClient->deleteMembership($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::membershipName('[SPACE]', '[MEMBER]');

    delete_membership_sample($formattedName);
}

deleteMessage

Deletes a message.

For an example, see Delete a message.

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::deleteMessageAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteMessageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\DeleteMessageRequest;

/**
 * @param string $formattedName 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/workspace/chat/create-messages#name_a_created_message). Please see
 *                              {@see ChatServiceClient::messageName()} for help formatting this field.
 */
function delete_message_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new DeleteMessageRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $chatServiceClient->deleteMessage($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::messageName('[SPACE]', '[MESSAGE]');

    delete_message_sample($formattedName);
}

deleteReaction

Deletes a reaction to a message. Only unicode emojis are supported.

For an example, see Delete a reaction. Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::deleteReactionAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteReactionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\DeleteReactionRequest;

/**
 * @param string $formattedName Name of the reaction to delete.
 *
 *                              Format: `spaces/{space}/messages/{message}/reactions/{reaction}`
 *                              Please see {@see ChatServiceClient::reactionName()} for help formatting this field.
 */
function delete_reaction_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new DeleteReactionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $chatServiceClient->deleteReaction($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::reactionName('[SPACE]', '[MESSAGE]', '[REACTION]');

    delete_reaction_sample($formattedName);
}

deleteSpace

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

Requires user authentication from a user who has permission to delete the space.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::deleteSpaceAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteSpaceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\DeleteSpaceRequest;

/**
 * @param string $formattedName Resource name of the space to delete.
 *
 *                              Format: `spaces/{space}`
 *                              Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function delete_space_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new DeleteSpaceRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $chatServiceClient->deleteSpace($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::spaceName('[SPACE]');

    delete_space_sample($formattedName);
}

findDirectMessage

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

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

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

Requires user authentication or app authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::findDirectMessageAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\FindDirectMessageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Space
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\FindDirectMessageRequest;
use Google\Apps\Chat\V1\Space;

/**
 * @param string $name Resource name of the user to find direct message with.
 *
 *                     Format: `users/{user}`, where `{user}` is either the `id` for the
 *                     [person](https://developers.google.com/people/api/rest/v1/people) from the
 *                     People API, or the `id` for the
 *                     [user](https://developers.google.com/admin-sdk/directory/reference/rest/v1/users)
 *                     in the Directory API. For example, if the People API profile ID is
 *                     `123456789`, you can find a direct message with that person by using
 *                     `users/123456789` as the `name`. When [authenticated as a
 *                     user](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
 *                     you can use the email as an alias for `{user}`. For example,
 *                     `users/example@gmail.com` where `example@gmail.com` is the email of the
 *                     Google Chat user.
 */
function find_direct_message_sample(string $name): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new FindDirectMessageRequest())
        ->setName($name);

    // Call the API and handle any network failures.
    try {
        /** @var Space $response */
        $response = $chatServiceClient->findDirectMessage($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $name = '[NAME]';

    find_direct_message_sample($name);
}

getAttachment

Gets the metadata of a message attachment. The attachment data is fetched using the media API.

For an example, see Get metadata about a message attachment. Requires app authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::getAttachmentAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\GetAttachmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Attachment
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Attachment;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetAttachmentRequest;

/**
 * @param string $formattedName Resource name of the attachment, in the form
 *                              `spaces/{space}/messages/{message}/attachments/{attachment}`. Please see
 *                              {@see ChatServiceClient::attachmentName()} for help formatting this field.
 */
function get_attachment_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetAttachmentRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Attachment $response */
        $response = $chatServiceClient->getAttachment($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::attachmentName('[SPACE]', '[MESSAGE]', '[ATTACHMENT]');

    get_attachment_sample($formattedName);
}

getMembership

Parameters
Name Description
request Google\Apps\Chat\V1\GetMembershipRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Membership
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetMembershipRequest;
use Google\Apps\Chat\V1\Membership;

/**
 * @param string $formattedName Resource name of the membership to retrieve.
 *
 *                              To get the app's own membership [by using user
 *                              authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
 *                              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/workspace/chat/authenticate-authorize-chat-user),
 *                              you can use the user's email as an alias for `{member}`. For example,
 *                              `spaces/{space}/members/example@gmail.com` where `example@gmail.com` is the
 *                              email of the Google Chat user. Please see
 *                              {@see ChatServiceClient::membershipName()} for help formatting this field.
 */
function get_membership_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetMembershipRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Membership $response */
        $response = $chatServiceClient->getMembership($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::membershipName('[SPACE]', '[MEMBER]');

    get_membership_sample($formattedName);
}

getMessage

Returns details about a message.

For an example, see Get details about a message.

Requires authentication. Supports app authentication and user authentication.

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::getMessageAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\GetMessageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Message
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetMessageRequest;
use Google\Apps\Chat\V1\Message;

/**
 * @param string $formattedName 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/workspace/chat/create-messages#name_a_created_message). Please see
 *                              {@see ChatServiceClient::messageName()} for help formatting this field.
 */
function get_message_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetMessageRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Message $response */
        $response = $chatServiceClient->getMessage($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::messageName('[SPACE]', '[MESSAGE]');

    get_message_sample($formattedName);
}

getSpace

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

Requires authentication. Supports app authentication and user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::getSpaceAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\GetSpaceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Space
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetSpaceRequest;
use Google\Apps\Chat\V1\Space;

/**
 * @param string $formattedName Resource name of the space, in the form `spaces/{space}`.
 *
 *                              Format: `spaces/{space}`
 *                              Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function get_space_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetSpaceRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Space $response */
        $response = $chatServiceClient->getSpace($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::spaceName('[SPACE]');

    get_space_sample($formattedName);
}

getSpaceEvent

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

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

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

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::getSpaceEventAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\GetSpaceEventRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\SpaceEvent
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetSpaceEventRequest;
use Google\Apps\Chat\V1\SpaceEvent;

/**
 * @param string $formattedName The resource name of the space event.
 *
 *                              Format: `spaces/{space}/spaceEvents/{spaceEvent}`
 *                              Please see {@see ChatServiceClient::spaceEventName()} for help formatting this field.
 */
function get_space_event_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetSpaceEventRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var SpaceEvent $response */
        $response = $chatServiceClient->getSpaceEvent($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::spaceEventName('[SPACE]', '[SPACE_EVENT]');

    get_space_event_sample($formattedName);
}

getSpaceReadState

Returns details about a user's read state within a space, used to identify read and unread messages. For an example, see Get details about a user's space read state.

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::getSpaceReadStateAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\GetSpaceReadStateRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\SpaceReadState
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetSpaceReadStateRequest;
use Google\Apps\Chat\V1\SpaceReadState;

/**
 * @param string $formattedName Resource name of the space read state to retrieve.
 *
 *                              Only supports getting read state for the calling user.
 *
 *                              To refer to the calling user, set one of the following:
 *
 *                              - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
 *
 *                              - Their Workspace email address. For example,
 *                              `users/user@example.com/spaces/{space}/spaceReadState`.
 *
 *                              - Their user id. For example,
 *                              `users/123456789/spaces/{space}/spaceReadState`.
 *
 *                              Format: users/{user}/spaces/{space}/spaceReadState
 *                              Please see {@see ChatServiceClient::spaceReadStateName()} for help formatting this field.
 */
function get_space_read_state_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetSpaceReadStateRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var SpaceReadState $response */
        $response = $chatServiceClient->getSpaceReadState($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::spaceReadStateName('[USER]', '[SPACE]');

    get_space_read_state_sample($formattedName);
}

getThreadReadState

Returns details about a user's read state within a thread, used to identify read and unread messages. For an example, see Get details about a user's thread read state.

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::getThreadReadStateAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\GetThreadReadStateRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\ThreadReadState
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetThreadReadStateRequest;
use Google\Apps\Chat\V1\ThreadReadState;

/**
 * @param string $formattedName Resource name of the thread read state to retrieve.
 *
 *                              Only supports getting read state for the calling user.
 *
 *                              To refer to the calling user, set one of the following:
 *
 *                              - The `me` alias. For example,
 *                              `users/me/spaces/{space}/threads/{thread}/threadReadState`.
 *
 *                              - Their Workspace email address. For example,
 *                              `users/user@example.com/spaces/{space}/threads/{thread}/threadReadState`.
 *
 *                              - Their user id. For example,
 *                              `users/123456789/spaces/{space}/threads/{thread}/threadReadState`.
 *
 *                              Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState
 *                              Please see {@see ChatServiceClient::threadReadStateName()} for help formatting this field.
 */
function get_thread_read_state_sample(string $formattedName): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new GetThreadReadStateRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var ThreadReadState $response */
        $response = $chatServiceClient->getThreadReadState($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = ChatServiceClient::threadReadStateName('[USER]', '[SPACE]', '[THREAD]');

    get_thread_read_state_sample($formattedName);
}

listMemberships

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

Requires authentication. Supports app authentication and user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::listMembershipsAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\ListMembershipsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\ListMembershipsRequest;
use Google\Apps\Chat\V1\Membership;

/**
 * @param string $formattedParent The resource name of the space for which to fetch a membership
 *                                list.
 *
 *                                Format: spaces/{space}
 *                                Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function list_memberships_sample(string $formattedParent): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new ListMembershipsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $chatServiceClient->listMemberships($request);

        /** @var Membership $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::spaceName('[SPACE]');

    list_memberships_sample($formattedParent);
}

listMessages

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}.

For an example, see List messages. Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::listMessagesAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\ListMessagesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\ListMessagesRequest;
use Google\Apps\Chat\V1\Message;

/**
 * @param string $formattedParent The resource name of the space to list messages from.
 *
 *                                Format: `spaces/{space}`
 *                                Please see {@see ChatServiceClient::spaceName()} for help formatting this field.
 */
function list_messages_sample(string $formattedParent): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new ListMessagesRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $chatServiceClient->listMessages($request);

        /** @var Message $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::spaceName('[SPACE]');

    list_messages_sample($formattedParent);
}

listReactions

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

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::listReactionsAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\ListReactionsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\ListReactionsRequest;
use Google\Apps\Chat\V1\Reaction;

/**
 * @param string $formattedParent The message users reacted to.
 *
 *                                Format: `spaces/{space}/messages/{message}`
 *                                Please see {@see ChatServiceClient::messageName()} for help formatting this field.
 */
function list_reactions_sample(string $formattedParent): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new ListReactionsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $chatServiceClient->listReactions($request);

        /** @var Reaction $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::messageName('[SPACE]', '[MESSAGE]');

    list_reactions_sample($formattedParent);
}

listSpaceEvents

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

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

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::listSpaceEventsAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\ListSpaceEventsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\ListSpaceEventsRequest;
use Google\Apps\Chat\V1\SpaceEvent;

/**
 * @param string $formattedParent Resource name of the [Google Chat
 *                                space](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces)
 *                                where the events occurred.
 *
 *                                Format: `spaces/{space}`. Please see
 *                                {@see ChatServiceClient::spaceName()} for help formatting this field.
 * @param string $filter          A query filter.
 *
 *                                You must specify at least one event type (`event_type`)
 *                                using the has `:` operator. To filter by multiple event types, use the `OR`
 *                                operator. Omit batch event types in your filter. The request automatically
 *                                returns any related batch events. For example, if you filter by new
 *                                reactions
 *                                (`google.workspace.chat.reaction.v1.created`), the server also returns
 *                                batch new reactions events
 *                                (`google.workspace.chat.reaction.v1.batchCreated`). For a list of supported
 *                                event types, see the [`SpaceEvents` reference
 *                                documentation](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.event_type).
 *
 *                                Optionally, you can also filter by start time (`start_time`) and
 *                                end time (`end_time`):
 *
 *                                * `start_time`: Exclusive timestamp from which to start listing space
 *                                events.
 *                                You can list events that occurred up to 28 days ago. If unspecified, lists
 *                                space events from the past 28 days.
 *                                * `end_time`: Inclusive timestamp until which space events are listed.
 *                                If unspecified, lists events up to the time of the request.
 *
 *                                To specify a start or end time, use the equals `=` operator and format in
 *                                [RFC-3339](https://www.rfc-editor.org/rfc/rfc3339). To filter by both
 *                                `start_time` and `end_time`, use the `AND` operator.
 *
 *                                For example, the following queries are valid:
 *
 *                                ```
 *                                start_time="2023-08-23T19:20:33+00:00" AND
 *                                end_time="2023-08-23T19:21:54+00:00"
 *                                ```
 *                                ```
 *                                start_time="2023-08-23T19:20:33+00:00" AND
 *                                (event_types:"google.workspace.chat.space.v1.updated" OR
 *                                event_types:"google.workspace.chat.message.v1.created")
 *                                ```
 *
 *                                The following queries are invalid:
 *
 *                                ```
 *                                start_time="2023-08-23T19:20:33+00:00" OR
 *                                end_time="2023-08-23T19:21:54+00:00"
 *                                ```
 *                                ```
 *                                event_types:"google.workspace.chat.space.v1.updated" AND
 *                                event_types:"google.workspace.chat.message.v1.created"
 *                                ```
 *
 *                                Invalid queries are rejected by the server with an `INVALID_ARGUMENT`
 *                                error.
 */
function list_space_events_sample(string $formattedParent, string $filter): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new ListSpaceEventsRequest())
        ->setParent($formattedParent)
        ->setFilter($filter);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $chatServiceClient->listSpaceEvents($request);

        /** @var SpaceEvent $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::spaceName('[SPACE]');
    $filter = '[FILTER]';

    list_space_events_sample($formattedParent, $filter);
}

listSpaces

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

Requires authentication. Supports app authentication and user authentication.

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

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::listSpacesAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\ListSpacesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\ListSpacesRequest;
use Google\Apps\Chat\V1\Space;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_spaces_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = new ListSpacesRequest();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $chatServiceClient->listSpaces($request);

        /** @var Space $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

searchSpaces

Returns a list of spaces in a Google Workspace organization based on an administrator's search. Requires user authentication with administrator privileges.

In the request, set use_admin_access to true.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::searchSpacesAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\SearchSpacesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\SearchSpacesRequest;
use Google\Apps\Chat\V1\Space;

/**
 * @param string $query A search query.
 *
 *                      You can search by using the following parameters:
 *
 *                      - `create_time`
 *                      - `customer`
 *                      - `display_name`
 *                      - `external_user_allowed`
 *                      - `last_active_time`
 *                      - `space_history_state`
 *                      - `space_type`
 *
 *                      `create_time` and `last_active_time` accept a timestamp in
 *                      [RFC-3339](https://www.rfc-editor.org/rfc/rfc3339) format and the supported
 *                      comparison operators are: `=`, `<`, `>`, `<=`, `>=`.
 *
 *                      `customer` is required and is used to indicate which customer
 *                      to fetch spaces from. `customers/my_customer` is the only supported value.
 *
 *                      `display_name` only accepts the `HAS` (`:`) operator. The text to
 *                      match is first tokenized into tokens and each token is prefix-matched
 *                      case-insensitively and independently as a substring anywhere in the space's
 *                      `display_name`. For example, `Fun Eve` matches `Fun event` or `The
 *                      evening was fun`, but not `notFun event` or `even`.
 *
 *                      `external_user_allowed` accepts either `true` or `false`.
 *
 *                      `space_history_state` only accepts values from the [`historyState`]
 *                      (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.HistoryState)
 *                      field of a `space` resource.
 *
 *                      `space_type` is required and the only valid value is `SPACE`.
 *
 *                      Across different fields, only `AND` operators are supported. A valid
 *                      example is `space_type = "SPACE" AND display_name:"Hello"` and an invalid
 *                      example is `space_type = "SPACE" OR display_name:"Hello"`.
 *
 *                      Among the same field,
 *                      `space_type` doesn't support `AND` or `OR` operators.
 *                      `display_name`, 'space_history_state', and 'external_user_allowed' only
 *                      support `OR` operators.
 *                      `last_active_time` and `create_time` support both `AND` and `OR` operators.
 *                      `AND` can only be used to represent an interval, such as `last_active_time
 *                      < "2022-01-01T00:00:00+00:00" AND last_active_time >
 *                      "2023-01-01T00:00:00+00:00"`.
 *
 *                      The following example queries are valid:
 *
 *                      ```
 *                      customer = "customers/my_customer" AND space_type = "SPACE"
 *
 *                      customer = "customers/my_customer" AND space_type = "SPACE" AND
 *                      display_name:"Hello World"
 *
 *                      customer = "customers/my_customer" AND space_type = "SPACE" AND
 *                      (last_active_time < "2020-01-01T00:00:00+00:00" OR last_active_time >
 *                      "2022-01-01T00:00:00+00:00")
 *
 *                      customer = "customers/my_customer" AND space_type = "SPACE" AND
 *                      (display_name:"Hello World" OR display_name:"Fun event") AND
 *                      (last_active_time > "2020-01-01T00:00:00+00:00" AND last_active_time <
 *                      "2022-01-01T00:00:00+00:00")
 *
 *                      customer = "customers/my_customer" AND space_type = "SPACE" AND
 *                      (create_time > "2019-01-01T00:00:00+00:00" AND create_time <
 *                      "2020-01-01T00:00:00+00:00") AND (external_user_allowed = "true") AND
 *                      (space_history_state = "HISTORY_ON" OR space_history_state = "HISTORY_OFF")
 *                      ```
 */
function search_spaces_sample(string $query): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new SearchSpacesRequest())
        ->setQuery($query);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $chatServiceClient->searchSpaces($request);

        /** @var Space $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $query = '[QUERY]';

    search_spaces_sample($query);
}

setUpSpace

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

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

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

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

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

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

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

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

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::setUpSpaceAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\SetUpSpaceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Space
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\SetUpSpaceRequest;
use Google\Apps\Chat\V1\Space;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function set_up_space_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $space = new Space();
    $request = (new SetUpSpaceRequest())
        ->setSpace($space);

    // Call the API and handle any network failures.
    try {
        /** @var Space $response */
        $response = $chatServiceClient->setUpSpace($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

updateMembership

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateMembershipRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Membership
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\Membership;
use Google\Apps\Chat\V1\UpdateMembershipRequest;
use Google\Protobuf\FieldMask;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_membership_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $membership = new Membership();
    $updateMask = new FieldMask();
    $request = (new UpdateMembershipRequest())
        ->setMembership($membership)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var Membership $response */
        $response = $chatServiceClient->updateMembership($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

updateMessage

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

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::updateMessageAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateMessageRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Message
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\Message;
use Google\Apps\Chat\V1\UpdateMessageRequest;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_message_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $message = new Message();
    $request = (new UpdateMessageRequest())
        ->setMessage($message);

    // Call the API and handle any network failures.
    try {
        /** @var Message $response */
        $response = $chatServiceClient->updateMessage($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

updateSpace

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

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

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::updateSpaceAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateSpaceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\Space
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\Space;
use Google\Apps\Chat\V1\UpdateSpaceRequest;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_space_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $space = new Space();
    $request = (new UpdateSpaceRequest())
        ->setSpace($space);

    // Call the API and handle any network failures.
    try {
        /** @var Space $response */
        $response = $chatServiceClient->updateSpace($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

updateSpaceReadState

Updates a user's read state within a space, used to identify read and unread messages. For an example, see Update a user's space read state.

Requires user authentication.

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::updateSpaceReadStateAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateSpaceReadStateRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\SpaceReadState
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\SpaceReadState;
use Google\Apps\Chat\V1\UpdateSpaceReadStateRequest;
use Google\Protobuf\FieldMask;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_space_read_state_sample(): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $spaceReadState = new SpaceReadState();
    $updateMask = new FieldMask();
    $request = (new UpdateSpaceReadStateRequest())
        ->setSpaceReadState($spaceReadState)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var SpaceReadState $response */
        $response = $chatServiceClient->updateSpaceReadState($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

uploadAttachment

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

Requires user authentication.

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

The async variant is Google\Apps\Chat\V1\Client\ChatServiceClient::uploadAttachmentAsync() .

Parameters
Name Description
request Google\Apps\Chat\V1\UploadAttachmentRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Apps\Chat\V1\UploadAttachmentResponse
Example
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\UploadAttachmentRequest;
use Google\Apps\Chat\V1\UploadAttachmentResponse;

/**
 * @param string $formattedParent Resource name of the Chat space in which the attachment is
 *                                uploaded. Format "spaces/{space}". Please see
 *                                {@see ChatServiceClient::spaceName()} for help formatting this field.
 * @param string $filename        The filename of the attachment, including the file extension.
 */
function upload_attachment_sample(string $formattedParent, string $filename): void
{
    // Create a client.
    $chatServiceClient = new ChatServiceClient();

    // Prepare the request message.
    $request = (new UploadAttachmentRequest())
        ->setParent($formattedParent)
        ->setFilename($filename);

    // Call the API and handle any network failures.
    try {
        /** @var UploadAttachmentResponse $response */
        $response = $chatServiceClient->uploadAttachment($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ChatServiceClient::spaceName('[SPACE]');
    $filename = '[FILENAME]';

    upload_attachment_sample($formattedParent, $filename);
}

completeImportSpaceAsync

Parameters
Name Description
request Google\Apps\Chat\V1\CompleteImportSpaceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createMembershipAsync

Parameters
Name Description
request Google\Apps\Chat\V1\CreateMembershipRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createMessageAsync

Parameters
Name Description
request Google\Apps\Chat\V1\CreateMessageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createReactionAsync

Parameters
Name Description
request Google\Apps\Chat\V1\CreateReactionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createSpaceAsync

Parameters
Name Description
request Google\Apps\Chat\V1\CreateSpaceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteMembershipAsync

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteMembershipRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteMessageAsync

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteMessageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteReactionAsync

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteReactionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteSpaceAsync

Parameters
Name Description
request Google\Apps\Chat\V1\DeleteSpaceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

findDirectMessageAsync

Parameters
Name Description
request Google\Apps\Chat\V1\FindDirectMessageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getAttachmentAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getMembershipAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetMembershipRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getMessageAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetMessageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getSpaceAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetSpaceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getSpaceEventAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetSpaceEventRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getSpaceReadStateAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetSpaceReadStateRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getThreadReadStateAsync

Parameters
Name Description
request Google\Apps\Chat\V1\GetThreadReadStateRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listMembershipsAsync

Parameters
Name Description
request Google\Apps\Chat\V1\ListMembershipsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listMessagesAsync

Parameters
Name Description
request Google\Apps\Chat\V1\ListMessagesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listReactionsAsync

Parameters
Name Description
request Google\Apps\Chat\V1\ListReactionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listSpaceEventsAsync

Parameters
Name Description
request Google\Apps\Chat\V1\ListSpaceEventsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listSpacesAsync

Parameters
Name Description
request Google\Apps\Chat\V1\ListSpacesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

searchSpacesAsync

Parameters
Name Description
request Google\Apps\Chat\V1\SearchSpacesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

setUpSpaceAsync

Parameters
Name Description
request Google\Apps\Chat\V1\SetUpSpaceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateMembershipAsync

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateMembershipRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateMessageAsync

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateMessageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateSpaceAsync

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateSpaceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateSpaceReadStateAsync

Parameters
Name Description
request Google\Apps\Chat\V1\UpdateSpaceReadStateRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

uploadAttachmentAsync

Parameters
Name Description
request Google\Apps\Chat\V1\UploadAttachmentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

static::attachmentName

Formats a string containing the fully-qualified path to represent a attachment resource.

Parameters
Name Description
space string
message string
attachment string
Returns
Type Description
string The formatted attachment resource.

static::membershipName

Formats a string containing the fully-qualified path to represent a membership resource.

Parameters
Name Description
space string
member string
Returns
Type Description
string The formatted membership resource.

static::messageName

Formats a string containing the fully-qualified path to represent a message resource.

Parameters
Name Description
space string
message string
Returns
Type Description
string The formatted message resource.

static::quotedMessageMetadataName

Formats a string containing the fully-qualified path to represent a quoted_message_metadata resource.

Parameters
Name Description
space string
message string
quotedMessageMetadata string
Returns
Type Description
string The formatted quoted_message_metadata resource.

static::reactionName

Formats a string containing the fully-qualified path to represent a reaction resource.

Parameters
Name Description
space string
message string
reaction string
Returns
Type Description
string The formatted reaction resource.

static::spaceName

Formats a string containing the fully-qualified path to represent a space resource.

Parameter
Name Description
space string
Returns
Type Description
string The formatted space resource.

static::spaceEventName

Formats a string containing the fully-qualified path to represent a space_event resource.

Parameters
Name Description
space string
spaceEvent string
Returns
Type Description
string The formatted space_event resource.

static::spaceReadStateName

Formats a string containing the fully-qualified path to represent a space_read_state resource.

Parameters
Name Description
user string
space string
Returns
Type Description
string The formatted space_read_state resource.

static::threadName

Formats a string containing the fully-qualified path to represent a thread resource.

Parameters
Name Description
space string
thread string
Returns
Type Description
string The formatted thread resource.

static::threadReadStateName

Formats a string containing the fully-qualified path to represent a thread_read_state resource.

Parameters
Name Description
user string
space string
thread string
Returns
Type Description
string The formatted thread_read_state resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • attachment: spaces/{space}/messages/{message}/attachments/{attachment}
  • membership: spaces/{space}/members/{member}
  • message: spaces/{space}/messages/{message}
  • quotedMessageMetadata: spaces/{space}/messages/{message}/quotedMessageMetadata/{quoted_message_metadata}
  • reaction: spaces/{space}/messages/{message}/reactions/{reaction}
  • space: spaces/{space}
  • spaceEvent: spaces/{space}/spaceEvents/{space_event}
  • spaceReadState: users/{user}/spaces/{space}/spaceReadState
  • thread: spaces/{space}/threads/{thread}
  • threadReadState: users/{user}/spaces/{space}/threads/{thread}/threadReadState

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.