Google Chat API v1 - Package cloud.google.com/go/chat/apiv1 (v0.13.1)

Package chat is an auto-generated package for the Google Chat API.

The Google Chat API lets you build Chat apps to integrate your services with Google Chat and manage Chat resources such as spaces, members, and messages.

NOTE: This package is in beta. It is not stable, and may be subject to changes.

General documentation

For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/chat/apiv1@latest
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := chat.NewClient(ctx)
if err != nil {
    // TODO: Handle error.
}
defer c.Close()

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client, mentioned above.

req := &chatpb.CompleteImportSpaceRequest{
    // TODO: Fill request struct fields.
    // See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CompleteImportSpaceRequest.
}
resp, err := c.CompleteImportSpace(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

Use of Context

The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

CallOptions

type CallOptions struct {
	CreateMessage                  []gax.CallOption
	ListMessages                   []gax.CallOption
	ListMemberships                []gax.CallOption
	GetMembership                  []gax.CallOption
	GetMessage                     []gax.CallOption
	UpdateMessage                  []gax.CallOption
	DeleteMessage                  []gax.CallOption
	GetAttachment                  []gax.CallOption
	UploadAttachment               []gax.CallOption
	ListSpaces                     []gax.CallOption
	SearchSpaces                   []gax.CallOption
	GetSpace                       []gax.CallOption
	CreateSpace                    []gax.CallOption
	SetUpSpace                     []gax.CallOption
	UpdateSpace                    []gax.CallOption
	DeleteSpace                    []gax.CallOption
	CompleteImportSpace            []gax.CallOption
	FindDirectMessage              []gax.CallOption
	CreateMembership               []gax.CallOption
	UpdateMembership               []gax.CallOption
	DeleteMembership               []gax.CallOption
	CreateReaction                 []gax.CallOption
	ListReactions                  []gax.CallOption
	DeleteReaction                 []gax.CallOption
	CreateCustomEmoji              []gax.CallOption
	GetCustomEmoji                 []gax.CallOption
	ListCustomEmojis               []gax.CallOption
	DeleteCustomEmoji              []gax.CallOption
	GetSpaceReadState              []gax.CallOption
	UpdateSpaceReadState           []gax.CallOption
	GetThreadReadState             []gax.CallOption
	GetSpaceEvent                  []gax.CallOption
	ListSpaceEvents                []gax.CallOption
	GetSpaceNotificationSetting    []gax.CallOption
	UpdateSpaceNotificationSetting []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

Client

type Client struct {

	// The call options for this service.
	CallOptions *CallOptions
	// contains filtered or unexported fields
}

Client is a client for interacting with Google Chat API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

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

func NewClient

func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewClient creates a new chat service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

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

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func NewRESTClient

func NewRESTClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)

NewRESTClient creates a new chat service rest client.

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

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewRESTClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*Client) CompleteImportSpace

CompleteImportSpace completes the import process (at https://developers.google.com/workspace/chat/import-data) for the specified space and makes it visible to users.

Requires app authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) and domain-wide delegation. For more information, see Authorize Google Chat apps to import data (at https://developers.google.com/workspace/chat/authorize-import).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.CompleteImportSpaceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CompleteImportSpaceRequest.
	}
	resp, err := c.CompleteImportSpace(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) Connection (deprecated)

func (c *Client) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated: Connections are now pooled so this method does not always return the same resource.

func (*Client) CreateCustomEmoji

func (c *Client) CreateCustomEmoji(ctx context.Context, req *chatpb.CreateCustomEmojiRequest, opts ...gax.CallOption) (*chatpb.CustomEmoji, error)

CreateCustomEmoji creates a custom emoji.

