Documentation
¶
Overview ¶
Package reservation is an auto-generated package for the BigQuery Reservation API.
A service to modify your BigQuery reservations.
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/bigquery/reservation/apiv1@latest
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client ¶
The following is an example of making an API call with the newly created client, mentioned above.
req := &reservationpb.CreateAssignmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateAssignmentRequest.
}
resp, err := c.CreateAssignment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Use of Context ¶
The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Index ¶
- func DefaultAuthScopes() []string
- type AssignmentIterator
- type CallOptions
- type CapacityCommitmentIterator
- type Client
- func (c *Client) Close() error
- func (c *Client) Connection() *grpc.ClientConndeprecated
- func (c *Client) CreateAssignment(ctx context.Context, req *reservationpb.CreateAssignmentRequest, ...) (*reservationpb.Assignment, error)
- func (c *Client) CreateCapacityCommitment(ctx context.Context, req *reservationpb.CreateCapacityCommitmentRequest, ...) (*reservationpb.CapacityCommitment, error)
- func (c *Client) CreateReservation(ctx context.Context, req *reservationpb.CreateReservationRequest, ...) (*reservationpb.Reservation, error)
- func (c *Client) CreateReservationGroup(ctx context.Context, req *reservationpb.CreateReservationGroupRequest, ...) (*reservationpb.ReservationGroup, error)
- func (c *Client) DeleteAssignment(ctx context.Context, req *reservationpb.DeleteAssignmentRequest, ...) error
- func (c *Client) DeleteCapacityCommitment(ctx context.Context, req *reservationpb.DeleteCapacityCommitmentRequest, ...) error
- func (c *Client) DeleteReservation(ctx context.Context, req *reservationpb.DeleteReservationRequest, ...) error
- func (c *Client) DeleteReservationGroup(ctx context.Context, req *reservationpb.DeleteReservationGroupRequest, ...) error
- func (c *Client) FailoverReservation(ctx context.Context, req *reservationpb.FailoverReservationRequest, ...) (*reservationpb.Reservation, error)
- func (c *Client) GetBiReservation(ctx context.Context, req *reservationpb.GetBiReservationRequest, ...) (*reservationpb.BiReservation, error)
- func (c *Client) GetCapacityCommitment(ctx context.Context, req *reservationpb.GetCapacityCommitmentRequest, ...) (*reservationpb.CapacityCommitment, error)
- func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *Client) GetReservation(ctx context.Context, req *reservationpb.GetReservationRequest, ...) (*reservationpb.Reservation, error)
- func (c *Client) GetReservationGroup(ctx context.Context, req *reservationpb.GetReservationGroupRequest, ...) (*reservationpb.ReservationGroup, error)
- func (c *Client) ListAssignments(ctx context.Context, req *reservationpb.ListAssignmentsRequest, ...) *AssignmentIterator
- func (c *Client) ListCapacityCommitments(ctx context.Context, req *reservationpb.ListCapacityCommitmentsRequest, ...) *CapacityCommitmentIterator
- func (c *Client) ListReservationGroups(ctx context.Context, req *reservationpb.ListReservationGroupsRequest, ...) *ReservationGroupIterator
- func (c *Client) ListReservations(ctx context.Context, req *reservationpb.ListReservationsRequest, ...) *ReservationIterator
- func (c *Client) MergeCapacityCommitments(ctx context.Context, req *reservationpb.MergeCapacityCommitmentsRequest, ...) (*reservationpb.CapacityCommitment, error)
- func (c *Client) MoveAssignment(ctx context.Context, req *reservationpb.MoveAssignmentRequest, ...) (*reservationpb.Assignment, error)
- func (c *Client) SearchAllAssignments(ctx context.Context, req *reservationpb.SearchAllAssignmentsRequest, ...) *AssignmentIterator
- func (c *Client) SearchAssignments(ctx context.Context, req *reservationpb.SearchAssignmentsRequest, ...) *AssignmentIteratordeprecated
- func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
- func (c *Client) SplitCapacityCommitment(ctx context.Context, req *reservationpb.SplitCapacityCommitmentRequest, ...) (*reservationpb.SplitCapacityCommitmentResponse, error)
- func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, ...) (*iampb.TestIamPermissionsResponse, error)
- func (c *Client) UpdateAssignment(ctx context.Context, req *reservationpb.UpdateAssignmentRequest, ...) (*reservationpb.Assignment, error)
- func (c *Client) UpdateBiReservation(ctx context.Context, req *reservationpb.UpdateBiReservationRequest, ...) (*reservationpb.BiReservation, error)
- func (c *Client) UpdateCapacityCommitment(ctx context.Context, req *reservationpb.UpdateCapacityCommitmentRequest, ...) (*reservationpb.CapacityCommitment, error)
- func (c *Client) UpdateReservation(ctx context.Context, req *reservationpb.UpdateReservationRequest, ...) (*reservationpb.Reservation, error)
- type ReservationGroupIterator
- type ReservationIterator
Examples ¶
- Client.CreateAssignment
- Client.CreateCapacityCommitment
- Client.CreateReservation
- Client.CreateReservationGroup
- Client.DeleteAssignment
- Client.DeleteCapacityCommitment
- Client.DeleteReservation
- Client.DeleteReservationGroup
- Client.FailoverReservation
- Client.GetBiReservation
- Client.GetCapacityCommitment
- Client.GetIamPolicy
- Client.GetReservation
- Client.GetReservationGroup
- Client.ListAssignments
- Client.ListAssignments (All)
- Client.ListCapacityCommitments
- Client.ListCapacityCommitments (All)
- Client.ListReservationGroups
- Client.ListReservationGroups (All)
- Client.ListReservations
- Client.ListReservations (All)
- Client.MergeCapacityCommitments
- Client.MoveAssignment
- Client.SearchAllAssignments
- Client.SearchAllAssignments (All)
- Client.SearchAssignments
- Client.SearchAssignments (All)
- Client.SetIamPolicy
- Client.SplitCapacityCommitment
- Client.TestIamPermissions
- Client.UpdateAssignment
- Client.UpdateBiReservation
- Client.UpdateCapacityCommitment
- Client.UpdateReservation
- NewClient
- NewRESTClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
Types ¶
type AssignmentIterator ¶
type AssignmentIterator 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 []*reservationpb.Assignment, nextPageToken string, err error)
// contains filtered or unexported fields
}
AssignmentIterator manages a stream of *reservationpb.Assignment.
func (*AssignmentIterator) All ¶ added in v1.63.0
func (it *AssignmentIterator) All() iter.Seq2[*reservationpb.Assignment, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AssignmentIterator) Next ¶
func (it *AssignmentIterator) Next() (*reservationpb.Assignment, 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 (*AssignmentIterator) PageInfo ¶
func (it *AssignmentIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type CallOptions ¶
type CallOptions struct {
CreateReservation []gax.CallOption
ListReservations []gax.CallOption
GetReservation []gax.CallOption
DeleteReservation []gax.CallOption
UpdateReservation []gax.CallOption
FailoverReservation []gax.CallOption
CreateCapacityCommitment []gax.CallOption
ListCapacityCommitments []gax.CallOption
GetCapacityCommitment []gax.CallOption
DeleteCapacityCommitment []gax.CallOption
UpdateCapacityCommitment []gax.CallOption
SplitCapacityCommitment []gax.CallOption
MergeCapacityCommitments []gax.CallOption
CreateAssignment []gax.CallOption
ListAssignments []gax.CallOption
DeleteAssignment []gax.CallOption
SearchAssignments []gax.CallOption
SearchAllAssignments []gax.CallOption
MoveAssignment []gax.CallOption
UpdateAssignment []gax.CallOption
GetBiReservation []gax.CallOption
UpdateBiReservation []gax.CallOption
GetIamPolicy []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
CreateReservationGroup []gax.CallOption
GetReservationGroup []gax.CallOption
DeleteReservationGroup []gax.CallOption
ListReservationGroups []gax.CallOption
}
CallOptions contains the retry settings for each method of Client.
type CapacityCommitmentIterator ¶
type CapacityCommitmentIterator 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 []*reservationpb.CapacityCommitment, nextPageToken string, err error)
// contains filtered or unexported fields
}
CapacityCommitmentIterator manages a stream of *reservationpb.CapacityCommitment.
func (*CapacityCommitmentIterator) All ¶ added in v1.63.0
func (it *CapacityCommitmentIterator) All() iter.Seq2[*reservationpb.CapacityCommitment, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*CapacityCommitmentIterator) Next ¶
func (it *CapacityCommitmentIterator) Next() (*reservationpb.CapacityCommitment, 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 (*CapacityCommitmentIterator) PageInfo ¶
func (it *CapacityCommitmentIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type Client ¶
type Client struct {
// The call options for this service.
CallOptions *CallOptions
// contains filtered or unexported fields
}
Client is a client for interacting with BigQuery Reservation API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
This API allows users to manage their BigQuery reservations.
A reservation provides computational resource guarantees, in the form of slots (at https://cloud.google.com/bigquery/docs/slots), to users. A slot is a unit of computational power in BigQuery, and serves as the basic unit of parallelism. In a scan of a multi-partitioned table, a single slot operates on a single partition of the table. A reservation resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/reservations/reservationName.
A capacity commitment is a way to purchase compute capacity for BigQuery jobs (in the form of slots) with some committed period of usage. A capacity commitment resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/capacityCommitments/id.
func NewClient ¶
NewClient creates a new reservation 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 manage their BigQuery reservations.
A reservation provides computational resource guarantees, in the form of slots (at https://cloud.google.com/bigquery/docs/slots), to users. A slot is a unit of computational power in BigQuery, and serves as the basic unit of parallelism. In a scan of a multi-partitioned table, a single slot operates on a single partition of the table. A reservation resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/reservations/reservationName.
A capacity commitment is a way to purchase compute capacity for BigQuery jobs (in the form of slots) with some committed period of usage. A capacity commitment resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/capacityCommitments/id.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewRESTClient ¶ added in v1.45.0
NewRESTClient creates a new reservation service rest client.
This API allows users to manage their BigQuery reservations.
A reservation provides computational resource guarantees, in the form of slots (at https://cloud.google.com/bigquery/docs/slots), to users. A slot is a unit of computational power in BigQuery, and serves as the basic unit of parallelism. In a scan of a multi-partitioned table, a single slot operates on a single partition of the table. A reservation resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/reservations/reservationName.
A capacity commitment is a way to purchase compute capacity for BigQuery jobs (in the form of slots) with some committed period of usage. A capacity commitment resource exists as a child resource of the admin project and location, e.g.: projects/myproject/locations/US/capacityCommitments/id.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := reservation.NewRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*Client) Close ¶
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*Client) Connection
deprecated
func (c *Client) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*Client) CreateAssignment ¶
func (c *Client) CreateAssignment(ctx context.Context, req *reservationpb.CreateAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
CreateAssignment creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation.
Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type.
Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query.
When creating assignments, it does not matter if other assignments exist at higher levels.
Example:
The organization organizationA contains two projects, project1 and project2. Assignments for all three entities (organizationA, project1, and project2) could all be created and mapped to the same or different reservations.
“None” assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a “None” assignment, use “none” as a reservation_id in the parent. Example parent: projects/myproject/locations/US/reservations/none.
Returns google.rpc.Code.PERMISSION_DENIED if user does not have ‘bigquery.admin’ permissions on the project using the reservation and the project that owns this reservation.
Returns google.rpc.Code.INVALID_ARGUMENT when location of the assignment does not match location of the reservation.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.CreateAssignmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateAssignmentRequest.
}
resp, err := c.CreateAssignment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) CreateCapacityCommitment ¶
func (c *Client) CreateCapacityCommitment(ctx context.Context, req *reservationpb.CreateCapacityCommitmentRequest, opts ...gax.CallOption) (*reservationpb.CapacityCommitment, error)
CreateCapacityCommitment creates a new capacity commitment resource.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.CreateCapacityCommitmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateCapacityCommitmentRequest.
}
resp, err := c.CreateCapacityCommitment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) CreateReservation ¶
func (c *Client) CreateReservation(ctx context.Context, req *reservationpb.CreateReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
CreateReservation creates a new reservation resource.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.CreateReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateReservationRequest.
}
resp, err := c.CreateReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) CreateReservationGroup ¶ added in v1.72.0
func (c *Client) CreateReservationGroup(ctx context.Context, req *reservationpb.CreateReservationGroupRequest, opts ...gax.CallOption) (*reservationpb.ReservationGroup, error)
CreateReservationGroup creates a new reservation group.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.CreateReservationGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#CreateReservationGroupRequest.
}
resp, err := c.CreateReservationGroup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) DeleteAssignment ¶
func (c *Client) DeleteAssignment(ctx context.Context, req *reservationpb.DeleteAssignmentRequest, opts ...gax.CallOption) error
DeleteAssignment deletes a assignment. No expansion will happen.
Example:
Organization organizationA contains two projects, project1 and project2. Reservation res1 exists and was created previously. CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>
In this example, deletion of the <organizationA, res1> assignment won’t affect the other assignment <project1, res1>. After said deletion, queries from project1 will still use res1 while queries from project2 will switch to use on-demand mode.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.DeleteAssignmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteAssignmentRequest.
}
err = c.DeleteAssignment(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) DeleteCapacityCommitment ¶
func (c *Client) DeleteCapacityCommitment(ctx context.Context, req *reservationpb.DeleteCapacityCommitmentRequest, opts ...gax.CallOption) error
DeleteCapacityCommitment deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code google.rpc.Code.FAILED_PRECONDITION.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.DeleteCapacityCommitmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteCapacityCommitmentRequest.
}
err = c.DeleteCapacityCommitment(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) DeleteReservation ¶
func (c *Client) DeleteReservation(ctx context.Context, req *reservationpb.DeleteReservationRequest, opts ...gax.CallOption) error
DeleteReservation deletes a reservation. Returns google.rpc.Code.FAILED_PRECONDITION when reservation has assignments.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.DeleteReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteReservationRequest.
}
err = c.DeleteReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) DeleteReservationGroup ¶ added in v1.72.0
func (c *Client) DeleteReservationGroup(ctx context.Context, req *reservationpb.DeleteReservationGroupRequest, opts ...gax.CallOption) error
DeleteReservationGroup deletes a reservation. Returns google.rpc.Code.FAILED_PRECONDITION when reservation has assignments.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.DeleteReservationGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#DeleteReservationGroupRequest.
}
err = c.DeleteReservationGroup(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*Client) FailoverReservation ¶ added in v1.65.0
func (c *Client) FailoverReservation(ctx context.Context, req *reservationpb.FailoverReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
FailoverReservation fail over a reservation to the secondary location. The operation should be done in the current secondary location, which will be promoted to the new primary location for the reservation. Attempting to failover a reservation in the current primary location will fail with the error code google.rpc.Code.FAILED_PRECONDITION.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.FailoverReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#FailoverReservationRequest.
}
resp, err := c.FailoverReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetBiReservation ¶
func (c *Client) GetBiReservation(ctx context.Context, req *reservationpb.GetBiReservationRequest, opts ...gax.CallOption) (*reservationpb.BiReservation, error)
GetBiReservation retrieves a BI reservation.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.GetBiReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetBiReservationRequest.
}
resp, err := c.GetBiReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetCapacityCommitment ¶
func (c *Client) GetCapacityCommitment(ctx context.Context, req *reservationpb.GetCapacityCommitmentRequest, opts ...gax.CallOption) (*reservationpb.CapacityCommitment, error)
GetCapacityCommitment returns information about the capacity commitment.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.GetCapacityCommitmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetCapacityCommitmentRequest.
}
resp, err := c.GetCapacityCommitment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetIamPolicy ¶ added in v1.72.0
func (c *Client) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May return:
ANOT_FOUND error if the resource doesn’t exist or you don’t have the permission to view it. An empty policy if the resource exists but doesn’t have a set policy.
Supported resources are:
Reservations ReservationAssignments
To call this method, you must have the following Google IAM permissions:
bigqueryreservation.reservations.getIamPolicy to get policies on reservations.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
iampb "cloud.google.com/go/iam/apiv1/iampb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &iampb.GetIamPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetReservation ¶
func (c *Client) GetReservation(ctx context.Context, req *reservationpb.GetReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
GetReservation returns information about the reservation.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.GetReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetReservationRequest.
}
resp, err := c.GetReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) GetReservationGroup ¶ added in v1.72.0
func (c *Client) GetReservationGroup(ctx context.Context, req *reservationpb.GetReservationGroupRequest, opts ...gax.CallOption) (*reservationpb.ReservationGroup, error)
GetReservationGroup returns information about the reservation group.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.GetReservationGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#GetReservationGroupRequest.
}
resp, err := c.GetReservationGroup(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) ListAssignments ¶
func (c *Client) ListAssignments(ctx context.Context, req *reservationpb.ListAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator
ListAssignments lists assignments.
Only explicitly created assignments will be returned.
Example:
Organization organizationA contains two projects, project1 and project2. Reservation res1 exists and was created previously. CreateAssignment was used previously to define the following associations between entities and reservations: <organizationA, res1> and <project1, res1>
In this example, ListAssignments will just return the above two assignments for reservation res1, and no expansion/merge will happen.
The wildcard “-” can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed.
Note "-" cannot be used for projects nor locations.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
"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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListAssignmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListAssignmentsRequest.
}
it := c.ListAssignments(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.(*reservationpb.ListAssignmentsResponse)
}
}
Example (All) ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListAssignmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListAssignmentsRequest.
}
for resp, err := range c.ListAssignments(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*Client) ListCapacityCommitments ¶
func (c *Client) ListCapacityCommitments(ctx context.Context, req *reservationpb.ListCapacityCommitmentsRequest, opts ...gax.CallOption) *CapacityCommitmentIterator
ListCapacityCommitments lists all the capacity commitments for the admin project.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
"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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListCapacityCommitmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListCapacityCommitmentsRequest.
}
it := c.ListCapacityCommitments(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.(*reservationpb.ListCapacityCommitmentsResponse)
}
}
Example (All) ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListCapacityCommitmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListCapacityCommitmentsRequest.
}
for resp, err := range c.ListCapacityCommitments(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*Client) ListReservationGroups ¶ added in v1.72.0
func (c *Client) ListReservationGroups(ctx context.Context, req *reservationpb.ListReservationGroupsRequest, opts ...gax.CallOption) *ReservationGroupIterator
ListReservationGroups lists all the reservation groups for the project in the specified location.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
"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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListReservationGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListReservationGroupsRequest.
}
it := c.ListReservationGroups(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.(*reservationpb.ListReservationGroupsResponse)
}
}
Example (All) ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListReservationGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListReservationGroupsRequest.
}
for resp, err := range c.ListReservationGroups(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*Client) ListReservations ¶
func (c *Client) ListReservations(ctx context.Context, req *reservationpb.ListReservationsRequest, opts ...gax.CallOption) *ReservationIterator
ListReservations lists all the reservations for the project in the specified location.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
"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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListReservationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListReservationsRequest.
}
it := c.ListReservations(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.(*reservationpb.ListReservationsResponse)
}
}
Example (All) ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.ListReservationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#ListReservationsRequest.
}
for resp, err := range c.ListReservations(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*Client) MergeCapacityCommitments ¶
func (c *Client) MergeCapacityCommitments(ctx context.Context, req *reservationpb.MergeCapacityCommitmentsRequest, opts ...gax.CallOption) (*reservationpb.CapacityCommitment, error)
MergeCapacityCommitments merges capacity commitments of the same plan into a single commitment.
The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments.
Attempting to merge capacity commitments of different plan will fail with the error code google.rpc.Code.FAILED_PRECONDITION.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.MergeCapacityCommitmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#MergeCapacityCommitmentsRequest.
}
resp, err := c.MergeCapacityCommitments(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) MoveAssignment ¶
func (c *Client) MoveAssignment(ctx context.Context, req *reservationpb.MoveAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
MoveAssignment moves an assignment under a new reservation.
This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.MoveAssignmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#MoveAssignmentRequest.
}
resp, err := c.MoveAssignment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) SearchAllAssignments ¶ added in v1.23.0
func (c *Client) SearchAllAssignments(ctx context.Context, req *reservationpb.SearchAllAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator
SearchAllAssignments looks up assignments for a specified resource for a particular region. If the request is about a project:
Assignments created on the project will be returned if they exist.
Otherwise assignments created on the closest ancestor will be returned.
Assignments for different JobTypes will all be returned.
The same logic applies if the request is about a folder.
If the request is about an organization, then assignments created on the organization will be returned (organization doesn’t have ancestors).
Comparing to ListAssignments, there are some behavior differences:
permission on the assignee will be verified in this API.
Hierarchy lookup (project->folder->organization) happens in this API.
Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
"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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.SearchAllAssignmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SearchAllAssignmentsRequest.
}
it := c.SearchAllAssignments(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.(*reservationpb.SearchAllAssignmentsResponse)
}
}
Example (All) ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.SearchAllAssignmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SearchAllAssignmentsRequest.
}
for resp, err := range c.SearchAllAssignments(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*Client) SearchAssignments
deprecated
func (c *Client) SearchAssignments(ctx context.Context, req *reservationpb.SearchAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator
SearchAssignments deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project:
Assignments created on the project will be returned if they exist.
Otherwise assignments created on the closest ancestor will be returned.
Assignments for different JobTypes will all be returned.
The same logic applies if the request is about a folder.
If the request is about an organization, then assignments created on the organization will be returned (organization doesn’t have ancestors).
Comparing to ListAssignments, there are some behavior differences:
permission on the assignee will be verified in this API.
Hierarchy lookup (project->folder->organization) happens in this API.
Parent here is projects/*/locations/*, instead of projects/*/locations/*reservations/*.
Note "-" cannot be used for projects nor locations.
Deprecated: SearchAssignments may be removed in a future version.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
"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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.SearchAssignmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SearchAssignmentsRequest.
}
it := c.SearchAssignments(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.(*reservationpb.SearchAssignmentsResponse)
}
}
Example (All) ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.SearchAssignmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SearchAssignmentsRequest.
}
for resp, err := range c.SearchAssignments(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*Client) SetIamPolicy ¶ added in v1.72.0
func (c *Client) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error)
SetIamPolicy sets an access control policy for a resource. Replaces any existing policy.
Supported resources are:
Reservations
To call this method, you must have the following Google IAM permissions:
bigqueryreservation.reservations.setIamPolicy to set policies on reservations.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
iampb "cloud.google.com/go/iam/apiv1/iampb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &iampb.SetIamPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) SplitCapacityCommitment ¶
func (c *Client) SplitCapacityCommitment(ctx context.Context, req *reservationpb.SplitCapacityCommitmentRequest, opts ...gax.CallOption) (*reservationpb.SplitCapacityCommitmentResponse, error)
SplitCapacityCommitment splits capacity commitment to two commitments of the same plan and commitment_end_time.
A common use case is to enable downgrading commitments.
For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.SplitCapacityCommitmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#SplitCapacityCommitmentRequest.
}
resp, err := c.SplitCapacityCommitment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) TestIamPermissions ¶ added in v1.72.0
func (c *Client) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
TestIamPermissions gets your permissions on a resource. Returns an empty set of permissions if the resource doesn’t exist.
Supported resources are:
Reservations
No Google IAM permissions are required to call this method.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
iampb "cloud.google.com/go/iam/apiv1/iampb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &iampb.TestIamPermissionsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) UpdateAssignment ¶ added in v1.32.0
func (c *Client) UpdateAssignment(ctx context.Context, req *reservationpb.UpdateAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
UpdateAssignment updates an existing assignment.
Only the priority field can be updated.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.UpdateAssignmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateAssignmentRequest.
}
resp, err := c.UpdateAssignment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) UpdateBiReservation ¶
func (c *Client) UpdateBiReservation(ctx context.Context, req *reservationpb.UpdateBiReservationRequest, opts ...gax.CallOption) (*reservationpb.BiReservation, error)
UpdateBiReservation updates a BI reservation.
Only fields specified in the field_mask are updated.
A singleton BI reservation always exists with default size 0. In order to reserve BI capacity it needs to be updated to an amount greater than 0. In order to release BI capacity reservation size must be set to 0.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.UpdateBiReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateBiReservationRequest.
}
resp, err := c.UpdateBiReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) UpdateCapacityCommitment ¶
func (c *Client) UpdateCapacityCommitment(ctx context.Context, req *reservationpb.UpdateCapacityCommitmentRequest, opts ...gax.CallOption) (*reservationpb.CapacityCommitment, error)
UpdateCapacityCommitment updates an existing capacity commitment.
Only plan and renewal_plan fields can be updated.
Plan can only be changed to a plan of a longer commitment period. Attempting to change to a plan with shorter commitment period will fail with the error code google.rpc.Code.FAILED_PRECONDITION.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.UpdateCapacityCommitmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateCapacityCommitmentRequest.
}
resp, err := c.UpdateCapacityCommitment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) UpdateReservation ¶
func (c *Client) UpdateReservation(ctx context.Context, req *reservationpb.UpdateReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
UpdateReservation updates an existing reservation resource.
Example ¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1"
reservationpb "cloud.google.com/go/bigquery/reservation/apiv1/reservationpb"
)
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 := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &reservationpb.UpdateReservationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1/reservationpb#UpdateReservationRequest.
}
resp, err := c.UpdateReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
type ReservationGroupIterator ¶ added in v1.72.0
type ReservationGroupIterator 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 []*reservationpb.ReservationGroup, nextPageToken string, err error)
// contains filtered or unexported fields
}
ReservationGroupIterator manages a stream of *reservationpb.ReservationGroup.
func (*ReservationGroupIterator) All ¶ added in v1.72.0
func (it *ReservationGroupIterator) All() iter.Seq2[*reservationpb.ReservationGroup, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ReservationGroupIterator) Next ¶ added in v1.72.0
func (it *ReservationGroupIterator) Next() (*reservationpb.ReservationGroup, 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 (*ReservationGroupIterator) PageInfo ¶ added in v1.72.0
func (it *ReservationGroupIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type ReservationIterator ¶
type ReservationIterator 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 []*reservationpb.Reservation, nextPageToken string, err error)
// contains filtered or unexported fields
}
ReservationIterator manages a stream of *reservationpb.Reservation.
func (*ReservationIterator) All ¶ added in v1.63.0
func (it *ReservationIterator) All() iter.Seq2[*reservationpb.Reservation, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ReservationIterator) Next ¶
func (it *ReservationIterator) Next() (*reservationpb.Reservation, 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 (*ReservationIterator) PageInfo ¶
func (it *ReservationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.