all: auto-regenerate gapics
This is an auto-generated regeneration of the gapic clients by
cloud.google.com/go/internal/gapicgen. Once the corresponding genproto PR is
submitted, genmgr will update this CL with a newer dependency to the newer
version of genproto and assign reviewers to this CL.
If you have been assigned to review this CL, please:
- Ensure that the version of genproto in go.mod has been updated.
- Ensure that CI is passing. If it's failing, it requires your manual attention.
- +2 and submit this CL if you believe it's ready to ship.
Corresponding genproto PR: https://github.com/googleapis/go-genproto/pull/299
Change-Id: Ia05b9f0ae4bac1f5a6a0bc540ad6ba4cca3742e4
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/51451
Reviewed-by: Seth Hollyman <shollyman@google.com>
diff --git a/bigquery/reservation/apiv1beta1/doc.go b/bigquery/reservation/apiv1beta1/doc.go
new file mode 100644
index 0000000..c32817b
--- /dev/null
+++ b/bigquery/reservation/apiv1beta1/doc.go
@@ -0,0 +1,101 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
+
+// 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.
+package reservation // import "cloud.google.com/go/bigquery/reservation/apiv1beta1"
+
+import (
+ "context"
+ "runtime"
+ "strings"
+ "unicode"
+
+ "google.golang.org/grpc/metadata"
+)
+
+const versionClient = "20200204"
+
+func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
+ out, _ := metadata.FromOutgoingContext(ctx)
+ out = out.Copy()
+ for _, md := range mds {
+ for k, v := range md {
+ out[k] = append(out[k], v...)
+ }
+ }
+ return metadata.NewOutgoingContext(ctx, out)
+}
+
+// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
+func DefaultAuthScopes() []string {
+ return []string{
+ "https://www.googleapis.com/auth/bigquery",
+ "https://www.googleapis.com/auth/cloud-platform",
+ }
+}
+
+// versionGo returns the Go runtime version. The returned string
+// has no whitespace, suitable for reporting in header.
+func versionGo() string {
+ const develPrefix = "devel +"
+
+ s := runtime.Version()
+ if strings.HasPrefix(s, develPrefix) {
+ s = s[len(develPrefix):]
+ if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
+ s = s[:p]
+ }
+ return s
+ }
+
+ notSemverRune := func(r rune) bool {
+ return !strings.ContainsRune("0123456789.", r)
+ }
+
+ if strings.HasPrefix(s, "go1") {
+ s = s[2:]
+ var prerelease string
+ if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
+ s, prerelease = s[:p], s[p:]
+ }
+ if strings.HasSuffix(s, ".") {
+ s += "0"
+ } else if strings.Count(s, ".") < 2 {
+ s += ".0"
+ }
+ if prerelease != "" {
+ s += "-" + prerelease
+ }
+ return s
+ }
+ return "UNKNOWN"
+}
diff --git a/bigquery/reservation/apiv1beta1/reservation_client.go b/bigquery/reservation/apiv1beta1/reservation_client.go
new file mode 100644
index 0000000..d26dc34
--- /dev/null
+++ b/bigquery/reservation/apiv1beta1/reservation_client.go
@@ -0,0 +1,748 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
+
+package reservation
+
+import (
+ "context"
+ "fmt"
+ "math"
+ "net/url"
+ "time"
+
+ "github.com/golang/protobuf/proto"
+ gax "github.com/googleapis/gax-go/v2"
+ "google.golang.org/api/iterator"
+ "google.golang.org/api/option"
+ "google.golang.org/api/transport"
+ reservationpb "google.golang.org/genproto/googleapis/cloud/bigquery/reservation/v1beta1"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/metadata"
+)
+
+// CallOptions contains the retry settings for each method of Client.
+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
+}
+
+func defaultClientOptions() []option.ClientOption {
+ return []option.ClientOption{
+ option.WithEndpoint("bigqueryreservation.googleapis.com:443"),
+ option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
+ option.WithScopes(DefaultAuthScopes()...),
+ option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
+ grpc.MaxCallRecvMsgSize(math.MaxInt32))),
+ }
+}
+
+func defaultCallOptions() *CallOptions {
+ return &CallOptions{
+ CreateReservation: []gax.CallOption{},
+ ListReservations: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ GetReservation: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ DeleteReservation: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ UpdateReservation: []gax.CallOption{},
+ ListCapacityCommitments: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ GetCapacityCommitment: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ DeleteCapacityCommitment: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ CreateAssignment: []gax.CallOption{},
+ ListAssignments: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ DeleteAssignment: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ SearchAssignments: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ MoveAssignment: []gax.CallOption{},
+ }
+}
+
+// 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.
+type Client struct {
+ // The connection to the service.
+ conn *grpc.ClientConn
+
+ // The gRPC API client.
+ client reservationpb.ReservationServiceClient
+
+ // The call options for this service.
+ CallOptions *CallOptions
+
+ // The x-goog-* metadata to be sent with each request.
+ xGoogMetadata metadata.MD
+}
+
+// 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 NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) {
+ conn, err := transport.DialGRPC(ctx, append(defaultClientOptions(), opts...)...)
+ if err != nil {
+ return nil, err
+ }
+ c := &Client{
+ conn: conn,
+ CallOptions: defaultCallOptions(),
+
+ client: reservationpb.NewReservationServiceClient(conn),
+ }
+ c.setGoogleClientInfo()
+
+ return c, nil
+}
+
+// Connection returns the client's connection to the API service.
+func (c *Client) Connection() *grpc.ClientConn {
+ return c.conn
+}
+
+// Close closes the connection to the API service. The user should invoke this when
+// the client is no longer required.
+func (c *Client) Close() error {
+ return c.conn.Close()
+}
+
+// setGoogleClientInfo sets the name and version of the application in
+// the `x-goog-api-client` header passed on each request. Intended for
+// use by Google-written clients.
+func (c *Client) setGoogleClientInfo(keyval ...string) {
+ kv := append([]string{"gl-go", versionGo()}, keyval...)
+ kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
+ c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
+}
+
+// CreateReservation creates a new reservation resource.
+func (c *Client) CreateReservation(ctx context.Context, req *reservationpb.CreateReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.CreateReservation[0:len(c.CallOptions.CreateReservation):len(c.CallOptions.CreateReservation)], opts...)
+ var resp *reservationpb.Reservation
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.CreateReservation(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ListReservations lists all the reservations for the project in the specified location.
+func (c *Client) ListReservations(ctx context.Context, req *reservationpb.ListReservationsRequest, opts ...gax.CallOption) *ReservationIterator {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.ListReservations[0:len(c.CallOptions.ListReservations):len(c.CallOptions.ListReservations)], opts...)
+ it := &ReservationIterator{}
+ req = proto.Clone(req).(*reservationpb.ListReservationsRequest)
+ it.InternalFetch = func(pageSize int, pageToken string) ([]*reservationpb.Reservation, string, error) {
+ var resp *reservationpb.ListReservationsResponse
+ req.PageToken = pageToken
+ if pageSize > math.MaxInt32 {
+ req.PageSize = math.MaxInt32
+ } else {
+ req.PageSize = int32(pageSize)
+ }
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.ListReservations(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, "", err
+ }
+
+ it.Response = resp
+ return resp.Reservations, resp.NextPageToken, nil
+ }
+ fetch := func(pageSize int, pageToken string) (string, error) {
+ items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
+ if err != nil {
+ return "", err
+ }
+ it.items = append(it.items, items...)
+ return nextPageToken, nil
+ }
+ it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
+ it.pageInfo.MaxSize = int(req.PageSize)
+ it.pageInfo.Token = req.PageToken
+ return it
+}
+
+// GetReservation returns information about the reservation.
+func (c *Client) GetReservation(ctx context.Context, req *reservationpb.GetReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.GetReservation[0:len(c.CallOptions.GetReservation):len(c.CallOptions.GetReservation)], opts...)
+ var resp *reservationpb.Reservation
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.GetReservation(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// DeleteReservation deletes a reservation.
+// Returns google.rpc.Code.FAILED_PRECONDITION when reservation has
+// assignments.
+func (c *Client) DeleteReservation(ctx context.Context, req *reservationpb.DeleteReservationRequest, opts ...gax.CallOption) error {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.DeleteReservation[0:len(c.CallOptions.DeleteReservation):len(c.CallOptions.DeleteReservation)], opts...)
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ _, err = c.client.DeleteReservation(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ return err
+}
+
+// UpdateReservation updates an existing reservation resource.
+func (c *Client) UpdateReservation(ctx context.Context, req *reservationpb.UpdateReservationRequest, opts ...gax.CallOption) (*reservationpb.Reservation, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "reservation.name", url.QueryEscape(req.GetReservation().GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.UpdateReservation[0:len(c.CallOptions.UpdateReservation):len(c.CallOptions.UpdateReservation)], opts...)
+ var resp *reservationpb.Reservation
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.UpdateReservation(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ListCapacityCommitments lists all the capacity commitments for the admin project.
+func (c *Client) ListCapacityCommitments(ctx context.Context, req *reservationpb.ListCapacityCommitmentsRequest, opts ...gax.CallOption) *CapacityCommitmentIterator {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.ListCapacityCommitments[0:len(c.CallOptions.ListCapacityCommitments):len(c.CallOptions.ListCapacityCommitments)], opts...)
+ it := &CapacityCommitmentIterator{}
+ req = proto.Clone(req).(*reservationpb.ListCapacityCommitmentsRequest)
+ it.InternalFetch = func(pageSize int, pageToken string) ([]*reservationpb.CapacityCommitment, string, error) {
+ var resp *reservationpb.ListCapacityCommitmentsResponse
+ req.PageToken = pageToken
+ if pageSize > math.MaxInt32 {
+ req.PageSize = math.MaxInt32
+ } else {
+ req.PageSize = int32(pageSize)
+ }
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.ListCapacityCommitments(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, "", err
+ }
+
+ it.Response = resp
+ return resp.CapacityCommitments, resp.NextPageToken, nil
+ }
+ fetch := func(pageSize int, pageToken string) (string, error) {
+ items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
+ if err != nil {
+ return "", err
+ }
+ it.items = append(it.items, items...)
+ return nextPageToken, nil
+ }
+ it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
+ it.pageInfo.MaxSize = int(req.PageSize)
+ it.pageInfo.Token = req.PageToken
+ return it
+}
+
+// GetCapacityCommitment returns information about the capacity commitment.
+func (c *Client) GetCapacityCommitment(ctx context.Context, req *reservationpb.GetCapacityCommitmentRequest, opts ...gax.CallOption) (*reservationpb.CapacityCommitment, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.GetCapacityCommitment[0:len(c.CallOptions.GetCapacityCommitment):len(c.CallOptions.GetCapacityCommitment)], opts...)
+ var resp *reservationpb.CapacityCommitment
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.GetCapacityCommitment(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// 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.
+func (c *Client) DeleteCapacityCommitment(ctx context.Context, req *reservationpb.DeleteCapacityCommitmentRequest, opts ...gax.CallOption) error {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.DeleteCapacityCommitment[0:len(c.CallOptions.DeleteCapacityCommitment):len(c.CallOptions.DeleteCapacityCommitment)], opts...)
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ _, err = c.client.DeleteCapacityCommitment(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ return err
+}
+
+// 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.
+func (c *Client) CreateAssignment(ctx context.Context, req *reservationpb.CreateAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.CreateAssignment[0:len(c.CallOptions.CreateAssignment):len(c.CallOptions.CreateAssignment)], opts...)
+ var resp *reservationpb.Assignment
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.CreateAssignment(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// 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.
+func (c *Client) ListAssignments(ctx context.Context, req *reservationpb.ListAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.ListAssignments[0:len(c.CallOptions.ListAssignments):len(c.CallOptions.ListAssignments)], opts...)
+ it := &AssignmentIterator{}
+ req = proto.Clone(req).(*reservationpb.ListAssignmentsRequest)
+ it.InternalFetch = func(pageSize int, pageToken string) ([]*reservationpb.Assignment, string, error) {
+ var resp *reservationpb.ListAssignmentsResponse
+ req.PageToken = pageToken
+ if pageSize > math.MaxInt32 {
+ req.PageSize = math.MaxInt32
+ } else {
+ req.PageSize = int32(pageSize)
+ }
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.ListAssignments(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, "", err
+ }
+
+ it.Response = resp
+ return resp.Assignments, resp.NextPageToken, nil
+ }
+ fetch := func(pageSize int, pageToken string) (string, error) {
+ items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
+ if err != nil {
+ return "", err
+ }
+ it.items = append(it.items, items...)
+ return nextPageToken, nil
+ }
+ it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
+ it.pageInfo.MaxSize = int(req.PageSize)
+ it.pageInfo.Token = req.PageToken
+ return it
+}
+
+// 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.
+func (c *Client) DeleteAssignment(ctx context.Context, req *reservationpb.DeleteAssignmentRequest, opts ...gax.CallOption) error {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.DeleteAssignment[0:len(c.CallOptions.DeleteAssignment):len(c.CallOptions.DeleteAssignment)], opts...)
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ _, err = c.client.DeleteAssignment(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ return err
+}
+
+// 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.
+func (c *Client) SearchAssignments(ctx context.Context, req *reservationpb.SearchAssignmentsRequest, opts ...gax.CallOption) *AssignmentIterator {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.SearchAssignments[0:len(c.CallOptions.SearchAssignments):len(c.CallOptions.SearchAssignments)], opts...)
+ it := &AssignmentIterator{}
+ req = proto.Clone(req).(*reservationpb.SearchAssignmentsRequest)
+ it.InternalFetch = func(pageSize int, pageToken string) ([]*reservationpb.Assignment, string, error) {
+ var resp *reservationpb.SearchAssignmentsResponse
+ req.PageToken = pageToken
+ if pageSize > math.MaxInt32 {
+ req.PageSize = math.MaxInt32
+ } else {
+ req.PageSize = int32(pageSize)
+ }
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.SearchAssignments(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, "", err
+ }
+
+ it.Response = resp
+ return resp.Assignments, resp.NextPageToken, nil
+ }
+ fetch := func(pageSize int, pageToken string) (string, error) {
+ items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
+ if err != nil {
+ return "", err
+ }
+ it.items = append(it.items, items...)
+ return nextPageToken, nil
+ }
+ it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
+ it.pageInfo.MaxSize = int(req.PageSize)
+ it.pageInfo.Token = req.PageToken
+ return it
+}
+
+// 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.
+func (c *Client) MoveAssignment(ctx context.Context, req *reservationpb.MoveAssignmentRequest, opts ...gax.CallOption) (*reservationpb.Assignment, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.MoveAssignment[0:len(c.CallOptions.MoveAssignment):len(c.CallOptions.MoveAssignment)], opts...)
+ var resp *reservationpb.Assignment
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.client.MoveAssignment(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// AssignmentIterator manages a stream of *reservationpb.Assignment.
+type AssignmentIterator struct {
+ items []*reservationpb.Assignment
+ pageInfo *iterator.PageInfo
+ nextFunc func() error
+
+ // 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)
+}
+
+// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
+func (it *AssignmentIterator) PageInfo() *iterator.PageInfo {
+ return it.pageInfo
+}
+
+// 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 (it *AssignmentIterator) Next() (*reservationpb.Assignment, error) {
+ var item *reservationpb.Assignment
+ if err := it.nextFunc(); err != nil {
+ return item, err
+ }
+ item = it.items[0]
+ it.items = it.items[1:]
+ return item, nil
+}
+
+func (it *AssignmentIterator) bufLen() int {
+ return len(it.items)
+}
+
+func (it *AssignmentIterator) takeBuf() interface{} {
+ b := it.items
+ it.items = nil
+ return b
+}
+
+// CapacityCommitmentIterator manages a stream of *reservationpb.CapacityCommitment.
+type CapacityCommitmentIterator struct {
+ items []*reservationpb.CapacityCommitment
+ pageInfo *iterator.PageInfo
+ nextFunc func() error
+
+ // 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)
+}
+
+// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
+func (it *CapacityCommitmentIterator) PageInfo() *iterator.PageInfo {
+ return it.pageInfo
+}
+
+// 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 (it *CapacityCommitmentIterator) Next() (*reservationpb.CapacityCommitment, error) {
+ var item *reservationpb.CapacityCommitment
+ if err := it.nextFunc(); err != nil {
+ return item, err
+ }
+ item = it.items[0]
+ it.items = it.items[1:]
+ return item, nil
+}
+
+func (it *CapacityCommitmentIterator) bufLen() int {
+ return len(it.items)
+}
+
+func (it *CapacityCommitmentIterator) takeBuf() interface{} {
+ b := it.items
+ it.items = nil
+ return b
+}
+
+// ReservationIterator manages a stream of *reservationpb.Reservation.
+type ReservationIterator struct {
+ items []*reservationpb.Reservation
+ pageInfo *iterator.PageInfo
+ nextFunc func() error
+
+ // 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)
+}
+
+// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
+func (it *ReservationIterator) PageInfo() *iterator.PageInfo {
+ return it.pageInfo
+}
+
+// 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 (it *ReservationIterator) Next() (*reservationpb.Reservation, error) {
+ var item *reservationpb.Reservation
+ if err := it.nextFunc(); err != nil {
+ return item, err
+ }
+ item = it.items[0]
+ it.items = it.items[1:]
+ return item, nil
+}
+
+func (it *ReservationIterator) bufLen() int {
+ return len(it.items)
+}
+
+func (it *ReservationIterator) takeBuf() interface{} {
+ b := it.items
+ it.items = nil
+ return b
+}
diff --git a/bigquery/reservation/apiv1beta1/reservation_client_example_test.go b/bigquery/reservation/apiv1beta1/reservation_client_example_test.go
new file mode 100644
index 0000000..2006300
--- /dev/null
+++ b/bigquery/reservation/apiv1beta1/reservation_client_example_test.go
@@ -0,0 +1,311 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
+
+package reservation_test
+
+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 ExampleNewClient() {
+ ctx := context.Background()
+ c, err := reservation.NewClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use client.
+ _ = c
+}
+
+func ExampleClient_CreateReservation() {
+ // 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 ExampleClient_ListReservations() {
+ // 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 ExampleClient_GetReservation() {
+ // 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 ExampleClient_DeleteReservation() {
+ 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 ExampleClient_UpdateReservation() {
+ // 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
+}
+
+func ExampleClient_ListCapacityCommitments() {
+ // 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 ExampleClient_GetCapacityCommitment() {
+ // 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 ExampleClient_DeleteCapacityCommitment() {
+ 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 ExampleClient_CreateAssignment() {
+ // 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 ExampleClient_ListAssignments() {
+ // 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 ExampleClient_DeleteAssignment() {
+ 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 ExampleClient_SearchAssignments() {
+ // 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 ExampleClient_MoveAssignment() {
+ // 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
+}
diff --git a/bigquery/storage/apiv1/big_query_read_client.go b/bigquery/storage/apiv1/big_query_read_client.go
new file mode 100644
index 0000000..37091be
--- /dev/null
+++ b/bigquery/storage/apiv1/big_query_read_client.go
@@ -0,0 +1,234 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
+
+package storage
+
+import (
+ "context"
+ "fmt"
+ "math"
+ "net/url"
+ "time"
+
+ gax "github.com/googleapis/gax-go/v2"
+ "google.golang.org/api/option"
+ "google.golang.org/api/transport"
+ storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+ "google.golang.org/grpc/metadata"
+)
+
+// BigQueryReadCallOptions contains the retry settings for each method of BigQueryReadClient.
+type BigQueryReadCallOptions struct {
+ CreateReadSession []gax.CallOption
+ ReadRows []gax.CallOption
+ SplitReadStream []gax.CallOption
+}
+
+func defaultBigQueryReadClientOptions() []option.ClientOption {
+ return []option.ClientOption{
+ option.WithEndpoint("bigquerystorage.googleapis.com:443"),
+ option.WithGRPCDialOption(grpc.WithDisableServiceConfig()),
+ option.WithScopes(DefaultAuthScopes()...),
+ option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
+ grpc.MaxCallRecvMsgSize(math.MaxInt32))),
+ }
+}
+
+func defaultBigQueryReadCallOptions() *BigQueryReadCallOptions {
+ return &BigQueryReadCallOptions{
+ CreateReadSession: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ ReadRows: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ SplitReadStream: []gax.CallOption{
+ gax.WithRetry(func() gax.Retryer {
+ return gax.OnCodes([]codes.Code{
+ codes.DeadlineExceeded,
+ codes.Unavailable,
+ }, gax.Backoff{
+ Initial: 100 * time.Millisecond,
+ Max: 60000 * time.Millisecond,
+ Multiplier: 1.30,
+ })
+ }),
+ },
+ }
+}
+
+// BigQueryReadClient is a client for interacting with BigQuery Storage API.
+//
+// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
+type BigQueryReadClient struct {
+ // The connection to the service.
+ conn *grpc.ClientConn
+
+ // The gRPC API client.
+ bigQueryReadClient storagepb.BigQueryReadClient
+
+ // The call options for this service.
+ CallOptions *BigQueryReadCallOptions
+
+ // The x-goog-* metadata to be sent with each request.
+ xGoogMetadata metadata.MD
+}
+
+// NewBigQueryReadClient creates a new big query read client.
+//
+// BigQuery Read API.
+//
+// The Read API can be used to read data from BigQuery.
+func NewBigQueryReadClient(ctx context.Context, opts ...option.ClientOption) (*BigQueryReadClient, error) {
+ conn, err := transport.DialGRPC(ctx, append(defaultBigQueryReadClientOptions(), opts...)...)
+ if err != nil {
+ return nil, err
+ }
+ c := &BigQueryReadClient{
+ conn: conn,
+ CallOptions: defaultBigQueryReadCallOptions(),
+
+ bigQueryReadClient: storagepb.NewBigQueryReadClient(conn),
+ }
+ c.setGoogleClientInfo()
+
+ return c, nil
+}
+
+// Connection returns the client's connection to the API service.
+func (c *BigQueryReadClient) Connection() *grpc.ClientConn {
+ return c.conn
+}
+
+// Close closes the connection to the API service. The user should invoke this when
+// the client is no longer required.
+func (c *BigQueryReadClient) Close() error {
+ return c.conn.Close()
+}
+
+// setGoogleClientInfo sets the name and version of the application in
+// the `x-goog-api-client` header passed on each request. Intended for
+// use by Google-written clients.
+func (c *BigQueryReadClient) setGoogleClientInfo(keyval ...string) {
+ kv := append([]string{"gl-go", versionGo()}, keyval...)
+ kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version)
+ c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
+}
+
+// CreateReadSession creates a new read session. A read session divides the contents of a
+// BigQuery table into one or more streams, which can then be used to read
+// data from the table. The read session also specifies properties of the
+// data to be read, such as a list of columns or a push-down filter describing
+// the rows to be returned.
+//
+// A particular row can be read by at most one stream. When the caller has
+// reached the end of each stream in the session, then all the data in the
+// table has been read.
+//
+// Data is assigned to each stream such that roughly the same number of
+// rows can be read from each stream. Because the server-side unit for
+// assigning data is collections of rows, the API does not guarantee that
+// each stream will return the same number or rows. Additionally, the
+// limits are enforced based on the number of pre-filtered rows, so some
+// filters can lead to lopsided assignments.
+//
+// Read sessions automatically expire 24 hours after they are created and do
+// not require manual clean-up by the caller.
+func (c *BigQueryReadClient) CreateReadSession(ctx context.Context, req *storagepb.CreateReadSessionRequest, opts ...gax.CallOption) (*storagepb.ReadSession, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "read_session.table", url.QueryEscape(req.GetReadSession().GetTable())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.CreateReadSession[0:len(c.CallOptions.CreateReadSession):len(c.CallOptions.CreateReadSession)], opts...)
+ var resp *storagepb.ReadSession
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.bigQueryReadClient.CreateReadSession(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// ReadRows reads rows from the stream in the format prescribed by the ReadSession.
+// Each response contains one or more table rows, up to a maximum of 100 MiB
+// per response; read requests which attempt to read individual rows larger
+// than 100 MiB will fail.
+//
+// Each request also returns a set of stream statistics reflecting the current
+// state of the stream.
+func (c *BigQueryReadClient) ReadRows(ctx context.Context, req *storagepb.ReadRowsRequest, opts ...gax.CallOption) (storagepb.BigQueryRead_ReadRowsClient, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "read_stream", url.QueryEscape(req.GetReadStream())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.ReadRows[0:len(c.CallOptions.ReadRows):len(c.CallOptions.ReadRows)], opts...)
+ var resp storagepb.BigQueryRead_ReadRowsClient
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.bigQueryReadClient.ReadRows(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+// SplitReadStream splits a given ReadStream into two ReadStream objects. These
+// ReadStream objects are referred to as the primary and the residual
+// streams of the split. The original ReadStream can still be read from in
+// the same manner as before. Both of the returned ReadStream objects can
+// also be read from, and the rows returned by both child streams will be
+// the same as the rows read from the original stream.
+//
+// Moreover, the two child streams will be allocated back-to-back in the
+// original ReadStream. Concretely, it is guaranteed that for streams
+// original, primary, and residual, that original[0-j] = primary[0-j] and
+// original[j-n] = residual[0-m] once the streams have been read to
+// completion.
+func (c *BigQueryReadClient) SplitReadStream(ctx context.Context, req *storagepb.SplitReadStreamRequest, opts ...gax.CallOption) (*storagepb.SplitReadStreamResponse, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.SplitReadStream[0:len(c.CallOptions.SplitReadStream):len(c.CallOptions.SplitReadStream)], opts...)
+ var resp *storagepb.SplitReadStreamResponse
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.bigQueryReadClient.SplitReadStream(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
diff --git a/bigquery/storage/apiv1/big_query_read_client_example_test.go b/bigquery/storage/apiv1/big_query_read_client_example_test.go
new file mode 100644
index 0000000..e2b7a81
--- /dev/null
+++ b/bigquery/storage/apiv1/big_query_read_client_example_test.go
@@ -0,0 +1,74 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
+
+package storage_test
+
+import (
+ "context"
+
+ storage "cloud.google.com/go/bigquery/storage/apiv1"
+ storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1"
+)
+
+func ExampleNewBigQueryReadClient() {
+ ctx := context.Background()
+ c, err := storage.NewBigQueryReadClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use client.
+ _ = c
+}
+
+func ExampleBigQueryReadClient_CreateReadSession() {
+ // import storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1"
+
+ ctx := context.Background()
+ c, err := storage.NewBigQueryReadClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &storagepb.CreateReadSessionRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.CreateReadSession(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
+func ExampleBigQueryReadClient_SplitReadStream() {
+ // import storagepb "google.golang.org/genproto/googleapis/cloud/bigquery/storage/v1"
+
+ ctx := context.Background()
+ c, err := storage.NewBigQueryReadClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &storagepb.SplitReadStreamRequest{
+ // TODO: Fill request struct fields.
+ }
+ resp, err := c.SplitReadStream(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
diff --git a/bigquery/storage/apiv1/doc.go b/bigquery/storage/apiv1/doc.go
new file mode 100644
index 0000000..8a3552b
--- /dev/null
+++ b/bigquery/storage/apiv1/doc.go
@@ -0,0 +1,100 @@
+// Copyright 2020 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
+
+// Package storage is an auto-generated package for the
+// BigQuery Storage API.
+//
+// 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.
+package storage // import "cloud.google.com/go/bigquery/storage/apiv1"
+
+import (
+ "context"
+ "runtime"
+ "strings"
+ "unicode"
+
+ "google.golang.org/grpc/metadata"
+)
+
+const versionClient = "20200204"
+
+func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
+ out, _ := metadata.FromOutgoingContext(ctx)
+ out = out.Copy()
+ for _, md := range mds {
+ for k, v := range md {
+ out[k] = append(out[k], v...)
+ }
+ }
+ return metadata.NewOutgoingContext(ctx, out)
+}
+
+// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
+func DefaultAuthScopes() []string {
+ return []string{
+ "https://www.googleapis.com/auth/bigquery",
+ "https://www.googleapis.com/auth/bigquery.readonly",
+ "https://www.googleapis.com/auth/cloud-platform",
+ }
+}
+
+// versionGo returns the Go runtime version. The returned string
+// has no whitespace, suitable for reporting in header.
+func versionGo() string {
+ const develPrefix = "devel +"
+
+ s := runtime.Version()
+ if strings.HasPrefix(s, develPrefix) {
+ s = s[len(develPrefix):]
+ if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
+ s = s[:p]
+ }
+ return s
+ }
+
+ notSemverRune := func(r rune) bool {
+ return !strings.ContainsRune("0123456789.", r)
+ }
+
+ if strings.HasPrefix(s, "go1") {
+ s = s[2:]
+ var prerelease string
+ if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
+ s, prerelease = s[:p], s[p:]
+ }
+ if strings.HasSuffix(s, ".") {
+ s += "0"
+ } else if strings.Count(s, ".") < 2 {
+ s += ".0"
+ }
+ if prerelease != "" {
+ s += "-" + prerelease
+ }
+ return s
+ }
+ return "UNKNOWN"
+}
diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json
index cc349dc..7fb51ee 100644
--- a/internal/.repo-metadata-full.json
+++ b/internal/.repo-metadata-full.json
@@ -31,6 +31,22 @@
"docs_url": "https://pkg.go.dev/cloud.google.com/go/bigquery/datatransfer/apiv1",
"release_level": "alpha"
},
+ "cloud.google.com/go/bigquery/reservation/apiv1beta1": {
+ "distribution_name": "cloud.google.com/go/bigquery/reservation/apiv1beta1",
+ "description": "BigQuery Reservation API",
+ "language": "Go",
+ "client_library_type": "generated",
+ "docs_url": "https://pkg.go.dev/cloud.google.com/go/bigquery/reservation/apiv1beta1",
+ "release_level": "alpha"
+ },
+ "cloud.google.com/go/bigquery/storage/apiv1": {
+ "distribution_name": "cloud.google.com/go/bigquery/storage/apiv1",
+ "description": "BigQuery Storage API",
+ "language": "Go",
+ "client_library_type": "generated",
+ "docs_url": "https://pkg.go.dev/cloud.google.com/go/bigquery/storage/apiv1",
+ "release_level": "alpha"
+ },
"cloud.google.com/go/bigquery/storage/apiv1alpha2": {
"distribution_name": "cloud.google.com/go/bigquery/storage/apiv1alpha2",
"description": "BigQuery Storage API",
diff --git a/redis/apiv1beta1/cloud_redis_client.go b/redis/apiv1beta1/cloud_redis_client.go
index 2922424..33d6150 100644
--- a/redis/apiv1beta1/cloud_redis_client.go
+++ b/redis/apiv1beta1/cloud_redis_client.go
@@ -43,6 +43,7 @@
GetInstance []gax.CallOption
CreateInstance []gax.CallOption
UpdateInstance []gax.CallOption
+ UpgradeInstance []gax.CallOption
ImportInstance []gax.CallOption
ExportInstance []gax.CallOption
FailoverInstance []gax.CallOption
@@ -65,6 +66,7 @@
GetInstance: []gax.CallOption{},
CreateInstance: []gax.CallOption{},
UpdateInstance: []gax.CallOption{},
+ UpgradeInstance: []gax.CallOption{},
ImportInstance: []gax.CallOption{},
ExportInstance: []gax.CallOption{},
FailoverInstance: []gax.CallOption{},
@@ -281,6 +283,26 @@
}, nil
}
+// UpgradeInstance upgrades Redis instance to the newer Redis version specified in the
+// request.
+func (c *CloudRedisClient) UpgradeInstance(ctx context.Context, req *redispb.UpgradeInstanceRequest, opts ...gax.CallOption) (*UpgradeInstanceOperation, error) {
+ md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName())))
+ ctx = insertMetadata(ctx, c.xGoogMetadata, md)
+ opts = append(c.CallOptions.UpgradeInstance[0:len(c.CallOptions.UpgradeInstance):len(c.CallOptions.UpgradeInstance)], opts...)
+ var resp *longrunningpb.Operation
+ err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
+ var err error
+ resp, err = c.cloudRedisClient.UpgradeInstance(ctx, req, settings.GRPC...)
+ return err
+ }, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &UpgradeInstanceOperation{
+ lro: longrunning.InternalNewOperation(c.LROClient, resp),
+ }, nil
+}
+
// ImportInstance import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
//
// Redis may stop serving during this operation. Instance state will be
@@ -774,6 +796,75 @@
return op.lro.Name()
}
+// UpgradeInstanceOperation manages a long-running operation from UpgradeInstance.
+type UpgradeInstanceOperation struct {
+ lro *longrunning.Operation
+}
+
+// UpgradeInstanceOperation returns a new UpgradeInstanceOperation from a given name.
+// The name must be that of a previously created UpgradeInstanceOperation, possibly from a different process.
+func (c *CloudRedisClient) UpgradeInstanceOperation(name string) *UpgradeInstanceOperation {
+ return &UpgradeInstanceOperation{
+ lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}),
+ }
+}
+
+// Wait blocks until the long-running operation is completed, returning the response and any errors encountered.
+//
+// See documentation of Poll for error-handling information.
+func (op *UpgradeInstanceOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, error) {
+ var resp redispb.Instance
+ if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil {
+ return nil, err
+ }
+ return &resp, nil
+}
+
+// Poll fetches the latest state of the long-running operation.
+//
+// Poll also fetches the latest metadata, which can be retrieved by Metadata.
+//
+// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and
+// the operation has completed with failure, the error is returned and op.Done will return true.
+// If Poll succeeds and the operation has completed successfully,
+// op.Done will return true, and the response of the operation is returned.
+// If Poll succeeds and the operation has not completed, the returned response and error are both nil.
+func (op *UpgradeInstanceOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*redispb.Instance, error) {
+ var resp redispb.Instance
+ if err := op.lro.Poll(ctx, &resp, opts...); err != nil {
+ return nil, err
+ }
+ if !op.Done() {
+ return nil, nil
+ }
+ return &resp, nil
+}
+
+// Metadata returns metadata associated with the long-running operation.
+// Metadata itself does not contact the server, but Poll does.
+// To get the latest metadata, call this method after a successful call to Poll.
+// If the metadata is not available, the returned metadata and error are both nil.
+func (op *UpgradeInstanceOperation) Metadata() (*anypb.Any, error) {
+ var meta anypb.Any
+ if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata {
+ return nil, nil
+ } else if err != nil {
+ return nil, err
+ }
+ return &meta, nil
+}
+
+// Done reports whether the long-running operation has completed.
+func (op *UpgradeInstanceOperation) Done() bool {
+ return op.lro.Done()
+}
+
+// Name returns the name of the long-running operation.
+// The name is assigned by the server and is unique within the service from which the operation is created.
+func (op *UpgradeInstanceOperation) Name() string {
+ return op.lro.Name()
+}
+
// InstanceIterator manages a stream of *redispb.Instance.
type InstanceIterator struct {
items []*redispb.Instance
diff --git a/redis/apiv1beta1/cloud_redis_client_example_test.go b/redis/apiv1beta1/cloud_redis_client_example_test.go
index 65ca49c..0761ddb 100644
--- a/redis/apiv1beta1/cloud_redis_client_example_test.go
+++ b/redis/apiv1beta1/cloud_redis_client_example_test.go
@@ -131,6 +131,31 @@
_ = resp
}
+func ExampleCloudRedisClient_UpgradeInstance() {
+ // import redispb "google.golang.org/genproto/googleapis/cloud/redis/v1beta1"
+
+ ctx := context.Background()
+ c, err := redis.NewCloudRedisClient(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ req := &redispb.UpgradeInstanceRequest{
+ // TODO: Fill request struct fields.
+ }
+ op, err := c.UpgradeInstance(ctx, req)
+ if err != nil {
+ // TODO: Handle error.
+ }
+
+ resp, err := op.Wait(ctx)
+ if err != nil {
+ // TODO: Handle error.
+ }
+ // TODO: Use resp.
+ _ = resp
+}
+
func ExampleCloudRedisClient_ImportInstance() {
// import redispb "google.golang.org/genproto/googleapis/cloud/redis/v1beta1"