Cloud Quotas API v1 - Package cloud.google.com/go/cloudquotas/apiv1 (v1.2.0)

Package cloudquotas is an auto-generated package for the Cloud Quotas API.

Cloud Quotas API provides Google Cloud service consumers with management and observability for resource usage, quotas, and restrictions of the services they consume.

General documentation

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

Example usage

To get started with this package, create a client.

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

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

Using the Client

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

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

Use of Context

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

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

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

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

CallOptions

type CallOptions struct {
	ListQuotaInfos        []gax.CallOption
	GetQuotaInfo          []gax.CallOption
	ListQuotaPreferences  []gax.CallOption
	GetQuotaPreference    []gax.CallOption
	CreateQuotaPreference []gax.CallOption
	UpdateQuotaPreference []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

Client

type Client struct {

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

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

The Cloud Quotas API is an infrastructure service for Google Cloud that lets service consumers list and manage their resource usage limits.

List/Get the metadata and current status of the quotas for a service.

Create/Update quota preferencess that declare the preferred quota values.

Check the status of a quota preference request.

List/Get pending and historical quota preference.

func NewClient

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

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

The Cloud Quotas API is an infrastructure service for Google Cloud that lets service consumers list and manage their resource usage limits.

List/Get the metadata and current status of the quotas for a service.

Create/Update quota preferencess that declare the preferred quota values.

Check the status of a quota preference request.

List/Get pending and historical quota preference.

Example

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/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 := cloudquotas.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 cloud quotas rest client.

The Cloud Quotas API is an infrastructure service for Google Cloud that lets service consumers list and manage their resource usage limits.

List/Get the metadata and current status of the quotas for a service.

Create/Update quota preferencess that declare the preferred quota values.

Check the status of a quota preference request.

List/Get pending and historical quota preference.

Example

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/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 := cloudquotas.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) CreateQuotaPreference

CreateQuotaPreference creates a new QuotaPreference that declares the desired value for a quota.

Example

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
)

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

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

func (*Client) GetQuotaInfo

GetQuotaInfo retrieve the QuotaInfo of a quota for a project, folder or organization.

Example

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
)

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

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

func (*Client) GetQuotaPreference

GetQuotaPreference gets details of a single QuotaPreference.

Example

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
)

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

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

func (*Client) ListQuotaInfos

ListQuotaInfos lists QuotaInfos of all quotas for a given project, folder or organization.

Examples

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
	"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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.ListQuotaInfosRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#ListQuotaInfosRequest.
	}
	it := c.ListQuotaInfos(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.(*cloudquotaspb.ListQuotaInfosResponse)
	}
}
all
package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
)

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

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

func (*Client) ListQuotaPreferences

ListQuotaPreferences lists QuotaPreferences in a given project, folder or organization.

Examples

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
	"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 := cloudquotas.NewClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &cloudquotaspb.ListQuotaPreferencesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb#ListQuotaPreferencesRequest.
	}
	it := c.ListQuotaPreferences(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.(*cloudquotaspb.ListQuotaPreferencesResponse)
	}
}
all
package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
)

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

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

func (*Client) UpdateQuotaPreference

UpdateQuotaPreference updates the parameters of a single QuotaPreference. It can updates the config in any states, not just the ones pending approval.

Example

package main

import (
	"context"

	cloudquotas "cloud.google.com/go/cloudquotas/apiv1"
	cloudquotaspb "cloud.google.com/go/cloudquotas/apiv1/cloudquotaspb"
)

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

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

QuotaInfoIterator

type QuotaInfoIterator 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 []*cloudquotaspb.QuotaInfo, nextPageToken string, err error)
	// contains filtered or unexported fields
}

QuotaInfoIterator manages a stream of *cloudquotaspb.QuotaInfo.

func (*QuotaInfoIterator) All

func (it *QuotaInfoIterator) All() iter.Seq2[*cloudquotaspb.QuotaInfo, error]

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

func (*QuotaInfoIterator) 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 (*QuotaInfoIterator) PageInfo

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

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

QuotaPreferenceIterator

type QuotaPreferenceIterator 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 []*cloudquotaspb.QuotaPreference, nextPageToken string, err error)
	// contains filtered or unexported fields
}

QuotaPreferenceIterator manages a stream of *cloudquotaspb.QuotaPreference.

func (*QuotaPreferenceIterator) All

func (it *QuotaPreferenceIterator) All() iter.Seq2[*cloudquotaspb.QuotaPreference, error]

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

func (*QuotaPreferenceIterator) 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 (*QuotaPreferenceIterator) PageInfo

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

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