- 0.116.0 (latest)
- 0.115.1
- 0.114.0
- 0.113.0
- 0.112.2
- 0.111.0
- 0.110.10
- 0.109.0
- 0.108.0
- 0.107.0
- 0.106.0
- 0.105.0
- 0.104.0
- 0.103.0
- 0.102.1
- 0.101.1
- 0.100.2
- 0.99.0
- 0.98.0
- 0.97.0
- 0.96.0
- 0.95.0
- 0.94.1
- 0.93.3
- 0.92.3
- 0.91.1
- 0.90.0
- 0.89.0
- 0.88.0
- 0.87.0
- 0.86.0
- 0.85.0
- 0.84.0
- 0.83.0
- 0.82.0
- 0.81.0
- 0.80.0
- 0.79.0
- 0.78.0
- 0.77.0
- 0.76.0
- 0.75.0
Package serviceusage is an auto-generated package for the Service Usage API.
Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.
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.
For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
BatchEnableServicesOperation
type BatchEnableServicesOperation struct {
// contains filtered or unexported fields
}
BatchEnableServicesOperation manages a long-running operation from BatchEnableServices.
func (*BatchEnableServicesOperation) Done
func (op *BatchEnableServicesOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*BatchEnableServicesOperation) Metadata
func (op *BatchEnableServicesOperation) Metadata() (*serviceusagepb.OperationMetadata, error)
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 (*BatchEnableServicesOperation) Name
func (op *BatchEnableServicesOperation) Name() string
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 (*BatchEnableServicesOperation) Poll
func (op *BatchEnableServicesOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*serviceusagepb.BatchEnableServicesResponse, error)
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 (*BatchEnableServicesOperation) Wait
func (op *BatchEnableServicesOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*serviceusagepb.BatchEnableServicesResponse, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
CallOptions
type CallOptions struct {
EnableService []gax.CallOption
DisableService []gax.CallOption
GetService []gax.CallOption
ListServices []gax.CallOption
BatchEnableServices []gax.CallOption
BatchGetServices []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 Service Usage API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.
See Service Usage API (at https://cloud.google.com/service-usage/docs/overview)
func NewClient
NewClient creates a new service usage client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.
See Service Usage API (at https://cloud.google.com/service-usage/docs/overview)
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*Client) BatchEnableServices
func (c *Client) BatchEnableServices(ctx context.Context, req *serviceusagepb.BatchEnableServicesRequest, opts ...gax.CallOption) (*BatchEnableServicesOperation, error)
BatchEnableServices enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur. To enable a single service, use the EnableService method instead.
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
serviceusagepb "google.golang.org/genproto/googleapis/api/serviceusage/v1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &serviceusagepb.BatchEnableServicesRequest{
// TODO: Fill request struct fields.
}
op, err := c.BatchEnableServices(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) BatchEnableServicesOperation
func (c *Client) BatchEnableServicesOperation(name string) *BatchEnableServicesOperation
BatchEnableServicesOperation returns a new BatchEnableServicesOperation from a given name. The name must be that of a previously created BatchEnableServicesOperation, possibly from a different process.
func (*Client) BatchGetServices
func (c *Client) BatchGetServices(ctx context.Context, req *serviceusagepb.BatchGetServicesRequest, opts ...gax.CallOption) (*serviceusagepb.BatchGetServicesResponse, error)
BatchGetServices returns the service configurations and enabled states for a given list of services.
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
serviceusagepb "google.golang.org/genproto/googleapis/api/serviceusage/v1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &serviceusagepb.BatchGetServicesRequest{
// TODO: Fill request struct fields.
}
resp, err := c.BatchGetServices(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
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
func (c *Client) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*Client) DisableService
func (c *Client) DisableService(ctx context.Context, req *serviceusagepb.DisableServiceRequest, opts ...gax.CallOption) (*DisableServiceOperation, error)
DisableService disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause unexpected billing charges or security leaks.
It is not valid to call the disable method on a service that is not currently enabled. Callers will receive a FAILED_PRECONDITION status if the target service is not currently enabled.
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
serviceusagepb "google.golang.org/genproto/googleapis/api/serviceusage/v1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &serviceusagepb.DisableServiceRequest{
// TODO: Fill request struct fields.
}
op, err := c.DisableService(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) DisableServiceOperation
func (c *Client) DisableServiceOperation(name string) *DisableServiceOperation
DisableServiceOperation returns a new DisableServiceOperation from a given name. The name must be that of a previously created DisableServiceOperation, possibly from a different process.
func (*Client) EnableService
func (c *Client) EnableService(ctx context.Context, req *serviceusagepb.EnableServiceRequest, opts ...gax.CallOption) (*EnableServiceOperation, error)
EnableService enable a service so that it can be used with a project.
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
serviceusagepb "google.golang.org/genproto/googleapis/api/serviceusage/v1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &serviceusagepb.EnableServiceRequest{
// TODO: Fill request struct fields.
}
op, err := c.EnableService(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) EnableServiceOperation
func (c *Client) EnableServiceOperation(name string) *EnableServiceOperation
EnableServiceOperation returns a new EnableServiceOperation from a given name. The name must be that of a previously created EnableServiceOperation, possibly from a different process.
func (*Client) GetService
func (c *Client) GetService(ctx context.Context, req *serviceusagepb.GetServiceRequest, opts ...gax.CallOption) (*serviceusagepb.Service, error)
GetService returns the service configuration and enabled state for a given service.
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
serviceusagepb "google.golang.org/genproto/googleapis/api/serviceusage/v1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &serviceusagepb.GetServiceRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GetService(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) ListServices
func (c *Client) ListServices(ctx context.Context, req *serviceusagepb.ListServicesRequest, opts ...gax.CallOption) *ServiceIterator
ListServices list all services available to the specified project, and the current state of those services with respect to the project. The list includes all public services, all services for which the calling user has the servicemanagement.services.bind permission, and all services that have already been enabled on the project. The list can be filtered to only include services in a specific state, for example to only include services enabled on the project.
WARNING: If you need to query enabled services frequently or across an organization, you should use Cloud Asset Inventory API (at https://cloud.google.com/asset-inventory/docs/apis), which provides higher throughput and richer filtering capability.
Example
package main
import (
"context"
serviceusage "cloud.google.com/go/serviceusage/apiv1"
"google.golang.org/api/iterator"
serviceusagepb "google.golang.org/genproto/googleapis/api/serviceusage/v1"
)
func main() {
ctx := context.Background()
c, err := serviceusage.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &serviceusagepb.ListServicesRequest{
// TODO: Fill request struct fields.
}
it := c.ListServices(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
DisableServiceOperation
type DisableServiceOperation struct {
// contains filtered or unexported fields
}
DisableServiceOperation manages a long-running operation from DisableService.
func (*DisableServiceOperation) Done
func (op *DisableServiceOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*DisableServiceOperation) Metadata
func (op *DisableServiceOperation) Metadata() (*serviceusagepb.OperationMetadata, error)
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 (*DisableServiceOperation) Name
func (op *DisableServiceOperation) Name() string
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 (*DisableServiceOperation) Poll
func (op *DisableServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*serviceusagepb.DisableServiceResponse, error)
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 (*DisableServiceOperation) Wait
func (op *DisableServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*serviceusagepb.DisableServiceResponse, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
EnableServiceOperation
type EnableServiceOperation struct {
// contains filtered or unexported fields
}
EnableServiceOperation manages a long-running operation from EnableService.
func (*EnableServiceOperation) Done
func (op *EnableServiceOperation) Done() bool
Done reports whether the long-running operation has completed.
func (*EnableServiceOperation) Metadata
func (op *EnableServiceOperation) Metadata() (*serviceusagepb.OperationMetadata, error)
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 (*EnableServiceOperation) Name
func (op *EnableServiceOperation) Name() string
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 (*EnableServiceOperation) Poll
func (op *EnableServiceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*serviceusagepb.EnableServiceResponse, error)
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 (*EnableServiceOperation) Wait
func (op *EnableServiceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*serviceusagepb.EnableServiceResponse, error)
Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
See documentation of Poll for error-handling information.
ServiceIterator
type ServiceIterator 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 []*serviceusagepb.Service, nextPageToken string, err error)
// contains filtered or unexported fields
}
ServiceIterator manages a stream of *serviceusagepb.Service.
func (*ServiceIterator) Next
func (it *ServiceIterator) Next() (*serviceusagepb.Service, 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 (*ServiceIterator) PageInfo
func (it *ServiceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.