Documentation ¶
Overview ¶
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:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
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.
Index ¶
- func DefaultAuthScopes() []string
- type CallOptions
- type Client
- func (c *Client) Close() error
- func (c *Client) Connection() *grpc.ClientConndeprecated
- func (c *Client) CreateQuotaPreference(ctx context.Context, req *cloudquotaspb.CreateQuotaPreferenceRequest, ...) (*cloudquotaspb.QuotaPreference, error)
- func (c *Client) GetQuotaInfo(ctx context.Context, req *cloudquotaspb.GetQuotaInfoRequest, ...) (*cloudquotaspb.QuotaInfo, error)
- func (c *Client) GetQuotaPreference(ctx context.Context, req *cloudquotaspb.GetQuotaPreferenceRequest, ...) (*cloudquotaspb.QuotaPreference, error)
- func (c *Client) ListQuotaInfos(ctx context.Context, req *cloudquotaspb.ListQuotaInfosRequest, ...) *QuotaInfoIterator
- func (c *Client) ListQuotaPreferences(ctx context.Context, req *cloudquotaspb.ListQuotaPreferencesRequest, ...) *QuotaPreferenceIterator
- func (c *Client) UpdateQuotaPreference(ctx context.Context, req *cloudquotaspb.UpdateQuotaPreferenceRequest, ...) (*cloudquotaspb.QuotaPreference, error)
- type QuotaInfoIterator
- type QuotaPreferenceIterator
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type 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.
type 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 ¶
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 }
Output:
func NewRESTClient ¶
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 }
Output:
func (*Client) Close ¶
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 ¶
func (c *Client) CreateQuotaPreference(ctx context.Context, req *cloudquotaspb.CreateQuotaPreferenceRequest, opts ...gax.CallOption) (*cloudquotaspb.QuotaPreference, error)
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 }
Output:
func (*Client) GetQuotaInfo ¶
func (c *Client) GetQuotaInfo(ctx context.Context, req *cloudquotaspb.GetQuotaInfoRequest, opts ...gax.CallOption) (*cloudquotaspb.QuotaInfo, error)
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 }
Output:
func (*Client) GetQuotaPreference ¶
func (c *Client) GetQuotaPreference(ctx context.Context, req *cloudquotaspb.GetQuotaPreferenceRequest, opts ...gax.CallOption) (*cloudquotaspb.QuotaPreference, error)
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 }
Output:
func (*Client) ListQuotaInfos ¶
func (c *Client) ListQuotaInfos(ctx context.Context, req *cloudquotaspb.ListQuotaInfosRequest, opts ...gax.CallOption) *QuotaInfoIterator
ListQuotaInfos lists QuotaInfos of all quotas for a given project, folder or organization.
Example ¶
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) } }
Output:
Example (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 } }
Output:
func (*Client) ListQuotaPreferences ¶
func (c *Client) ListQuotaPreferences(ctx context.Context, req *cloudquotaspb.ListQuotaPreferencesRequest, opts ...gax.CallOption) *QuotaPreferenceIterator
ListQuotaPreferences lists QuotaPreferences in a given project, folder or organization.
Example ¶
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) } }
Output:
Example (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 } }
Output:
func (*Client) UpdateQuotaPreference ¶
func (c *Client) UpdateQuotaPreference(ctx context.Context, req *cloudquotaspb.UpdateQuotaPreferenceRequest, opts ...gax.CallOption) (*cloudquotaspb.QuotaPreference, error)
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 }
Output:
type 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 ¶ added in v1.1.1
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 ¶
func (it *QuotaInfoIterator) Next() (*cloudquotaspb.QuotaInfo, error)
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.
type 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 ¶ added in v1.1.1
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 ¶
func (it *QuotaPreferenceIterator) Next() (*cloudquotaspb.QuotaPreference, error)
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.