package reservation
import "cloud.google.com/go/bigquery/reservation/apiv1beta1"
Package reservation is an auto-generated package for the BigQuery Reservation API.
A service to modify your BigQuery flat-rate reservations.
NOTE: This package is in alpha. It is not stable, and is likely to change.
Use of Context
The ctx passed to NewClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
For information about setting deadlines, reusing contexts, and more please visit godoc.org/cloud.google.com/go.
Index ¶
- func DefaultAuthScopes() []string
- type AssignmentIterator
- func (it *AssignmentIterator) Next() (*reservationpb.Assignment, error)
- func (it *AssignmentIterator) PageInfo() *iterator.PageInfo
- type CallOptions
- type CapacityCommitmentIterator
- func (it *CapacityCommitmentIterator) Next() (*reservationpb.CapacityCommitment, error)
- func (it *CapacityCommitmentIterator) PageInfo() *iterator.PageInfo
- type Client
- func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error)
- func (c *Client) Close() error
- func (c *Client) Connection() *grpc.ClientConn
- func (c *Client) CreateAssignment(ctx context.Context, req *reservationpb.CreateAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
- func (c *Client) CreateReservation(ctx context.Context, req *reservationpb.CreateReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
- func (c *Client) DeleteAssignment(ctx context.Context, req *reservationpb.DeleteAssignmentRequest, opts ...gax.CallOption) error
- func (c *Client) DeleteCapacityCommitment(ctx context.Context, req *reservationpb.DeleteCapacityCommitmentRequest, opts ...gax.CallOption) error
- func (c *Client) DeleteReservation(ctx context.Context, req *reservationpb.DeleteReservationRequest, opts ...gax.CallOption) error
- func (c *Client) GetCapacityCommitment(ctx context.Context, req *reservationpb.GetCapacityCommitmentRequest, opts ...gax.CallOption) (*reservationpb.CapacityCommitment, error)
- func (c *Client) GetReservation(ctx context.Context, req *reservationpb.GetReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
- func (c *Client) ListAssignments(ctx context.Context, req *reservationpb.ListAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator
- func (c *Client) ListCapacityCommitments(ctx context.Context, req *reservationpb.ListCapacityCommitmentsRequest, opts ...gax.CallOption) *CapacityCommitmentIterator
- func (c *Client) ListReservations(ctx context.Context, req *reservationpb.ListReservationsRequest, opts ...gax.CallOption) *ReservationIterator
- func (c *Client) MoveAssignment(ctx context.Context, req *reservationpb.MoveAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
- func (c *Client) SearchAssignments(ctx context.Context, req *reservationpb.SearchAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator
- func (c *Client) UpdateReservation(ctx context.Context, req *reservationpb.UpdateReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error)
- type ReservationIterator
Examples ¶
- Client.CreateAssignment
- Client.CreateReservation
- Client.DeleteAssignment
- Client.DeleteCapacityCommitment
- Client.DeleteReservation
- Client.GetCapacityCommitment
- Client.GetReservation
- Client.ListAssignments
- Client.ListCapacityCommitments
- Client.ListReservations
- Client.MoveAssignment
- Client.SearchAssignments
- Client.UpdateReservation
- NewClient
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) 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 ListCapacityCommitments []gax.CallOption GetCapacityCommitment []gax.CallOption DeleteCapacityCommitment []gax.CallOption CreateAssignment []gax.CallOption ListAssignments []gax.CallOption DeleteAssignment []gax.CallOption SearchAssignments []gax.CallOption MoveAssignment []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) 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.
func NewClient ¶
NewClient creates a new reservation service client.
This API allows users to manage their flat-rate 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 minimum 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 (*Client) Close ¶
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*Client) Connection ¶
func (c *Client) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated.
func (*Client) CreateAssignment ¶
func (c *Client) CreateAssignment(ctx context.Context, req *reservationpb.CreateAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
CreateAssignment 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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.CreateAssignmentRequest{
// TODO: Fill request struct fields.
}
resp, err := c.CreateAssignment(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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.CreateReservationRequest{
// TODO: Fill request struct fields.
}
resp, err := c.CreateReservation(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.
E.g:
organizationA contains project1 and project2. Reservation res1 exists.
CreateAssignment was invoked previously and following assignments were
created explicitly:
<organizationA, res1>
<project1, res1>
Then deletion of <organizationA, res1> won’t affect <project1, res1>. After
deletion of <organizationA, res1>, queries from project1 will still use
res1, while queries from project2 will use on-demand mode.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.DeleteAssignmentRequest{
// TODO: Fill request struct fields.
}
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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.DeleteCapacityCommitmentRequest{
// TODO: Fill request struct fields.
}
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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.DeleteReservationRequest{
// TODO: Fill request struct fields.
}
err = c.DeleteReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.GetCapacityCommitmentRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GetCapacityCommitment(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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.GetReservationRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GetReservation(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. E.g:
organizationA contains project1 and project2. Reservation res1 exists.
CreateAssignment was invoked previously and following assignments were
created explicitly:
<organizationA, res1>
<project1, res1>
Then this API will just return the above two assignments for reservation
res1, and no expansion/merge will happen. 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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
"google.golang.org/api/iterator"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
// import "google.golang.org/api/iterator"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.ListAssignmentsRequest{
// TODO: Fill request struct fields.
}
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
}
}
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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
"google.golang.org/api/iterator"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
// import "google.golang.org/api/iterator"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.ListCapacityCommitmentsRequest{
// TODO: Fill request struct fields.
}
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
}
}
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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
"google.golang.org/api/iterator"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
// import "google.golang.org/api/iterator"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.ListReservationsRequest{
// TODO: Fill request struct fields.
}
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
}
}
func (*Client) MoveAssignment ¶
func (c *Client) MoveAssignment(ctx context.Context, req *reservationpb.MoveAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error)
MoveAssignment moves a assignment under a new reservation. Customers can do this by
deleting the existing assignment followed by creating another assignment
under the new reservation, but this method provides a transactional way to
do so, to make sure the assignee always has an associated reservation.
Without the method customers might see some queries run on-demand which
might be unexpected.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.MoveAssignmentRequest{
// TODO: Fill request struct fields.
}
resp, err := c.MoveAssignment(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*Client) SearchAssignments ¶
func (c *Client) SearchAssignments(ctx context.Context, req *reservationpb.SearchAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator
SearchAssignments 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. 3) Assignments for different JobTypes will all be returned. 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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
"google.golang.org/api/iterator"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
// import "google.golang.org/api/iterator"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.SearchAssignmentsRequest{
// TODO: Fill request struct fields.
}
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
}
}
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.
Code:play
Example¶
package main
import (
"context"
reservation "cloud.google.com/go/bigquery/reservation/apiv1beta1"
reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
)
func main() {
// import reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
ctx := context.Background()
c, err := reservation.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &reservationpb.UpdateReservationRequest{
// TODO: Fill request struct fields.
}
resp, err := c.UpdateReservation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
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) 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.
Source Files ¶
doc.go reservation_client.go
- Version
- v1.5.0
- Published
- Feb 28, 2020
- Platform
- linux/amd64
- Imports
- 17 packages
- Last checked
- 1 hour ago –
Tools for package owners.