Service Usage API v1 - Package cloud.google.com/go/serviceusage/apiv1 (v0.89.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

Done reports whether the long-running operation has completed.

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

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

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

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

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

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

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

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

  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

  func 
  
 ( 
 c 
  
 * 
  Client 
 
 ) 
  
 Connection 
 () 
  
 * 
  grpc 
 
 . 
  ClientConn 
 
 

Connection returns a connection to the API service.

Deprecated.

func (*Client) DisableService

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

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

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

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.

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

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

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

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.

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

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

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

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

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.

Create a Mobile Website
View Site in Mobile | Classic
Share by: