Capacity Planner API v1beta - Package cloud.google.com/go/capacityplanner/apiv1beta (v0.1.0)

Package capacityplanner is an auto-generated package for the Capacity Planner API.

Provides programmatic access to Capacity Planner features.

 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.

 // go get cloud.google.com/go/capacityplanner/apiv1beta@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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningClient 
 ( 
 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 
  
 := 
  
& capacityplannerpb 
 . 
 GetCapacityPlanRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#GetCapacityPlanRequest. 
 } 
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetCapacityPlan 
 ( 
 ctx 
 , 
  
 req 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 // TODO: Use resp. 
 _ 
  
 = 
  
 resp 

Use of Context

The ctx passed to NewCapacityPlanningClient 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.

CapacityPlanIterator

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

CapacityPlanIterator manages a stream of *capacityplannerpb.CapacityPlan.

func (*CapacityPlanIterator) All

  func 
  
 ( 
 it 
  
 * 
  CapacityPlanIterator 
 
 ) 
  
 All 
 () 
  
 iter 
 . 
 Seq2 
 [ 
 * 
 capacityplannerpb 
 . 
 CapacityPlan 
 , 
  
 error 
 ] 
 

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

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

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

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

CapacityPlanningCallOptions

  type 
  
 CapacityPlanningCallOptions 
  
 struct 
  
 { 
  
 GetCapacityPlan 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 QueryCapacityPlans 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 QueryCapacityPlanInsights 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

CapacityPlanningCallOptions contains the retry settings for each method of CapacityPlanningClient.

CapacityPlanningClient

  type 
  
 CapacityPlanningClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  CapacityPlanningCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

CapacityPlanningClient is a client for interacting with Capacity Planner API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

This API allows users to plan for GCP capacity associated with their projects. Users can request additional capacity for GCP resources such as VMs, PDs, etc.

func NewCapacityPlanningClient

  func 
  
 NewCapacityPlanningClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  CapacityPlanningClient 
 
 , 
  
  error 
 
 ) 
 

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

This API allows users to plan for GCP capacity associated with their projects. Users can request additional capacity for GCP resources such as VMs, PDs, etc.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func NewCapacityPlanningRESTClient

  func 
  
 NewCapacityPlanningRESTClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  CapacityPlanningClient 
 
 , 
  
  error 
 
 ) 
 

NewCapacityPlanningRESTClient creates a new capacity planning service rest client.

This API allows users to plan for GCP capacity associated with their projects. Users can request additional capacity for GCP resources such as VMs, PDs, etc.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningRESTClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*CapacityPlanningClient) Close

  func 
  
 ( 
 c 
  
 * 
  CapacityPlanningClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*CapacityPlanningClient) Connection (deprecated)

  func 
  
 ( 
 c 
  
 * 
  CapacityPlanningClient 
 
 ) 
  
 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 (*CapacityPlanningClient) GetCapacityPlan

GetCapacityPlan returns information about the capacity plan.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 GetCapacityPlanRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#GetCapacityPlanRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetCapacityPlan 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*CapacityPlanningClient) QueryCapacityPlanInsights

QueryCapacityPlanInsights query capacity plan insights that are in the parent parameter and match your specified filters.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 QueryCapacityPlanInsightsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#QueryCapacityPlanInsightsRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 QueryCapacityPlanInsights 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*CapacityPlanningClient) QueryCapacityPlans

QueryCapacityPlans returns a list of the capacity plans that are in the parent parameter and match your specified filters. (The maximum list length is limited by the pageSize parameter.)

Examples

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
  
 "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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 QueryCapacityPlansRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#QueryCapacityPlansRequest. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 QueryCapacityPlans 
 ( 
 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 
 .( 
 * 
 capacityplannerpb 
 . 
 QueryCapacityPlansResponse 
 ) 
  
 } 
 } 
 
