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:
- 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/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
func
(
it
*
CapacityPlanIterator
)
Next
()
(
*
capacityplannerpb
.
CapacityPlan
,
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 (*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
func
(
c
*
CapacityPlanningClient
)
GetCapacityPlan
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
GetCapacityPlanRequest
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
CapacityPlan
,
error
)
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
func
(
c
*
CapacityPlanningClient
)
QueryCapacityPlanInsights
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
QueryCapacityPlanInsightsRequest
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
QueryCapacityPlanInsightsResponse
,
error
)
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
func
(
c
*
CapacityPlanningClient
)
QueryCapacityPlans
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
QueryCapacityPlansRequest
,
opts
...
gax
.
CallOption
)
*
CapacityPlanIterator
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
func
(
op
*
ExportForecastsOperation
)
Done
()
bool
Done reports whether the long-running operation has completed.
func (*ExportForecastsOperation) Metadata
func
(
op
*
ExportForecastsOperation
)
Metadata
()
(
*
capacityplannerpb
.
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 (*ExportForecastsOperation) Name
func
(
op
*
ExportForecastsOperation
)
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 (*ExportForecastsOperation) Poll
func
(
op
*
ExportForecastsOperation
)
Poll
(
ctx
context
.
Context
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
ExportForecastsResponse
,
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 (*ExportForecastsOperation) Wait
func
(
op
*
ExportForecastsOperation
)
Wait
(
ctx
context
.
Context
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
ExportForecastsResponse
,
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.
ExportReservationsUsageOperation
type
ExportReservationsUsageOperation
struct
{
// contains filtered or unexported fields
}
ExportReservationsUsageOperation manages a long-running operation from ExportReservationsUsage.
func (*ExportReservationsUsageOperation) Done
func
(
op
*
ExportReservationsUsageOperation
)
Done
()
bool
Done reports whether the long-running operation has completed.
func (*ExportReservationsUsageOperation) Metadata
func
(
op
*
ExportReservationsUsageOperation
)
Metadata
()
(
*
capacityplannerpb
.
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 (*ExportReservationsUsageOperation) Name
func
(
op
*
ExportReservationsUsageOperation
)
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 (*ExportReservationsUsageOperation) Poll
func
(
op
*
ExportReservationsUsageOperation
)
Poll
(
ctx
context
.
Context
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
ExportReservationsUsageResponse
,
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 (*ExportReservationsUsageOperation) Wait
func
(
op
*
ExportReservationsUsageOperation
)
Wait
(
ctx
context
.
Context
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
ExportReservationsUsageResponse
,
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.
ExportUsageHistoriesOperation
type
ExportUsageHistoriesOperation
struct
{
// contains filtered or unexported fields
}
ExportUsageHistoriesOperation manages a long-running operation from ExportUsageHistories.
func (*ExportUsageHistoriesOperation) Done
func
(
op
*
ExportUsageHistoriesOperation
)
Done
()
bool
Done reports whether the long-running operation has completed.
func (*ExportUsageHistoriesOperation) Metadata
func
(
op
*
ExportUsageHistoriesOperation
)
Metadata
()
(
*
capacityplannerpb
.
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 (*ExportUsageHistoriesOperation) Name
func
(
op
*
ExportUsageHistoriesOperation
)
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 (*ExportUsageHistoriesOperation) Poll
func
(
op
*
ExportUsageHistoriesOperation
)
Poll
(
ctx
context
.
Context
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
ExportUsageHistoriesResponse
,
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 (*ExportUsageHistoriesOperation) Wait
func
(
op
*
ExportUsageHistoriesOperation
)
Wait
(
ctx
context
.
Context
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
ExportUsageHistoriesResponse
,
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.
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
func
(
c
*
UsageClient
)
ExportForecasts
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
ExportForecastsRequest
,
opts
...
gax
.
CallOption
)
(
*
ExportForecastsOperation
,
error
)
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
func
(
c
*
UsageClient
)
ExportReservationsUsage
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
ExportReservationsUsageRequest
,
opts
...
gax
.
CallOption
)
(
*
ExportReservationsUsageOperation
,
error
)
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
func
(
c
*
UsageClient
)
ExportUsageHistories
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
ExportUsageHistoriesRequest
,
opts
...
gax
.
CallOption
)
(
*
ExportUsageHistoriesOperation
,
error
)
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
func
(
c
*
UsageClient
)
QueryForecasts
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
QueryForecastsRequest
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
QueryForecastsResponse
,
error
)
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
func
(
c
*
UsageClient
)
QueryReservations
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
QueryReservationsRequest
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
QueryReservationsResponse
,
error
)
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
func
(
c
*
UsageClient
)
QueryUsageHistories
(
ctx
context
.
Context
,
req
*
capacityplannerpb
.
QueryUsageHistoriesRequest
,
opts
...
gax
.
CallOption
)
(
*
capacityplannerpb
.
QueryUsageHistoriesResponse
,
error
)
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
}

