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

Beta

This library is covered by thePre-GA Offerings Terms of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see thelaunch stage descriptions.

Note: To get more information about this package, such as access to older versions, viewthis package on pkg.go.dev.

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

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

NOTE:Thispackageisinbeta.Itisnotstable,andmaybesubjecttochanges.

General documentation

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

Example usage

To get started with this package, create a client.

// go get cloud.google.com/go/chat/apiv1@latestctx:=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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp

Use of Context

The ctx passed to NewClient is used for authentication requests andfor 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

funcDefaultAuthScopes()[]string

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

CallOptions

typeCallOptionsstruct{CreateMessage[]gax.CallOptionListMessages[]gax.CallOptionListMemberships[]gax.CallOptionGetMembership[]gax.CallOptionGetMessage[]gax.CallOptionUpdateMessage[]gax.CallOptionDeleteMessage[]gax.CallOptionGetAttachment[]gax.CallOptionUploadAttachment[]gax.CallOptionListSpaces[]gax.CallOptionSearchSpaces[]gax.CallOptionGetSpace[]gax.CallOptionCreateSpace[]gax.CallOptionSetUpSpace[]gax.CallOptionUpdateSpace[]gax.CallOptionDeleteSpace[]gax.CallOptionCompleteImportSpace[]gax.CallOptionFindDirectMessage[]gax.CallOptionCreateMembership[]gax.CallOptionUpdateMembership[]gax.CallOptionDeleteMembership[]gax.CallOptionCreateReaction[]gax.CallOptionListReactions[]gax.CallOptionDeleteReaction[]gax.CallOptionCreateCustomEmoji[]gax.CallOptionGetCustomEmoji[]gax.CallOptionListCustomEmojis[]gax.CallOptionDeleteCustomEmoji[]gax.CallOptionGetSpaceReadState[]gax.CallOptionUpdateSpaceReadState[]gax.CallOptionGetThreadReadState[]gax.CallOptionGetSpaceEvent[]gax.CallOptionListSpaceEvents[]gax.CallOptionGetSpaceNotificationSetting[]gax.CallOptionUpdateSpaceNotificationSetting[]gax.CallOption}

CallOptions contains the retry settings for each method of Client.

Client

typeClientstruct{// 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 andintegrations on Google Chat Platform.

func NewClient

funcNewClient(ctxcontext.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 andintegrations on Google Chat Platform.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}

func NewRESTClient

funcNewRESTClient(ctxcontext.Context,opts...option.ClientOption)(*Client,error)

NewRESTClient creates a new chat service rest client.

Enables developers to build Chat apps andintegrations on Google Chat Platform.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1")funcmain(){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_Optionsc,err:=chat.NewRESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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 whenthe client is no longer required.

func (*Client) CompleteImportSpace

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

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)and domain-wide delegation with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.import