all
  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
 NewCapacityPlanningClient 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 QueryCapacityPlansRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#QueryCapacityPlansRequest. 
  
 } 
  
 for 
  
 resp 
 , 
  
 err 
  
 := 
  
 range 
  
 c 
 . 
 QueryCapacityPlans 
 ( 
 ctx 
 , 
  
 req 
 ). 
 All 
 () 
  
 { 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error and break/return/continue. Iteration will stop after any error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

ExportForecastsOperation

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

ExportForecastsOperation manages a long-running operation from ExportForecasts.

func (*ExportForecastsOperation) 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 (*ExportForecastsOperation) 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 (*ExportForecastsOperation) 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 (*ExportForecastsOperation) 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.

ExportReservationsUsageOperation

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

ExportReservationsUsageOperation manages a long-running operation from ExportReservationsUsage.

func (*ExportReservationsUsageOperation) 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 (*ExportReservationsUsageOperation) 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 (*ExportReservationsUsageOperation) 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 (*ExportReservationsUsageOperation) 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.

ExportUsageHistoriesOperation

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

ExportUsageHistoriesOperation manages a long-running operation from ExportUsageHistories.

func (*ExportUsageHistoriesOperation) 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 (*ExportUsageHistoriesOperation) 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 (*ExportUsageHistoriesOperation) 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 (*ExportUsageHistoriesOperation) 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.

UsageCallOptions

  type 
  
 UsageCallOptions 
  
 struct 
  
 { 
  
 QueryUsageHistories 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 QueryForecasts 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 QueryReservations 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ExportUsageHistories 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ExportForecasts 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ExportReservationsUsage 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

UsageCallOptions contains the retry settings for each method of UsageClient.

UsageClient

  type 
  
 UsageClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  UsageCallOptions 
 
  
 // 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 
 } 
 

UsageClient is a client for interacting with Capacity Planner API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Provides access to historical and forecasted usage data.

func NewUsageClient

  func 
  
 NewUsageClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  UsageClient 
 
 , 
  
  error 
 
 ) 
 

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

Provides access to historical and forecasted usage data.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func NewUsageRESTClient

  func 
  
 NewUsageRESTClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 ( 
 * 
  UsageClient 
 
 , 
  
  error 
 
 ) 
 

NewUsageRESTClient creates a new usage service rest client.

Provides access to historical and forecasted usage data.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageRESTClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*UsageClient) Close

  func 
  
 ( 
 c 
  
 * 
  UsageClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*UsageClient) Connection (deprecated)

  func 
  
 ( 
 c 
  
 * 
  UsageClient 
 
 ) 
  
 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 (*UsageClient) ExportForecasts

ExportForecasts exports forecasted usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 ExportForecastsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#ExportForecastsRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ExportForecasts 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UsageClient) ExportForecastsOperation

  func 
  
 ( 
 c 
  
 * 
  UsageClient 
 
 ) 
  
 ExportForecastsOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  ExportForecastsOperation 
 
 

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

func (*UsageClient) ExportReservationsUsage

ExportReservationsUsage exports reservations usage data requested by user into either an existing Cloud Storage bucket or a new/existing BigQuery table.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 ExportReservationsUsageRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#ExportReservationsUsageRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ExportReservationsUsage 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UsageClient) ExportReservationsUsageOperation

  func 
  
 ( 
 c 
  
 * 
  UsageClient 
 
 ) 
  
 ExportReservationsUsageOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  ExportReservationsUsageOperation 
 
 

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

func (*UsageClient) ExportUsageHistories

ExportUsageHistories exports historical usage data requested by user into either an existing Cloud Storage bucket or a BigQuery table.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 ExportUsageHistoriesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#ExportUsageHistoriesRequest. 
  
 } 
  
 op 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ExportUsageHistories 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 op 
 . 
 Wait 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UsageClient) ExportUsageHistoriesOperation

  func 
  
 ( 
 c 
  
 * 
  UsageClient 
 
 ) 
  
 ExportUsageHistoriesOperation 
 ( 
 name 
  
  string 
 
 ) 
  
 * 
  ExportUsageHistoriesOperation 
 
 

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

func (*UsageClient) QueryForecasts

QueryForecasts returns a list of the forecasts that are in the parent parameter and match your specified filters.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 QueryForecastsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#QueryForecastsRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 QueryForecasts 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UsageClient) QueryReservations

QueryReservations returns a list of the reservations that are in the parent parameter and match your specified filters.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 QueryReservationsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#QueryReservationsRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 QueryReservations 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*UsageClient) QueryUsageHistories

QueryUsageHistories returns a list of the usage histories that are in the parent parameter and match your specified filters.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 capacityplanner 
  
 "cloud.google.com/go/capacityplanner/apiv1beta" 
  
 capacityplannerpb 
  
 "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb" 
 ) 
 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 
  
 := 
  
 capacityplanner 
 . 
  NewUsageClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 defer 
  
 c 
 . 
  Close 
 
 () 
  
 req 
  
 := 
  
& capacityplannerpb 
 . 
 QueryUsageHistoriesRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb#QueryUsageHistoriesRequest. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 QueryUsageHistories 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: