Google Workspace Events API v1 - Package cloud.google.com/go/apps/events/subscriptions/apiv1 (v0.5.2)

Package subscriptions is an auto-generated package for the Google Workspace Events API.

The Google Workspace Events API lets you subscribe to events and manage change notifications across Google Workspace applications.

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.

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 := subscriptions.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.

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 := subscriptions.NewClient(ctx)
if err != nil {
    // TODO: Handle error.
}
defer c.Close()

req := &subscriptionspb.CreateSubscriptionRequest{
    // TODO: Fill request struct fields.
    // See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#CreateSubscriptionRequest.
}
op, err := c.CreateSubscription(ctx, req)
if err != nil {
    // TODO: Handle error.
}

resp, err := op.Wait(ctx)
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 {
	CreateSubscription     []gax.CallOption
	DeleteSubscription     []gax.CallOption
	GetSubscription        []gax.CallOption
	ListSubscriptions      []gax.CallOption
	UpdateSubscription     []gax.CallOption
	ReactivateSubscription []gax.CallOption
	GetOperation           []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

Client

type Client struct {

	// The call options for this service.
	CallOptions *CallOptions

	// LROClient is used internally to handle long-running operations.
	// It is exposed so that its CallOptions can be modified if required.
	// Users should not Close this client.
	LROClient *lroauto.OperationsClient
	// contains filtered or unexported fields
}

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

A service that manages subscriptions to Google Workspace events.

func NewClient

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

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

A service that manages subscriptions to Google Workspace events.

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/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 := subscriptions.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 subscriptions service rest client.

A service that manages subscriptions to Google Workspace events.

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/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 := subscriptions.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) 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) CreateSubscription

CreateSubscription creates a Google Workspace subscription. To learn how to use this method, see Create a Google Workspace subscription (at https://developers.google.com/workspace/events/guides/create-subscription).

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.CreateSubscriptionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#CreateSubscriptionRequest.
	}
	op, err := c.CreateSubscription(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) CreateSubscriptionOperation

func (c *Client) CreateSubscriptionOperation(name string) *CreateSubscriptionOperation

CreateSubscriptionOperation returns a new CreateSubscriptionOperation from a given name. The name must be that of a previously created CreateSubscriptionOperation, possibly from a different process.

func (*Client) DeleteSubscription

DeleteSubscription deletes a Google Workspace subscription. To learn how to use this method, see Delete a Google Workspace subscription (at https://developers.google.com/workspace/events/guides/delete-subscription).

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.DeleteSubscriptionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#DeleteSubscriptionRequest.
	}
	op, err := c.DeleteSubscription(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

func (*Client) DeleteSubscriptionOperation

func (c *Client) DeleteSubscriptionOperation(name string) *DeleteSubscriptionOperation

DeleteSubscriptionOperation returns a new DeleteSubscriptionOperation from a given name. The name must be that of a previously created DeleteSubscriptionOperation, possibly from a different process.

func (*Client) GetOperation

GetOperation is a utility method from google.longrunning.Operations.

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"

	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &longrunningpb.GetOperationRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
	}
	resp, err := c.GetOperation(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) GetSubscription

GetSubscription gets details about a Google Workspace subscription. To learn how to use this method, see Get details about a Google Workspace subscription (at https://developers.google.com/workspace/events/guides/get-subscription).

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.GetSubscriptionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#GetSubscriptionRequest.
	}
	resp, err := c.GetSubscription(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) ListSubscriptions

ListSubscriptions lists Google Workspace subscriptions. To learn how to use this method, see List Google Workspace subscriptions (at https://developers.google.com/workspace/events/guides/list-subscriptions).

Examples

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
	"google.golang.org/api/iterator"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.ListSubscriptionsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#ListSubscriptionsRequest.
	}
	it := c.ListSubscriptions(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != 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.(*subscriptionspb.ListSubscriptionsResponse)
	}
}
all
package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.ListSubscriptionsRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#ListSubscriptionsRequest.
	}
	for resp, err := range c.ListSubscriptions(ctx, req).All() {
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp
	}
}

func (*Client) ReactivateSubscription

ReactivateSubscription reactivates a suspended Google Workspace subscription.

This method resets your subscription’s State field to ACTIVE. Before you use this method, you must fix the error that suspended the subscription. To learn how to use this method, see Reactivate a Google Workspace subscription (at https://developers.google.com/workspace/events/guides/reactivate-subscription).

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.ReactivateSubscriptionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#ReactivateSubscriptionRequest.
	}
	op, err := c.ReactivateSubscription(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) ReactivateSubscriptionOperation