For more information, see Authorize GoogleChat apps to importdata (athttps://developers.google.com/workspace/chat/authorize-import).

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=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 alwaysreturn the same resource.

func (*Client) CreateCustomEmoji

CreateCustomEmoji creates a custom emoji.

Custom emojis are only available for Google Workspace accounts, and theadministrator must turn custom emojis on for the organization. For moreinformation, see Learn about custom emojis in GoogleChat (athttps://support.google.com/chat/answer/12800149) andManage custom emojipermissions (athttps://support.google.com/a/answer/12850085).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.customemojis

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) CreateMembership

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-acceptpolicy turned off, then they’re invited, and must accept the spaceinvitation before joining. Otherwise, creating a membership adds the memberdirectly to the specified space.

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with administrator approval (at https://support.google.com/a?p=chat-app-auth)and the authorization scope:  https://www.googleapis.com/auth/chat.app.membershipsUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.memberships  https://www.googleapis.com/auth/chat.memberships.app (to add the  calling app to the space)  https://www.googleapis.com/auth/chat.import (import mode spaces  only)  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  the following authorization scope is used:    https://www.googleapis.com/auth/chat.admin.memberships

App authentication is not supported for the following use cases:

Inviting users external to the Workspace organization that owns thespace.Adding a Google Group to a space.Adding a Chat app to a space.

For example usage, see:

Invite or add a user to aspace (at https://developers.google.com/workspace/chat/create-members#create-user-membership).Invite or add a Google Group to aspace (at https://developers.google.com/workspace/chat/create-members#create-group-membership).Add the Chat app to aspace (at https://developers.google.com/workspace/chat/create-members#create-membership-calling-api).

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) CreateMessage

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

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorization scope:  https://www.googleapis.com/auth/chat.botUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.messages.create  https://www.googleapis.com/auth/chat.messages  https://www.googleapis.com/auth/chat.import (import mode spaces  only)

Chat attributes the message sender differently depending on the type ofauthentication that you use in your request.

The following image shows how Chat attributes a message when you use appauthentication. Chat displays the Chat app as the messagesender. 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 userauthentication. Chat displays the user as the message sender and attributesthe Chat app to the message by displaying its name. The content of messagecan only contain text (text).

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

Forwebhook (athttps://developers.google.com/workspace/chat/quickstart/webhooks)requests, the response doesn’t contain the full message. The response onlypopulates the name and thread.name fields in addition to theinformation that was in the request.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) CreateReaction

CreateReaction creates a reaction and adds it to a message. For an example, seeAdd a reaction to amessage (athttps://developers.google.com/workspace/chat/create-reactions).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.messages.reactions.createhttps://www.googleapis.com/auth/chat.messages.reactionshttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.import (import mode spaces only)

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) CreateSpace

CreateSpace creates a space. Can be used to create a named space, or agroup chat in Import mode. For an example, see Create aspace (athttps://developers.google.com/workspace/chat/create-spaces).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with administrator approval (at https://support.google.com/a?p=chat-app-auth)and one of the following authorization scopes:  https://www.googleapis.com/auth/chat.app.spaces.create  https://www.googleapis.com/auth/chat.app.spacesUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.spaces.create  https://www.googleapis.com/auth/chat.spaces  https://www.googleapis.com/auth/chat.import (import mode spaces  only)

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

When authenticating as an app, the Chat app is added as a member of thespace. However, unlike human authentication, the Chat app is not added as aspace manager. By default, the Chat app can be removed from the space byall space members. To allow only space managers to remove the app from aspace, set space.permission_settings.manage_apps to managers_allowed.

Space membership upon creation depends on whether the space is created inImport mode:

Import mode: No members are created.All other modes:  The calling user is added as a member. This is:  The app itself when using app authentication.  The human user when using user authentication.

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

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) DeleteCustomEmoji

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

DeleteCustomEmoji deletes a custom emoji. By default, users can only delete custom emoji theycreated. Emoji managers (athttps://support.google.com/a/answer/12850085)assigned by the administrator can delete any custom emoji in theorganization. See Learn about custom emojis in GoogleChat (athttps://support.google.com/chat/answer/12800149).

Custom emojis are only available for Google Workspace accounts, and theadministrator must turn custom emojis on for the organization. For moreinformation, see Learn about custom emojis in GoogleChat (athttps://support.google.com/chat/answer/12800149) andManage custom emojipermissions (athttps://support.google.com/a/answer/12850085).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.customemojis

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}}

func (*Client) DeleteMembership

DeleteMembership deletes a membership. For an example, seeRemove a user or a Google Chat app from aspace (athttps://developers.google.com/workspace/chat/delete-members).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with administrator approval (at https://support.google.com/a?p=chat-app-auth)and the authorization scope:  https://www.googleapis.com/auth/chat.app.membershipsUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.memberships  https://www.googleapis.com/auth/chat.memberships.app (to remove  the calling app from the space)  https://www.googleapis.com/auth/chat.import (import mode spaces  only)  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  the following authorization scope is used:    https://www.googleapis.com/auth/chat.admin.memberships

App authentication is not supported for the following use cases:

Removing a Google Group from a space.Removing a Chat app from a space.

To delete memberships for space managers, the requestermust be a space manager. If you’re using appauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-app)the Chat app must be the space creator.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) DeleteMessage

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

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorization scope:  https://www.googleapis.com/auth/chat.botUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.messages  https://www.googleapis.com/auth/chat.import (import mode spaces  only)

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

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}}