Custom emojis are only available for Google Workspace accounts, and the administrator must turn custom emojis on for the organization. For more information, see Learn about custom emojis in Google Chat (at https://support.google.com/chat/answer/12800149) and Manage custom emoji permissions (at https://support.google.com/a/answer/12850085).

Requires user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.CreateCustomEmojiRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CreateCustomEmojiRequest.
	}
	resp, err := c.CreateCustomEmoji(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateMembership

func (c *Client) CreateMembership(ctx context.Context, req *chatpb.CreateMembershipRequest, opts ...gax.CallOption) (*chatpb.Membership, error)

CreateMembership creates a membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn’t supported. When creating a membership, if the specified member has their auto-accept policy turned off, then they’re invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space.

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
with administrator approval (at https://support.google.com/a?p=chat-app-auth)
in Developer Preview (at https://developers.google.com/workspace/preview)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
You can authenticate and authorize this method with administrator
privileges by setting the use_admin_access field in the request.

For example usage, see:

Invite or add a user to a
space (at https://developers.google.com/workspace/chat/create-members#create-user-membership).

Invite or add a Google Group to a
space (at https://developers.google.com/workspace/chat/create-members#create-group-membership).

Add the Chat app to a
space (at https://developers.google.com/workspace/chat/create-members#create-membership-calling-api).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.CreateMembershipRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CreateMembershipRequest.
	}
	resp, err := c.CreateMembership(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, req *chatpb.CreateMessageRequest, opts ...gax.CallOption) (*chatpb.Message, error)

CreateMessage creates a message in a Google Chat space. For an example, see Send a message (at https://developers.google.com/workspace/chat/create-messages).

The create() method requires either user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) or app authentication (at https://developers.google.com/workspace/chat/authorize-import). 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).

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

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

For webhook (at https://developers.google.com/workspace/chat/quickstart/webhooks) requests, the response doesn’t contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.CreateMessageRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CreateMessageRequest.
	}
	resp, err := c.CreateMessage(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateReaction

func (c *Client) CreateReaction(ctx context.Context, req *chatpb.CreateReactionRequest, opts ...gax.CallOption) (*chatpb.Reaction, error)

CreateReaction creates a reaction and adds it to a message. For an example, see Add a reaction to a message (at https://developers.google.com/workspace/chat/create-reactions).

Requires user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.CreateReactionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CreateReactionRequest.
	}
	resp, err := c.CreateReaction(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateSpace

func (c *Client) CreateSpace(ctx context.Context, req *chatpb.CreateSpaceRequest, opts ...gax.CallOption) (*chatpb.Space, error)

CreateSpace creates a space with no members. Can be used to create a named space, or a group chat in Import mode. For an example, see Create a space (at https://developers.google.com/workspace/chat/create-spaces).

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

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
with administrator approval (at https://support.google.com/a?p=chat-app-auth)
in Developer Preview (at https://developers.google.com/workspace/preview)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)

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

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.CreateSpaceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#CreateSpaceRequest.
	}
	resp, err := c.CreateSpace(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) DeleteCustomEmoji

func (c *Client) DeleteCustomEmoji(ctx context.Context, req *chatpb.DeleteCustomEmojiRequest, opts ...gax.CallOption) error

DeleteCustomEmoji deletes a custom emoji. By default, users can only delete custom emoji they created. Emoji managers (at https://support.google.com/a/answer/12850085) assigned by the administrator can delete any custom emoji in the organization. See Learn about custom emojis in Google Chat (at https://support.google.com/chat/answer/12800149).

Custom emojis are only available for Google Workspace accounts, and the administrator must turn custom emojis on for the organization. For more information, see Learn about custom emojis in Google Chat (at https://support.google.com/chat/answer/12800149) and Manage custom emoji permissions (at https://support.google.com/a/answer/12850085).

Requires user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.DeleteCustomEmojiRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#DeleteCustomEmojiRequest.
	}
	err = c.DeleteCustomEmoji(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeleteMembership

func (c *Client) DeleteMembership(ctx context.Context, req *chatpb.DeleteMembershipRequest, opts ...gax.CallOption) (*chatpb.Membership, error)

DeleteMembership deletes a membership. For an example, see Remove a user or a Google Chat app from a space (at https://developers.google.com/workspace/chat/delete-members).

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
with administrator approval (at https://support.google.com/a?p=chat-app-auth)
in Developer Preview (at https://developers.google.com/workspace/preview)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
You can authenticate and authorize this method with administrator
privileges by setting the use_admin_access field in the request.

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.DeleteMembershipRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#DeleteMembershipRequest.
	}
	resp, err := c.DeleteMembership(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, req *chatpb.DeleteMessageRequest, opts ...gax.CallOption) error

DeleteMessage deletes a message. For an example, see Delete a message (at https://developers.google.com/workspace/chat/delete-messages).

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)

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

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.DeleteMessageRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#DeleteMessageRequest.
	}
	err = c.DeleteMessage(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeleteReaction

func (c *Client) DeleteReaction(ctx context.Context, req *chatpb.DeleteReactionRequest, opts ...gax.CallOption) error

DeleteReaction deletes a reaction to a message. For an example, see Delete a reaction (at https://developers.google.com/workspace/chat/delete-reactions).

Requires user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.DeleteReactionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#DeleteReactionRequest.
	}
	err = c.DeleteReaction(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeleteSpace

func (c *Client) DeleteSpace(ctx context.Context, req *chatpb.DeleteSpaceRequest, opts ...gax.CallOption) error

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 (at https://developers.google.com/workspace/chat/delete-spaces).

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
with administrator approval (at https://support.google.com/a?p=chat-app-auth)
in Developer Preview (at https://developers.google.com/workspace/preview)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
You can authenticate and authorize this method with administrator
privileges by setting the use_admin_access field in the request.

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.DeleteSpaceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#DeleteSpaceRequest.
	}
	err = c.DeleteSpace(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) FindDirectMessage

func (c *Client) FindDirectMessage(ctx context.Context, req *chatpb.FindDirectMessageRequest, opts ...gax.CallOption) (*chatpb.Space, error)

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 (at /chat/api/guides/v1/spaces/find-direct-message).

With app authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app), returns the direct message space between the specified user and the calling Chat app.

With user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), returns the direct message space between the specified user and the authenticated user.

// Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.FindDirectMessageRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#FindDirectMessageRequest.
	}
	resp, err := c.FindDirectMessage(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetAttachment

func (c *Client) GetAttachment(ctx context.Context, req *chatpb.GetAttachmentRequest, opts ...gax.CallOption) (*chatpb.Attachment, error)

GetAttachment gets the metadata of a message attachment. The attachment data is fetched using the media API (at https://developers.google.com/workspace/chat/api/reference/rest/v1/media/download). For an example, see Get metadata about a message attachment (at https://developers.google.com/workspace/chat/get-media-attachments). Requires app authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.GetAttachmentRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetAttachmentRequest.
	}
	resp, err := c.GetAttachment(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetCustomEmoji

func (c *Client) GetCustomEmoji(ctx context.Context, req *chatpb.GetCustomEmojiRequest, opts ...gax.CallOption) (*chatpb.CustomEmoji, error)

GetCustomEmoji returns details about a custom emoji.

Custom emojis are only available for Google Workspace accounts, and the administrator must turn custom emojis on for the organization. For more information, see Learn about custom emojis in Google Chat (at https://support.google.com/chat/answer/12800149) and Manage custom emoji permissions (at https://support.google.com/a/answer/12850085).

Requires user authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.GetCustomEmojiRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetCustomEmojiRequest.
	}
	resp, err := c.GetCustomEmoji(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetMembership

func (c *Client) GetMembership(ctx context.Context, req *chatpb.GetMembershipRequest, opts ...gax.CallOption) (*chatpb.Membership, error)

GetMembership returns details about a membership. For an example, see Get details about a user’s or Google Chat app’s membership (at https://developers.google.com/workspace/chat/get-members).

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
You can authenticate and authorize this method with administrator
privileges by setting the use_admin_access field in the request.

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.GetMembershipRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetMembershipRequest.
	}
	resp, err := c.GetMembership(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, req *chatpb.GetMessageRequest, opts ...gax.CallOption) (*chatpb.Message, error)

GetMessage returns details about a message. For an example, see Get details about a message (at https://developers.google.com/workspace/chat/get-messages).

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)

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

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.GetMessageRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetMessageRequest.
	}
	resp, err := c.GetMessage(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetSpace

func (c *Client) GetSpace(ctx context.Context, req *chatpb.GetSpaceRequest, opts ...gax.CallOption) (*chatpb.Space, error)

GetSpace returns details about a space. For an example, see Get details about a space (at https://developers.google.com/workspace/chat/get-spaces).

Supports the following types of authentication (at https://developers.google.com/workspace/chat/authenticate-authorize):

App
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)

User
authentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
You can authenticate and authorize this method with administrator
privileges by setting the use_admin_access field in the request.

Example

package main

import (
	"context"

	chat "cloud.google.com/go/chat/apiv1"
	chatpb "cloud.google.com/go/chat/apiv1/chatpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := chat.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &chatpb.GetSpaceRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetSpaceRequest.
	}
	resp, err := c.GetSpace(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetSpaceEvent

func (c *Client) GetSpaceEvent(ctx context.Context, req *chatpb.GetSpaceEventRequest, opts ...gax.CallOption) (*chatpb.SpaceEvent, error)

GetSpaceEvent returns an event from a Google Chat space. The event payload (at