func (c *Client) ReactivateSubscriptionOperation(name string) *ReactivateSubscriptionOperation

ReactivateSubscriptionOperation returns a new ReactivateSubscriptionOperation from a given name. The name must be that of a previously created ReactivateSubscriptionOperation, possibly from a different process.

func (*Client) UpdateSubscription

UpdateSubscription updates or renews a Google Workspace subscription. To learn how to use this method, see Update or renew a Google Workspace subscription (at https://developers.google.com/workspace/events/guides/update-subscription).

Example

package main

import (
	"context"

	subscriptions "cloud.google.com/go/apps/events/subscriptions/apiv1"
	subscriptionspb "cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb"
)

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 := subscriptions.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &subscriptionspb.UpdateSubscriptionRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/apps/events/subscriptions/apiv1/subscriptionspb#UpdateSubscriptionRequest.
	}
	op, err := c.UpdateSubscription(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*Client) UpdateSubscriptionOperation

func (c *Client) UpdateSubscriptionOperation(name string) *UpdateSubscriptionOperation

UpdateSubscriptionOperation returns a new UpdateSubscriptionOperation from a given name. The name must be that of a previously created UpdateSubscriptionOperation, possibly from a different process.

CreateSubscriptionOperation

type CreateSubscriptionOperation struct {
	// contains filtered or unexported fields
}

CreateSubscriptionOperation manages a long-running operation from CreateSubscription.

func (*CreateSubscriptionOperation) Done

func (op *CreateSubscriptionOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*CreateSubscriptionOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*CreateSubscriptionOperation) Name

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*CreateSubscriptionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*CreateSubscriptionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

DeleteSubscriptionOperation

type DeleteSubscriptionOperation struct {
	// contains filtered or unexported fields
}

DeleteSubscriptionOperation manages a long-running operation from DeleteSubscription.

func (*DeleteSubscriptionOperation) Done

func (op *DeleteSubscriptionOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*DeleteSubscriptionOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*DeleteSubscriptionOperation) Name

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*DeleteSubscriptionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*DeleteSubscriptionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

ReactivateSubscriptionOperation

type ReactivateSubscriptionOperation struct {
	// contains filtered or unexported fields
}

ReactivateSubscriptionOperation manages a long-running operation from ReactivateSubscription.

func (*ReactivateSubscriptionOperation) Done

Done reports whether the long-running operation has completed.

func (*ReactivateSubscriptionOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*ReactivateSubscriptionOperation) Name

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*ReactivateSubscriptionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*ReactivateSubscriptionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.

SubscriptionIterator

type SubscriptionIterator struct {

	// 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.
	Response interface{}

	// 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.
	InternalFetch func(pageSize int, pageToken string) (results []*subscriptionspb.Subscription, nextPageToken string, err error)
	// contains filtered or unexported fields
}

SubscriptionIterator manages a stream of *subscriptionspb.Subscription.

func (*SubscriptionIterator) All

func (it *SubscriptionIterator) All() iter.Seq2[*subscriptionspb.Subscription, error]

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

func (*SubscriptionIterator) Next

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

func (*SubscriptionIterator) PageInfo

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

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

UpdateSubscriptionOperation

type UpdateSubscriptionOperation struct {
	// contains filtered or unexported fields
}

UpdateSubscriptionOperation manages a long-running operation from UpdateSubscription.

func (*UpdateSubscriptionOperation) Done

func (op *UpdateSubscriptionOperation) Done() bool

Done reports whether the long-running operation has completed.

func (*UpdateSubscriptionOperation) Metadata

Metadata returns metadata associated with the long-running operation. Metadata itself does not contact the server, but Poll does. To get the latest metadata, call this method after a successful call to Poll. If the metadata is not available, the returned metadata and error are both nil.

func (*UpdateSubscriptionOperation) Name

Name returns the name of the long-running operation. The name is assigned by the server and is unique within the service from which the operation is created.

func (*UpdateSubscriptionOperation) Poll

Poll fetches the latest state of the long-running operation.

Poll also fetches the latest metadata, which can be retrieved by Metadata.

If Poll fails, the error is returned and op is unmodified. If Poll succeeds and the operation has completed with failure, the error is returned and op.Done will return true. If Poll succeeds and the operation has completed successfully, op.Done will return true, and the response of the operation is returned. If Poll succeeds and the operation has not completed, the returned response and error are both nil.

func (*UpdateSubscriptionOperation) Wait

Wait blocks until the long-running operation is completed, returning the response and any errors encountered.

See documentation of Poll for error-handling information.