func (*Client) DeleteReaction

DeleteReaction deletes a reaction to a message. For an example, seeDelete areaction (athttps://developers.google.com/workspace/chat/delete-reactions).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.messages.reactionshttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.import (import mode spaces only)

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}}

func (*Client) DeleteSpace

DeleteSpace deletes a named space. Always performs a cascading delete, which meansthat the space’s child resources—like messages posted in the space andmemberships in the space—are also deleted. For an example, seeDelete aspace (athttps://developers.google.com/workspace/chat/delete-spaces).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with administratorapproval (at https://support.google.com/a?p=chat-app-auth) and theauthorization scope:  https://www.googleapis.com/auth/chat.app.delete (only in  spaces the app created)Userauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.delete  https://www.googleapis.com/auth/chat.import (import mode spaces  only)  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  the following authorization scope is used:    https://www.googleapis.com/auth/chat.admin.delete

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}}

func (*Client) FindDirectMessage

FindDirectMessage returns the existing direct message with the specified user. If no directmessage space is found, returns a 404 NOT_FOUND error. For an example,seeFind a direct message (at /chat/api/guides/v1/spaces/find-direct-message).

With appauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-app),returns the direct message space between the specified user and the callingChat app.

With userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user),returns the direct message space between the specified user and theauthenticated user.

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorization scope:  https://www.googleapis.com/auth/chat.botUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.spaces.readonly  https://www.googleapis.com/auth/chat.spaces

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetAttachment

GetAttachment gets the metadata of a message attachment. The attachment data is fetchedusing the mediaAPI (athttps://developers.google.com/workspace/chat/api/reference/rest/v1/media/download).For an example, seeGet metadata about a messageattachment (athttps://developers.google.com/workspace/chat/get-media-attachments).

Requires appauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.bot

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetCustomEmoji

GetCustomEmoji returns details about a custom emoji.

Custom emojis are only available for Google Workspace accounts, and theadministrator must turn custom emojis on for the organization. For moreinformation, see Learn about custom emojis in GoogleChat (athttps://support.google.com/chat/answer/12800149) andManage custom emojipermissions (athttps://support.google.com/a/answer/12850085).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.customemojis.readonlyhttps://www.googleapis.com/auth/chat.customemojis

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetMembership

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

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.bot  https://www.googleapis.com/auth/chat.app.memberships (requires  administrator approval (at https://support.google.com/a?p=chat-app-auth))Userauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.memberships.readonly  https://www.googleapis.com/auth/chat.memberships  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  one of the following authorization scopes is used:    https://www.googleapis.com/auth/chat.admin.memberships.readonly    https://www.googleapis.com/auth/chat.admin.memberships

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetMessage

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

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorization scope:  https://www.googleapis.com/auth/chat.botUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.messages.readonly  https://www.googleapis.com/auth/chat.messages

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

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetSpace

GetSpace returns details about a space. For an example, seeGet details about aspace (athttps://developers.google.com/workspace/chat/get-spaces).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.bot  https://www.googleapis.com/auth/chat.app.spaces with administrator  approval (at https://support.google.com/a?p=chat-app-auth)Userauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.spaces.readonly  https://www.googleapis.com/auth/chat.spaces  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  one of the following authorization scopes is used:    https://www.googleapis.com/auth/chat.admin.spaces.readonly    https://www.googleapis.com/auth/chat.admin.spaces

App authentication has the following limitations:

space.access_settings is only populated when using thechat.app.spaces scope.space.predefind_permission_settings and space.permission_settings areonly populated when using the chat.app.spaces scope, and only forspaces the app created.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.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)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetSpaceEvent

GetSpaceEvent returns an event from a Google Chat space. The eventpayload (athttps://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_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 laterupdated, the server returns the updated Message resource in the eventpayload.

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

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with an authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes)appropriate for reading the requested data:

https://www.googleapis.com/auth/chat.spaces.readonlyhttps://www.googleapis.com/auth/chat.spaceshttps://www.googleapis.com/auth/chat.messages.readonlyhttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.messages.reactions.readonlyhttps://www.googleapis.com/auth/chat.messages.reactionshttps://www.googleapis.com/auth/chat.memberships.readonlyhttps://www.googleapis.com/auth/chat.memberships

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

For an example, see Get details about anevent from a Google Chatspace (athttps://developers.google.com/workspace/chat/get-space-event).

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.GetSpaceEventRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetSpaceEventRequest.}resp,err:=c.GetSpaceEvent(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetSpaceNotificationSetting

GetSpaceNotificationSetting gets the space notification setting. For an example, see Get thecaller’s space notificationsetting (athttps://developers.google.com/workspace/chat/get-space-notification-setting).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.users.spacesettings

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.GetSpaceNotificationSettingRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetSpaceNotificationSettingRequest.}resp,err:=c.GetSpaceNotificationSetting(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetSpaceReadState

GetSpaceReadState returns details about a user’s read state within a space, used to identifyread and unread messages. For an example, see Get details about a user’sspace readstate (athttps://developers.google.com/workspace/chat/get-space-read-state).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.users.readstate.readonlyhttps://www.googleapis.com/auth/chat.users.readstate

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.GetSpaceReadStateRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetSpaceReadStateRequest.}resp,err:=c.GetSpaceReadState(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) GetThreadReadState

GetThreadReadState returns details about a user’s read state within a thread, used to identifyread and unread messages. For an example, see Get details about a user’sthread readstate (athttps://developers.google.com/workspace/chat/get-thread-read-state).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.users.readstate.readonlyhttps://www.googleapis.com/auth/chat.users.readstate

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.GetThreadReadStateRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#GetThreadReadStateRequest.}resp,err:=c.GetThreadReadState(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) ListCustomEmojis

ListCustomEmojis lists custom emojis visible to the authenticated user.

Custom emojis are only available for Google Workspace accounts, and theadministrator must turn custom emojis on for the organization. For moreinformation, see Learn about custom emojis in GoogleChat (athttps://support.google.com/chat/answer/12800149) andManage custom emojipermissions (athttps://support.google.com/a/answer/12850085).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.customemojis.readonlyhttps://www.googleapis.com/auth/chat.customemojis

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListCustomEmojisRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListCustomEmojisRequest.}it:=c.ListCustomEmojis(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.ListCustomEmojisResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListCustomEmojisRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListCustomEmojisRequest.}forresp,err:=rangec.ListCustomEmojis(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListMemberships

ListMemberships lists memberships in a space. For an example, see List users and GoogleChat apps in aspace (athttps://developers.google.com/workspace/chat/list-members). Listingmemberships with appauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-app)lists memberships in spaces that the Chat app hasaccess to, but excludes Chat app memberships,including its own. Listing memberships withUserauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)lists memberships in spaces that the authenticated user has access to.

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.bot  https://www.googleapis.com/auth/chat.app.memberships (requires  administrator approval (at https://support.google.com/a?p=chat-app-auth))Userauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.memberships.readonly  https://www.googleapis.com/auth/chat.memberships  https://www.googleapis.com/auth/chat.import (import mode spaces  only)  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  one of the following authorization scopes is used:    https://www.googleapis.com/auth/chat.admin.memberships.readonly    https://www.googleapis.com/auth/chat.admin.memberships

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListMembershipsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListMembershipsRequest.}it:=c.ListMemberships(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.ListMembershipsResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListMembershipsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListMembershipsRequest.}forresp,err:=rangec.ListMemberships(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListMessages

ListMessages lists messages in a space that the caller is a member of, includingmessages from blocked members and spaces. If you list messages from aspace with no messages, the response is an empty object. When using aREST/HTTP interface, the response contains an empty JSON object, {}.For an example, seeListmessages (athttps://developers.google.com/workspace/chat/api/guides/v1/messages/list).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.messages.readonlyhttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.import (import mode spaces only)

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListMessagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListMessagesRequest.}it:=c.ListMessages(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.ListMessagesResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListMessagesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListMessagesRequest.}forresp,err:=rangec.ListMessages(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListReactions

ListReactions lists reactions to a message. For an example, seeList reactions for amessage (athttps://developers.google.com/workspace/chat/list-reactions).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.messages.reactions.readonlyhttps://www.googleapis.com/auth/chat.messages.reactionshttps://www.googleapis.com/auth/chat.messages.readonlyhttps://www.googleapis.com/auth/chat.messages

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListReactionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListReactionsRequest.}it:=c.ListReactions(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.ListReactionsResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListReactionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListReactionsRequest.}forresp,err:=rangec.ListReactions(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListSpaceEvents

ListSpaceEvents lists events from a Google Chat space. For each event, thepayload (athttps://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload)contains the most recent version of the Chat resource. For example, if youlist events about new space members, the server returns Membershipresources that contain the latest membership details. If new members wereremoved during the requested period, the event payload contains an emptyMembership resource.

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with an authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes)appropriate for reading the requested data:

https://www.googleapis.com/auth/chat.spaces.readonlyhttps://www.googleapis.com/auth/chat.spaceshttps://www.googleapis.com/auth/chat.messages.readonlyhttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.messages.reactions.readonlyhttps://www.googleapis.com/auth/chat.messages.reactionshttps://www.googleapis.com/auth/chat.memberships.readonlyhttps://www.googleapis.com/auth/chat.memberships

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

For an example, see List events from a Google Chatspace (athttps://developers.google.com/workspace/chat/list-space-events).

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListSpaceEventsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListSpaceEventsRequest.}it:=c.ListSpaceEvents(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.ListSpaceEventsResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListSpaceEventsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListSpaceEventsRequest.}forresp,err:=rangec.ListSpaceEvents(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) ListSpaces

ListSpaces lists spaces the caller is a member of. Group chats and DMs aren’t listeduntil the first message is sent. For an example, seeListspaces (athttps://developers.google.com/workspace/chat/list-spaces).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorization scope:  https://www.googleapis.com/auth/chat.botUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.spaces.readonly  https://www.googleapis.com/auth/chat.spaces

To list all named spaces by Google Workspace organization, use thespaces.search() (athttps://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search)method using Workspace administrator privileges instead.

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListSpacesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListSpacesRequest.}it:=c.ListSpaces(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.ListSpacesResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.ListSpacesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#ListSpacesRequest.}forresp,err:=rangec.ListSpaces(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) SearchSpaces

SearchSpaces returns a list of spaces in a Google Workspace organization based on anadministrator’s search.

Requires userauthentication with administratorprivileges (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user#admin-privileges)and one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.admin.spaces.readonlyhttps://www.googleapis.com/auth/chat.admin.spaces

In the request, set use_admin_access to true.

Examples

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb""google.golang.org/api/iterator")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.SearchSpacesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#SearchSpacesRequest.}it:=c.SearchSpaces(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*chatpb.SearchSpacesResponse)}}
all
packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.SearchSpacesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#SearchSpacesRequest.}forresp,err:=rangec.SearchSpaces(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}

func (*Client) SetUpSpace

SetUpSpace creates a space and adds specified users to it. The calling user isautomatically added to the space, and shouldn’t be specified as amembership in the request. For an example, seeSet up a space with initialmembers (athttps://developers.google.com/workspace/chat/set-up-spaces).

To specify the human members to add, add memberships with the appropriatemembership.member.name. To add a human user, use users/{user}, where{user} can be the email address for the user. For users in the sameWorkspace organization {user} can also be the id for the person fromthe 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.nameto users/user@example.com or users/123456789.

To specify the Google groups to add, add memberships with theappropriate membership.group_member.name. To add or invite a Googlegroup, use groups/{group}, where {group} is the id for the group fromthe Cloud Identity Groups API. For example, you can use Cloud IdentityGroups lookupAPI (athttps://cloud.google.com/identity/docs/reference/rest/v1/groups/lookup)to retrieve the ID 123456789 for group email group@example.com, thenyou can add the group to the space by setting themembership.group_member.name to groups/123456789. Group email is notsupported, 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 blockedby some members, or doesn’t have permission to add some members, thenthose members aren’t added to the created space.

To create a direct message (DM) between the calling user and another humanuser, specify exactly one membership to represent the human user. Ifone 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, setSpace.singleUserBotDm to true and don’t specify any memberships. Youcan only use this method to set up a DM with the calling app. To add thecalling app as a member of a space or an existing DM between two humanusers, seeInvite or add a user or app to aspace (athttps://developers.google.com/workspace/chat/create-members).

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

Spaces with threaded replies aren’t supported. If you receive the errormessage ALREADY_EXISTS when setting up a space, try a differentdisplayName. An existing space within the Google Workspace organizationmight already use this display name.

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.spaces.createhttps://www.googleapis.com/auth/chat.spaces

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.SetUpSpaceRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#SetUpSpaceRequest.}resp,err:=c.SetUpSpace(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) UpdateMembership

UpdateMembership updates a membership. For an example, see Update a user’s membership ina space (athttps://developers.google.com/workspace/chat/update-members).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with administratorapproval (at https://support.google.com/a?p=chat-app-auth) and theauthorization scope:  https://www.googleapis.com/auth/chat.app.memberships (only in  spaces the app created)Userauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.memberships  https://www.googleapis.com/auth/chat.import (import mode spaces  only)  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  the following authorization scope is used:    https://www.googleapis.com/auth/chat.admin.memberships

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.UpdateMembershipRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#UpdateMembershipRequest.}resp,err:=c.UpdateMembership(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) UpdateMessage

UpdateMessage updates a message. There’s a difference between the patch and updatemethods. The patchmethod uses a patch request while the update method uses a putrequest. We recommend using the patch method. For an example, seeUpdate amessage (athttps://developers.google.com/workspace/chat/update-messages).

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with the authorization scope:  https://www.googleapis.com/auth/chat.botUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.messages  https://www.googleapis.com/auth/chat.import (import mode spaces  only)

When using app authentication, requests can only update messagescreated by the calling Chat app.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.UpdateMessageRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#UpdateMessageRequest.}resp,err:=c.UpdateMessage(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) UpdateSpace

UpdateSpace updates a space. For an example, seeUpdate aspace (athttps://developers.google.com/workspace/chat/update-spaces).

If you’re updating the displayName field and receive the error messageALREADY_EXISTS, try a different display name… An existing space withinthe Google Workspace organization might already use this display name.

Supports the following types ofauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize):

Appauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)with administrator approval (at https://support.google.com/a?p=chat-app-auth)and one of the following authorization scopes:  https://www.googleapis.com/auth/chat.app.spacesUserauthentication (at https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorization scopes:  https://www.googleapis.com/auth/chat.spaces  https://www.googleapis.com/auth/chat.import (import mode spaces  only)  User authentication grants administrator privileges when an  administrator account authenticates, use_admin_access is true, and  the following authorization scopes is used:    https://www.googleapis.com/auth/chat.admin.spaces

App authentication has the following limitations:

To update either space.predefined_permission_settings orspace.permission_settings, the app must be the space creator.Updating the space.access_settings.audience is not supported for appauthentication.

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.UpdateSpaceRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#UpdateSpaceRequest.}resp,err:=c.UpdateSpace(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) UpdateSpaceNotificationSetting

UpdateSpaceNotificationSetting updates the space notification setting. For an example, see Updatethe caller’s space notificationsetting (athttps://developers.google.com/workspace/chat/update-space-notification-setting).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.users.spacesettings

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.UpdateSpaceNotificationSettingRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#UpdateSpaceNotificationSettingRequest.}resp,err:=c.UpdateSpaceNotificationSetting(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) UpdateSpaceReadState

UpdateSpaceReadState updates a user’s read state within a space, used to identify read andunread messages. For an example, see Update a user’s space readstate (athttps://developers.google.com/workspace/chat/update-space-read-state).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with the authorizationscope (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.users.readstate

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.UpdateSpaceReadStateRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#UpdateSpaceReadStateRequest.}resp,err:=c.UpdateSpaceReadState(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

func (*Client) UploadAttachment

UploadAttachment uploads an attachment. For an example, seeUpload media as a fileattachment (athttps://developers.google.com/workspace/chat/upload-media-attachments).

Requires userauthentication (athttps://developers.google.com/workspace/chat/authenticate-authorize-chat-user)with one of the following authorizationscopes (athttps://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):

https://www.googleapis.com/auth/chat.messages.createhttps://www.googleapis.com/auth/chat.messageshttps://www.googleapis.com/auth/chat.import (import mode spaces only)

You can upload attachments up to 200 MB. Certain file types aren’tsupported. For details, see File types blocked by GoogleChat (athttps://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat).

Example

packagemainimport("context"chat"cloud.google.com/go/chat/apiv1"chatpb"cloud.google.com/go/chat/apiv1/chatpb")funcmain(){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_Optionsc,err:=chat.NewClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&chatpb.UploadAttachmentRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/chat/apiv1/chatpb#UploadAttachmentRequest.}resp,err:=c.UploadAttachment(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

CustomEmojiIterator

typeCustomEmojiIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*chatpb.CustomEmoji,nextPageTokenstring,errerror)// contains filtered or unexported fields}

CustomEmojiIterator manages a stream of *chatpb.CustomEmoji.

func (*CustomEmojiIterator) All

func(it*CustomEmojiIterator)All()iter.Seq2[*chatpb.CustomEmoji,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*CustomEmojiIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*CustomEmojiIterator) PageInfo

func(it*CustomEmojiIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

MembershipIterator

typeMembershipIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*chatpb.Membership,nextPageTokenstring,errerror)// contains filtered or unexported fields}

MembershipIterator manages a stream of *chatpb.Membership.

func (*MembershipIterator) All

func(it*MembershipIterator)All()iter.Seq2[*chatpb.Membership,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*MembershipIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*MembershipIterator) PageInfo

func(it*MembershipIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

MessageIterator

typeMessageIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*chatpb.Message,nextPageTokenstring,errerror)// contains filtered or unexported fields}

MessageIterator manages a stream of *chatpb.Message.

func (*MessageIterator) All

func(it*MessageIterator)All()iter.Seq2[*chatpb.Message,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*MessageIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*MessageIterator) PageInfo

func(it*MessageIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

ReactionIterator

typeReactionIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*chatpb.Reaction,nextPageTokenstring,errerror)// contains filtered or unexported fields}

ReactionIterator manages a stream of *chatpb.Reaction.

func (*ReactionIterator) All

func(it*ReactionIterator)All()iter.Seq2[*chatpb.Reaction,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*ReactionIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*ReactionIterator) PageInfo

func(it*ReactionIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

SpaceEventIterator

typeSpaceEventIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*chatpb.SpaceEvent,nextPageTokenstring,errerror)// contains filtered or unexported fields}

SpaceEventIterator manages a stream of *chatpb.SpaceEvent.

func (*SpaceEventIterator) All

func(it*SpaceEventIterator)All()iter.Seq2[*chatpb.SpaceEvent,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*SpaceEventIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*SpaceEventIterator) PageInfo

func(it*SpaceEventIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

SpaceIterator

typeSpaceIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*chatpb.Space,nextPageTokenstring,errerror)// contains filtered or unexported fields}

SpaceIterator manages a stream of *chatpb.Space.

func (*SpaceIterator) All

func(it*SpaceIterator)All()iter.Seq2[*chatpb.Space,error]

All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.

func (*SpaceIterator) Next

func(it*SpaceIterator)Next()(*chatpb.Space,error)

Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.

func (*SpaceIterator) PageInfo

func(it*SpaceIterator)PageInfo()*iterator.PageInfo

PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.