From 7e65b5d98609c114ec0520ebe4d6dd34e472bf9a Mon Sep 17 00:00:00 2001 From: noahdietz Date: Thu, 29 Apr 2021 10:13:00 -0700 Subject: [PATCH 1/6] feat: add GCS GAPIC PoC --- internal/gapicgen/generator/config.go | 9 +- storage/internal/apiv1/doc.go | 121 + storage/internal/apiv1/gapic_metadata.json | 298 +++ storage/internal/apiv1/storage_client.go | 2140 +++++++++++++++++ .../apiv1/storage_client_example_test.go | 1082 +++++++++ 5 files changed, 3649 insertions(+), 1 deletion(-) create mode 100644 storage/internal/apiv1/doc.go create mode 100644 storage/internal/apiv1/gapic_metadata.json create mode 100644 storage/internal/apiv1/storage_client.go create mode 100644 storage/internal/apiv1/storage_client_example_test.go diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 7c25b1acdddb..e1e4395d8615 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -1202,6 +1202,13 @@ var microgenGapicConfigs = []*microgenConfig{ gRPCServiceConfigPath: "google/cloud/gsuiteaddons/v1/gsuiteaddons_grpc_service_config.json", apiServiceConfigPath: "google/cloud/gsuiteaddons/v1/gsuiteaddons_v1.yaml", // GA after 2021/06/10 - releaseLevel: "beta", + }, + { + releaseLevel: "beta", + inputDirectoryPath: "google/storage/v1", + pkg: "storage", + importPath: "cloud.google.com/go/storage/internal/apiv1", + gRPCServiceConfigPath: "google/storage/v1/storage_grpc_service_config.json", + apiServiceConfigPath: "google/storage/v1/storage_v1.yaml", }, } diff --git a/storage/internal/apiv1/doc.go b/storage/internal/apiv1/doc.go new file mode 100644 index 000000000000..5310ba49372b --- /dev/null +++ b/storage/internal/apiv1/doc.go @@ -0,0 +1,121 @@ +// Copyright 2021 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 +// Cloud Storage API. +// +// Lets you store and retrieve potentially-large, immutable data objects. +// +// 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 https://pkg.go.dev/cloud.google.com/go. +package storage // import "cloud.google.com/go/storage/internal/apiv1" + +import ( + "context" + "os" + "runtime" + "strings" + "strconv" + "unicode" + + "google.golang.org/api/option" + "google.golang.org/grpc/metadata" +) + +// For more information on implementing a client constructor hook, see +// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. +type clientHookParams struct{} +type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) + +const versionClient = "UNKNOWN" + +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) +} + +func checkDisableDeadlines() (bool, error) { + raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") + if !ok { + return false, nil + } + + b, err := strconv.ParseBool(raw) + return b, err +} + +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. +func DefaultAuthScopes() []string { + return []string{ + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + "https://www.googleapis.com/auth/devstorage.full_control", + "https://www.googleapis.com/auth/devstorage.read_only", + "https://www.googleapis.com/auth/devstorage.read_write", + } +} + +// 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/storage/internal/apiv1/gapic_metadata.json b/storage/internal/apiv1/gapic_metadata.json new file mode 100644 index 000000000000..d7b93b754dec --- /dev/null +++ b/storage/internal/apiv1/gapic_metadata.json @@ -0,0 +1,298 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", + "language": "go", + "protoPackage": "google.storage.v1", + "libraryPackage": "cloud.google.com/go/storage/internal/apiv1", + "services": { + "Storage": { + "clients": { + "grpc": { + "libraryClient": "Client", + "rpcs": { + "ComposeObject": { + "methods": [ + "ComposeObject" + ] + }, + "CopyObject": { + "methods": [ + "CopyObject" + ] + }, + "CreateHmacKey": { + "methods": [ + "CreateHmacKey" + ] + }, + "DeleteBucket": { + "methods": [ + "DeleteBucket" + ] + }, + "DeleteBucketAccessControl": { + "methods": [ + "DeleteBucketAccessControl" + ] + }, + "DeleteDefaultObjectAccessControl": { + "methods": [ + "DeleteDefaultObjectAccessControl" + ] + }, + "DeleteHmacKey": { + "methods": [ + "DeleteHmacKey" + ] + }, + "DeleteNotification": { + "methods": [ + "DeleteNotification" + ] + }, + "DeleteObject": { + "methods": [ + "DeleteObject" + ] + }, + "DeleteObjectAccessControl": { + "methods": [ + "DeleteObjectAccessControl" + ] + }, + "GetBucket": { + "methods": [ + "GetBucket" + ] + }, + "GetBucketAccessControl": { + "methods": [ + "GetBucketAccessControl" + ] + }, + "GetBucketIamPolicy": { + "methods": [ + "GetBucketIamPolicy" + ] + }, + "GetDefaultObjectAccessControl": { + "methods": [ + "GetDefaultObjectAccessControl" + ] + }, + "GetHmacKey": { + "methods": [ + "GetHmacKey" + ] + }, + "GetNotification": { + "methods": [ + "GetNotification" + ] + }, + "GetObject": { + "methods": [ + "GetObject" + ] + }, + "GetObjectAccessControl": { + "methods": [ + "GetObjectAccessControl" + ] + }, + "GetObjectIamPolicy": { + "methods": [ + "GetObjectIamPolicy" + ] + }, + "GetObjectMedia": { + "methods": [ + "GetObjectMedia" + ] + }, + "GetServiceAccount": { + "methods": [ + "GetServiceAccount" + ] + }, + "InsertBucket": { + "methods": [ + "InsertBucket" + ] + }, + "InsertBucketAccessControl": { + "methods": [ + "InsertBucketAccessControl" + ] + }, + "InsertDefaultObjectAccessControl": { + "methods": [ + "InsertDefaultObjectAccessControl" + ] + }, + "InsertNotification": { + "methods": [ + "InsertNotification" + ] + }, + "InsertObject": { + "methods": [ + "InsertObject" + ] + }, + "InsertObjectAccessControl": { + "methods": [ + "InsertObjectAccessControl" + ] + }, + "ListBucketAccessControls": { + "methods": [ + "ListBucketAccessControls" + ] + }, + "ListBuckets": { + "methods": [ + "ListBuckets" + ] + }, + "ListChannels": { + "methods": [ + "ListChannels" + ] + }, + "ListDefaultObjectAccessControls": { + "methods": [ + "ListDefaultObjectAccessControls" + ] + }, + "ListHmacKeys": { + "methods": [ + "ListHmacKeys" + ] + }, + "ListNotifications": { + "methods": [ + "ListNotifications" + ] + }, + "ListObjectAccessControls": { + "methods": [ + "ListObjectAccessControls" + ] + }, + "ListObjects": { + "methods": [ + "ListObjects" + ] + }, + "LockBucketRetentionPolicy": { + "methods": [ + "LockBucketRetentionPolicy" + ] + }, + "PatchBucket": { + "methods": [ + "PatchBucket" + ] + }, + "PatchBucketAccessControl": { + "methods": [ + "PatchBucketAccessControl" + ] + }, + "PatchDefaultObjectAccessControl": { + "methods": [ + "PatchDefaultObjectAccessControl" + ] + }, + "PatchObject": { + "methods": [ + "PatchObject" + ] + }, + "PatchObjectAccessControl": { + "methods": [ + "PatchObjectAccessControl" + ] + }, + "QueryWriteStatus": { + "methods": [ + "QueryWriteStatus" + ] + }, + "RewriteObject": { + "methods": [ + "RewriteObject" + ] + }, + "SetBucketIamPolicy": { + "methods": [ + "SetBucketIamPolicy" + ] + }, + "SetObjectIamPolicy": { + "methods": [ + "SetObjectIamPolicy" + ] + }, + "StartResumableWrite": { + "methods": [ + "StartResumableWrite" + ] + }, + "StopChannel": { + "methods": [ + "StopChannel" + ] + }, + "TestBucketIamPermissions": { + "methods": [ + "TestBucketIamPermissions" + ] + }, + "TestObjectIamPermissions": { + "methods": [ + "TestObjectIamPermissions" + ] + }, + "UpdateBucket": { + "methods": [ + "UpdateBucket" + ] + }, + "UpdateBucketAccessControl": { + "methods": [ + "UpdateBucketAccessControl" + ] + }, + "UpdateDefaultObjectAccessControl": { + "methods": [ + "UpdateDefaultObjectAccessControl" + ] + }, + "UpdateHmacKey": { + "methods": [ + "UpdateHmacKey" + ] + }, + "UpdateObject": { + "methods": [ + "UpdateObject" + ] + }, + "UpdateObjectAccessControl": { + "methods": [ + "UpdateObjectAccessControl" + ] + }, + "WatchAllObjects": { + "methods": [ + "WatchAllObjects" + ] + } + } + } + } + } + } +} diff --git a/storage/internal/apiv1/storage_client.go b/storage/internal/apiv1/storage_client.go new file mode 100644 index 000000000000..05ee0ba1f84b --- /dev/null +++ b/storage/internal/apiv1/storage_client.go @@ -0,0 +1,2140 @@ +// Copyright 2021 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" + "math" + "time" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + iampb "google.golang.org/genproto/googleapis/iam/v1" + storagepb "google.golang.org/genproto/googleapis/storage/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newClientHook clientHook + +// CallOptions contains the retry settings for each method of Client. +type CallOptions struct { + DeleteBucketAccessControl []gax.CallOption + GetBucketAccessControl []gax.CallOption + InsertBucketAccessControl []gax.CallOption + ListBucketAccessControls []gax.CallOption + UpdateBucketAccessControl []gax.CallOption + PatchBucketAccessControl []gax.CallOption + DeleteBucket []gax.CallOption + GetBucket []gax.CallOption + InsertBucket []gax.CallOption + ListChannels []gax.CallOption + ListBuckets []gax.CallOption + LockBucketRetentionPolicy []gax.CallOption + GetBucketIamPolicy []gax.CallOption + SetBucketIamPolicy []gax.CallOption + TestBucketIamPermissions []gax.CallOption + PatchBucket []gax.CallOption + UpdateBucket []gax.CallOption + StopChannel []gax.CallOption + DeleteDefaultObjectAccessControl []gax.CallOption + GetDefaultObjectAccessControl []gax.CallOption + InsertDefaultObjectAccessControl []gax.CallOption + ListDefaultObjectAccessControls []gax.CallOption + PatchDefaultObjectAccessControl []gax.CallOption + UpdateDefaultObjectAccessControl []gax.CallOption + DeleteNotification []gax.CallOption + GetNotification []gax.CallOption + InsertNotification []gax.CallOption + ListNotifications []gax.CallOption + DeleteObjectAccessControl []gax.CallOption + GetObjectAccessControl []gax.CallOption + InsertObjectAccessControl []gax.CallOption + ListObjectAccessControls []gax.CallOption + PatchObjectAccessControl []gax.CallOption + UpdateObjectAccessControl []gax.CallOption + ComposeObject []gax.CallOption + CopyObject []gax.CallOption + DeleteObject []gax.CallOption + GetObject []gax.CallOption + GetObjectMedia []gax.CallOption + InsertObject []gax.CallOption + ListObjects []gax.CallOption + RewriteObject []gax.CallOption + StartResumableWrite []gax.CallOption + QueryWriteStatus []gax.CallOption + PatchObject []gax.CallOption + UpdateObject []gax.CallOption + GetObjectIamPolicy []gax.CallOption + SetObjectIamPolicy []gax.CallOption + TestObjectIamPermissions []gax.CallOption + WatchAllObjects []gax.CallOption + GetServiceAccount []gax.CallOption + CreateHmacKey []gax.CallOption + DeleteHmacKey []gax.CallOption + GetHmacKey []gax.CallOption + ListHmacKeys []gax.CallOption + UpdateHmacKey []gax.CallOption +} + +func defaultGRPCClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("storage.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("storage.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://storage.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultCallOptions() *CallOptions { + return &CallOptions{ + DeleteBucketAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetBucketAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + InsertBucketAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListBucketAccessControls: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + UpdateBucketAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + PatchBucketAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + DeleteBucket: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetBucket: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + InsertBucket: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListChannels: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListBuckets: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + LockBucketRetentionPolicy: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetBucketIamPolicy: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + SetBucketIamPolicy: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + TestBucketIamPermissions: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + PatchBucket: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + UpdateBucket: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + StopChannel: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + DeleteDefaultObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetDefaultObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + InsertDefaultObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListDefaultObjectAccessControls: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + PatchDefaultObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + UpdateDefaultObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + DeleteNotification: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetNotification: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + InsertNotification: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListNotifications: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + DeleteObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + InsertObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListObjectAccessControls: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + PatchObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + UpdateObjectAccessControl: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ComposeObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + CopyObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + DeleteObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetObjectMedia: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + InsertObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListObjects: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + RewriteObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + StartResumableWrite: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + QueryWriteStatus: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + PatchObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + UpdateObject: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetObjectIamPolicy: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + SetObjectIamPolicy: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + TestObjectIamPermissions: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + WatchAllObjects: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetServiceAccount: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + CreateHmacKey: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + DeleteHmacKey: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + GetHmacKey: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + ListHmacKeys: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + UpdateHmacKey: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.DeadlineExceeded, + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 60000 * time.Millisecond, + Multiplier: 2.00, + }) + }), + }, + } +} + +// internalClient is an interface that defines the methods availaible from Cloud Storage API. +type internalClient interface { + Close() error + setGoogleClientInfo(...string) + Connection() *grpc.ClientConn + DeleteBucketAccessControl(context.Context, *storagepb.DeleteBucketAccessControlRequest, ...gax.CallOption) error + GetBucketAccessControl(context.Context, *storagepb.GetBucketAccessControlRequest, ...gax.CallOption) (*storagepb.BucketAccessControl, error) + InsertBucketAccessControl(context.Context, *storagepb.InsertBucketAccessControlRequest, ...gax.CallOption) (*storagepb.BucketAccessControl, error) + ListBucketAccessControls(context.Context, *storagepb.ListBucketAccessControlsRequest, ...gax.CallOption) (*storagepb.ListBucketAccessControlsResponse, error) + UpdateBucketAccessControl(context.Context, *storagepb.UpdateBucketAccessControlRequest, ...gax.CallOption) (*storagepb.BucketAccessControl, error) + PatchBucketAccessControl(context.Context, *storagepb.PatchBucketAccessControlRequest, ...gax.CallOption) (*storagepb.BucketAccessControl, error) + DeleteBucket(context.Context, *storagepb.DeleteBucketRequest, ...gax.CallOption) error + GetBucket(context.Context, *storagepb.GetBucketRequest, ...gax.CallOption) (*storagepb.Bucket, error) + InsertBucket(context.Context, *storagepb.InsertBucketRequest, ...gax.CallOption) (*storagepb.Bucket, error) + ListChannels(context.Context, *storagepb.ListChannelsRequest, ...gax.CallOption) (*storagepb.ListChannelsResponse, error) + ListBuckets(context.Context, *storagepb.ListBucketsRequest, ...gax.CallOption) (*storagepb.ListBucketsResponse, error) + LockBucketRetentionPolicy(context.Context, *storagepb.LockRetentionPolicyRequest, ...gax.CallOption) (*storagepb.Bucket, error) + GetBucketIamPolicy(context.Context, *storagepb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) + SetBucketIamPolicy(context.Context, *storagepb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) + TestBucketIamPermissions(context.Context, *storagepb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) + PatchBucket(context.Context, *storagepb.PatchBucketRequest, ...gax.CallOption) (*storagepb.Bucket, error) + UpdateBucket(context.Context, *storagepb.UpdateBucketRequest, ...gax.CallOption) (*storagepb.Bucket, error) + StopChannel(context.Context, *storagepb.StopChannelRequest, ...gax.CallOption) error + DeleteDefaultObjectAccessControl(context.Context, *storagepb.DeleteDefaultObjectAccessControlRequest, ...gax.CallOption) error + GetDefaultObjectAccessControl(context.Context, *storagepb.GetDefaultObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + InsertDefaultObjectAccessControl(context.Context, *storagepb.InsertDefaultObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + ListDefaultObjectAccessControls(context.Context, *storagepb.ListDefaultObjectAccessControlsRequest, ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) + PatchDefaultObjectAccessControl(context.Context, *storagepb.PatchDefaultObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + UpdateDefaultObjectAccessControl(context.Context, *storagepb.UpdateDefaultObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + DeleteNotification(context.Context, *storagepb.DeleteNotificationRequest, ...gax.CallOption) error + GetNotification(context.Context, *storagepb.GetNotificationRequest, ...gax.CallOption) (*storagepb.Notification, error) + InsertNotification(context.Context, *storagepb.InsertNotificationRequest, ...gax.CallOption) (*storagepb.Notification, error) + ListNotifications(context.Context, *storagepb.ListNotificationsRequest, ...gax.CallOption) (*storagepb.ListNotificationsResponse, error) + DeleteObjectAccessControl(context.Context, *storagepb.DeleteObjectAccessControlRequest, ...gax.CallOption) error + GetObjectAccessControl(context.Context, *storagepb.GetObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + InsertObjectAccessControl(context.Context, *storagepb.InsertObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + ListObjectAccessControls(context.Context, *storagepb.ListObjectAccessControlsRequest, ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) + PatchObjectAccessControl(context.Context, *storagepb.PatchObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + UpdateObjectAccessControl(context.Context, *storagepb.UpdateObjectAccessControlRequest, ...gax.CallOption) (*storagepb.ObjectAccessControl, error) + ComposeObject(context.Context, *storagepb.ComposeObjectRequest, ...gax.CallOption) (*storagepb.Object, error) + CopyObject(context.Context, *storagepb.CopyObjectRequest, ...gax.CallOption) (*storagepb.Object, error) + DeleteObject(context.Context, *storagepb.DeleteObjectRequest, ...gax.CallOption) error + GetObject(context.Context, *storagepb.GetObjectRequest, ...gax.CallOption) (*storagepb.Object, error) + GetObjectMedia(context.Context, *storagepb.GetObjectMediaRequest, ...gax.CallOption) (storagepb.Storage_GetObjectMediaClient, error) + InsertObject(context.Context, ...gax.CallOption) (storagepb.Storage_InsertObjectClient, error) + ListObjects(context.Context, *storagepb.ListObjectsRequest, ...gax.CallOption) (*storagepb.ListObjectsResponse, error) + RewriteObject(context.Context, *storagepb.RewriteObjectRequest, ...gax.CallOption) (*storagepb.RewriteResponse, error) + StartResumableWrite(context.Context, *storagepb.StartResumableWriteRequest, ...gax.CallOption) (*storagepb.StartResumableWriteResponse, error) + QueryWriteStatus(context.Context, *storagepb.QueryWriteStatusRequest, ...gax.CallOption) (*storagepb.QueryWriteStatusResponse, error) + PatchObject(context.Context, *storagepb.PatchObjectRequest, ...gax.CallOption) (*storagepb.Object, error) + UpdateObject(context.Context, *storagepb.UpdateObjectRequest, ...gax.CallOption) (*storagepb.Object, error) + GetObjectIamPolicy(context.Context, *storagepb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) + SetObjectIamPolicy(context.Context, *storagepb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) + TestObjectIamPermissions(context.Context, *storagepb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) + WatchAllObjects(context.Context, *storagepb.WatchAllObjectsRequest, ...gax.CallOption) (*storagepb.Channel, error) + GetServiceAccount(context.Context, *storagepb.GetProjectServiceAccountRequest, ...gax.CallOption) (*storagepb.ServiceAccount, error) + CreateHmacKey(context.Context, *storagepb.CreateHmacKeyRequest, ...gax.CallOption) (*storagepb.CreateHmacKeyResponse, error) + DeleteHmacKey(context.Context, *storagepb.DeleteHmacKeyRequest, ...gax.CallOption) error + GetHmacKey(context.Context, *storagepb.GetHmacKeyRequest, ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) + ListHmacKeys(context.Context, *storagepb.ListHmacKeysRequest, ...gax.CallOption) (*storagepb.ListHmacKeysResponse, error) + UpdateHmacKey(context.Context, *storagepb.UpdateHmacKeyRequest, ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) +} + +// Client is a client for interacting with Cloud Storage API. +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type Client struct { + // The internal transport-dependent client. + internalClient + + // The call options for this service. + CallOptions *CallOptions + +} + +// GRPCClient is a client for interacting with Cloud Storage API over gRPC transport. +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type GRPCClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // Points back to the CallOptions field of the containing Client + CallOptions **CallOptions + + // The gRPC API client. + client storagepb.StorageClient + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewClient creates a new storage client based on gRPC. +// +// Manages Google Cloud Storage resources. +func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { + clientOpts := defaultGRPCClientOptions() + if newClientHook != nil { + hookOpts, err := newClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + client := Client{CallOptions: defaultCallOptions()} + + c := &GRPCClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + client: storagepb.NewStorageClient(connPool), + CallOptions: &client.CallOptions, + + } + c.setGoogleClientInfo() + + client.internalClient = c + + return &client, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *GRPCClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// 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 *GRPCClient) 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...)) +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *GRPCClient) Close() error { + return c.connPool.Close() +} + +// DeleteBucketAccessControl permanently deletes the ACL entry for the specified entity on the specified +// bucket. +func (c *GRPCClient) DeleteBucketAccessControl(ctx context.Context, req *storagepb.DeleteBucketAccessControlRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteBucketAccessControl[0:len((*c.CallOptions).DeleteBucketAccessControl):len((*c.CallOptions).DeleteBucketAccessControl)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteBucketAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetBucketAccessControl returns the ACL entry for the specified entity on the specified bucket. +func (c *GRPCClient) GetBucketAccessControl(ctx context.Context, req *storagepb.GetBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetBucketAccessControl[0:len((*c.CallOptions).GetBucketAccessControl):len((*c.CallOptions).GetBucketAccessControl)], opts...) + var resp *storagepb.BucketAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetBucketAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// InsertBucketAccessControl creates a new ACL entry on the specified bucket. +func (c *GRPCClient) InsertBucketAccessControl(ctx context.Context, req *storagepb.InsertBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).InsertBucketAccessControl[0:len((*c.CallOptions).InsertBucketAccessControl):len((*c.CallOptions).InsertBucketAccessControl)], opts...) + var resp *storagepb.BucketAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.InsertBucketAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListBucketAccessControls retrieves ACL entries on the specified bucket. +func (c *GRPCClient) ListBucketAccessControls(ctx context.Context, req *storagepb.ListBucketAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListBucketAccessControlsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListBucketAccessControls[0:len((*c.CallOptions).ListBucketAccessControls):len((*c.CallOptions).ListBucketAccessControls)], opts...) + var resp *storagepb.ListBucketAccessControlsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListBucketAccessControls(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateBucketAccessControl updates an ACL entry on the specified bucket. Equivalent to +// PatchBucketAccessControl, but all unspecified fields will be +// reset to their default values. +func (c *GRPCClient) UpdateBucketAccessControl(ctx context.Context, req *storagepb.UpdateBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).UpdateBucketAccessControl[0:len((*c.CallOptions).UpdateBucketAccessControl):len((*c.CallOptions).UpdateBucketAccessControl)], opts...) + var resp *storagepb.BucketAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateBucketAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// PatchBucketAccessControl updates an ACL entry on the specified bucket. +func (c *GRPCClient) PatchBucketAccessControl(ctx context.Context, req *storagepb.PatchBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).PatchBucketAccessControl[0:len((*c.CallOptions).PatchBucketAccessControl):len((*c.CallOptions).PatchBucketAccessControl)], opts...) + var resp *storagepb.BucketAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.PatchBucketAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeleteBucket permanently deletes an empty bucket. +func (c *GRPCClient) DeleteBucket(ctx context.Context, req *storagepb.DeleteBucketRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteBucket[0:len((*c.CallOptions).DeleteBucket):len((*c.CallOptions).DeleteBucket)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteBucket(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetBucket returns metadata for the specified bucket. +func (c *GRPCClient) GetBucket(ctx context.Context, req *storagepb.GetBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetBucket[0:len((*c.CallOptions).GetBucket):len((*c.CallOptions).GetBucket)], opts...) + var resp *storagepb.Bucket + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetBucket(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// InsertBucket creates a new bucket. +func (c *GRPCClient) InsertBucket(ctx context.Context, req *storagepb.InsertBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).InsertBucket[0:len((*c.CallOptions).InsertBucket):len((*c.CallOptions).InsertBucket)], opts...) + var resp *storagepb.Bucket + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.InsertBucket(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListChannels list active object change notification channels for this bucket. +func (c *GRPCClient) ListChannels(ctx context.Context, req *storagepb.ListChannelsRequest, opts ...gax.CallOption) (*storagepb.ListChannelsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListChannels[0:len((*c.CallOptions).ListChannels):len((*c.CallOptions).ListChannels)], opts...) + var resp *storagepb.ListChannelsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListChannels(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListBuckets retrieves a list of buckets for a given project. +func (c *GRPCClient) ListBuckets(ctx context.Context, req *storagepb.ListBucketsRequest, opts ...gax.CallOption) (*storagepb.ListBucketsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListBuckets[0:len((*c.CallOptions).ListBuckets):len((*c.CallOptions).ListBuckets)], opts...) + var resp *storagepb.ListBucketsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListBuckets(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// LockBucketRetentionPolicy locks retention policy on a bucket. +func (c *GRPCClient) LockBucketRetentionPolicy(ctx context.Context, req *storagepb.LockRetentionPolicyRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).LockBucketRetentionPolicy[0:len((*c.CallOptions).LockBucketRetentionPolicy):len((*c.CallOptions).LockBucketRetentionPolicy)], opts...) + var resp *storagepb.Bucket + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.LockBucketRetentionPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetBucketIamPolicy gets the IAM policy for the specified bucket. +func (c *GRPCClient) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetBucketIamPolicy[0:len((*c.CallOptions).GetBucketIamPolicy):len((*c.CallOptions).GetBucketIamPolicy)], opts...) + var resp *iampb.Policy + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetBucketIamPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// SetBucketIamPolicy updates an IAM policy for the specified bucket. +func (c *GRPCClient) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).SetBucketIamPolicy[0:len((*c.CallOptions).SetBucketIamPolicy):len((*c.CallOptions).SetBucketIamPolicy)], opts...) + var resp *iampb.Policy + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.SetBucketIamPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// TestBucketIamPermissions tests a set of permissions on the given bucket to see which, if +// any, are held by the caller. +func (c *GRPCClient) TestBucketIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).TestBucketIamPermissions[0:len((*c.CallOptions).TestBucketIamPermissions):len((*c.CallOptions).TestBucketIamPermissions)], opts...) + var resp *iampb.TestIamPermissionsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.TestBucketIamPermissions(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// PatchBucket updates a bucket. Changes to the bucket will be readable immediately after +// writing, but configuration changes may take time to propagate. +func (c *GRPCClient) PatchBucket(ctx context.Context, req *storagepb.PatchBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).PatchBucket[0:len((*c.CallOptions).PatchBucket):len((*c.CallOptions).PatchBucket)], opts...) + var resp *storagepb.Bucket + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.PatchBucket(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateBucket updates a bucket. Equivalent to PatchBucket, but always replaces all +// mutatable fields of the bucket with new values, reverting all +// unspecified fields to their default values. +// Like PatchBucket, Changes to the bucket will be readable immediately after +// writing, but configuration changes may take time to propagate. +func (c *GRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).UpdateBucket[0:len((*c.CallOptions).UpdateBucket):len((*c.CallOptions).UpdateBucket)], opts...) + var resp *storagepb.Bucket + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateBucket(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// StopChannel halts “Object Change Notification” push messagages. +// See https://cloud.google.com/storage/docs/object-change-notification (at https://cloud.google.com/storage/docs/object-change-notification) +// Note: this is not related to the newer “Notifications” resource, which +// are stopped using DeleteNotification. +func (c *GRPCClient) StopChannel(ctx context.Context, req *storagepb.StopChannelRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).StopChannel[0:len((*c.CallOptions).StopChannel):len((*c.CallOptions).StopChannel)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.StopChannel(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// DeleteDefaultObjectAccessControl permanently deletes the default object ACL entry for the specified entity +// on the specified bucket. +func (c *GRPCClient) DeleteDefaultObjectAccessControl(ctx context.Context, req *storagepb.DeleteDefaultObjectAccessControlRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteDefaultObjectAccessControl[0:len((*c.CallOptions).DeleteDefaultObjectAccessControl):len((*c.CallOptions).DeleteDefaultObjectAccessControl)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteDefaultObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetDefaultObjectAccessControl returns the default object ACL entry for the specified entity on the +// specified bucket. +func (c *GRPCClient) GetDefaultObjectAccessControl(ctx context.Context, req *storagepb.GetDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetDefaultObjectAccessControl[0:len((*c.CallOptions).GetDefaultObjectAccessControl):len((*c.CallOptions).GetDefaultObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetDefaultObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// InsertDefaultObjectAccessControl creates a new default object ACL entry on the specified bucket. +func (c *GRPCClient) InsertDefaultObjectAccessControl(ctx context.Context, req *storagepb.InsertDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).InsertDefaultObjectAccessControl[0:len((*c.CallOptions).InsertDefaultObjectAccessControl):len((*c.CallOptions).InsertDefaultObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.InsertDefaultObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListDefaultObjectAccessControls retrieves default object ACL entries on the specified bucket. +func (c *GRPCClient) ListDefaultObjectAccessControls(ctx context.Context, req *storagepb.ListDefaultObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListDefaultObjectAccessControls[0:len((*c.CallOptions).ListDefaultObjectAccessControls):len((*c.CallOptions).ListDefaultObjectAccessControls)], opts...) + var resp *storagepb.ListObjectAccessControlsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListDefaultObjectAccessControls(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// PatchDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. +func (c *GRPCClient) PatchDefaultObjectAccessControl(ctx context.Context, req *storagepb.PatchDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).PatchDefaultObjectAccessControl[0:len((*c.CallOptions).PatchDefaultObjectAccessControl):len((*c.CallOptions).PatchDefaultObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.PatchDefaultObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. Equivalent to +// PatchDefaultObjectAccessControl, but modifies all unspecified fields to +// their default values. +func (c *GRPCClient) UpdateDefaultObjectAccessControl(ctx context.Context, req *storagepb.UpdateDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).UpdateDefaultObjectAccessControl[0:len((*c.CallOptions).UpdateDefaultObjectAccessControl):len((*c.CallOptions).UpdateDefaultObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateDefaultObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeleteNotification permanently deletes a notification subscription. +// Note: Older, “Object Change Notification” push subscriptions should be +// deleted using StopChannel instead. +func (c *GRPCClient) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteNotification[0:len((*c.CallOptions).DeleteNotification):len((*c.CallOptions).DeleteNotification)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteNotification(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetNotification view a notification configuration. +func (c *GRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetNotification[0:len((*c.CallOptions).GetNotification):len((*c.CallOptions).GetNotification)], opts...) + var resp *storagepb.Notification + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetNotification(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// InsertNotification creates a notification subscription for a given bucket. +// These notifications, when triggered, publish messages to the specified +// Cloud Pub/Sub topics. +// See https://cloud.google.com/storage/docs/pubsub-notifications (at https://cloud.google.com/storage/docs/pubsub-notifications). +func (c *GRPCClient) InsertNotification(ctx context.Context, req *storagepb.InsertNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).InsertNotification[0:len((*c.CallOptions).InsertNotification):len((*c.CallOptions).InsertNotification)], opts...) + var resp *storagepb.Notification + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.InsertNotification(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListNotifications retrieves a list of notification subscriptions for a given bucket. +func (c *GRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) (*storagepb.ListNotificationsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListNotifications[0:len((*c.CallOptions).ListNotifications):len((*c.CallOptions).ListNotifications)], opts...) + var resp *storagepb.ListNotificationsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListNotifications(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeleteObjectAccessControl permanently deletes the ACL entry for the specified entity on the specified +// object. +func (c *GRPCClient) DeleteObjectAccessControl(ctx context.Context, req *storagepb.DeleteObjectAccessControlRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteObjectAccessControl[0:len((*c.CallOptions).DeleteObjectAccessControl):len((*c.CallOptions).DeleteObjectAccessControl)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetObjectAccessControl returns the ACL entry for the specified entity on the specified object. +func (c *GRPCClient) GetObjectAccessControl(ctx context.Context, req *storagepb.GetObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetObjectAccessControl[0:len((*c.CallOptions).GetObjectAccessControl):len((*c.CallOptions).GetObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// InsertObjectAccessControl creates a new ACL entry on the specified object. +func (c *GRPCClient) InsertObjectAccessControl(ctx context.Context, req *storagepb.InsertObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).InsertObjectAccessControl[0:len((*c.CallOptions).InsertObjectAccessControl):len((*c.CallOptions).InsertObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.InsertObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListObjectAccessControls retrieves ACL entries on the specified object. +func (c *GRPCClient) ListObjectAccessControls(ctx context.Context, req *storagepb.ListObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListObjectAccessControls[0:len((*c.CallOptions).ListObjectAccessControls):len((*c.CallOptions).ListObjectAccessControls)], opts...) + var resp *storagepb.ListObjectAccessControlsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListObjectAccessControls(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// PatchObjectAccessControl patches an ACL entry on the specified object. Patch is similar to update, +// but only applies or appends the specified fields in the +// object_access_control object. Other fields are unaffected. +func (c *GRPCClient) PatchObjectAccessControl(ctx context.Context, req *storagepb.PatchObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).PatchObjectAccessControl[0:len((*c.CallOptions).PatchObjectAccessControl):len((*c.CallOptions).PatchObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.PatchObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateObjectAccessControl updates an ACL entry on the specified object. +func (c *GRPCClient) UpdateObjectAccessControl(ctx context.Context, req *storagepb.UpdateObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).UpdateObjectAccessControl[0:len((*c.CallOptions).UpdateObjectAccessControl):len((*c.CallOptions).UpdateObjectAccessControl)], opts...) + var resp *storagepb.ObjectAccessControl + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateObjectAccessControl(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ComposeObject concatenates a list of existing objects into a new object in the same +// bucket. +func (c *GRPCClient) ComposeObject(ctx context.Context, req *storagepb.ComposeObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ComposeObject[0:len((*c.CallOptions).ComposeObject):len((*c.CallOptions).ComposeObject)], opts...) + var resp *storagepb.Object + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ComposeObject(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CopyObject copies a source object to a destination object. Optionally overrides +// metadata. +func (c *GRPCClient) CopyObject(ctx context.Context, req *storagepb.CopyObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).CopyObject[0:len((*c.CallOptions).CopyObject):len((*c.CallOptions).CopyObject)], opts...) + var resp *storagepb.Object + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.CopyObject(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeleteObject deletes an object and its metadata. Deletions are permanent if versioning +// is not enabled for the bucket, or if the generation parameter +// is used. +func (c *GRPCClient) DeleteObject(ctx context.Context, req *storagepb.DeleteObjectRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteObject[0:len((*c.CallOptions).DeleteObject):len((*c.CallOptions).DeleteObject)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteObject(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetObject retrieves an object’s metadata. +func (c *GRPCClient) GetObject(ctx context.Context, req *storagepb.GetObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetObject[0:len((*c.CallOptions).GetObject):len((*c.CallOptions).GetObject)], opts...) + var resp *storagepb.Object + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetObject(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetObjectMedia reads an object’s data. +func (c *GRPCClient) GetObjectMedia(ctx context.Context, req *storagepb.GetObjectMediaRequest, opts ...gax.CallOption) (storagepb.Storage_GetObjectMediaClient, error) { + ctx = insertMetadata(ctx, c.xGoogMetadata) + var resp storagepb.Storage_GetObjectMediaClient + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetObjectMedia(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// InsertObject stores a new object and metadata. +// +// An object can be written either in a single message stream or in a +// resumable sequence of message streams. To write using a single stream, +// the client should include in the first message of the stream an +// InsertObjectSpec describing the destination bucket, object, and any +// preconditions. Additionally, the final message must set ‘finish_write’ to +// true, or else it is an error. +// +// For a resumable write, the client should instead call +// StartResumableWrite() and provide that method an InsertObjectSpec. +// They should then attach the returned upload_id to the first message of +// each following call to Insert. If there is an error or the connection is +// broken during the resumable Insert(), the client should check the status +// of the Insert() by calling QueryWriteStatus() and continue writing from +// the returned committed_size. This may be less than the amount of data the +// client previously sent. +// +// The service will not view the object as complete until the client has +// sent an Insert with finish_write set to true. Sending any +// requests on a stream after sending a request with finish_write set to +// true will cause an error. The client should check the +// Object it receives to determine how much data the service was +// able to commit and whether the service views the object as complete. +func (c *GRPCClient) InsertObject(ctx context.Context, opts ...gax.CallOption) (storagepb.Storage_InsertObjectClient, error) { + ctx = insertMetadata(ctx, c.xGoogMetadata) + var resp storagepb.Storage_InsertObjectClient + opts = append((*c.CallOptions).InsertObject[0:len((*c.CallOptions).InsertObject):len((*c.CallOptions).InsertObject)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.InsertObject(ctx, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListObjects retrieves a list of objects matching the criteria. +func (c *GRPCClient) ListObjects(ctx context.Context, req *storagepb.ListObjectsRequest, opts ...gax.CallOption) (*storagepb.ListObjectsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListObjects[0:len((*c.CallOptions).ListObjects):len((*c.CallOptions).ListObjects)], opts...) + var resp *storagepb.ListObjectsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListObjects(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// RewriteObject rewrites a source object to a destination object. Optionally overrides +// metadata. +func (c *GRPCClient) RewriteObject(ctx context.Context, req *storagepb.RewriteObjectRequest, opts ...gax.CallOption) (*storagepb.RewriteResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).RewriteObject[0:len((*c.CallOptions).RewriteObject):len((*c.CallOptions).RewriteObject)], opts...) + var resp *storagepb.RewriteResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.RewriteObject(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// StartResumableWrite starts a resumable write. How long the write operation remains valid, and +// what happens when the write operation becomes invalid, are +// service-dependent. +func (c *GRPCClient) StartResumableWrite(ctx context.Context, req *storagepb.StartResumableWriteRequest, opts ...gax.CallOption) (*storagepb.StartResumableWriteResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).StartResumableWrite[0:len((*c.CallOptions).StartResumableWrite):len((*c.CallOptions).StartResumableWrite)], opts...) + var resp *storagepb.StartResumableWriteResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.StartResumableWrite(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// QueryWriteStatus determines the committed_size for an object that is being written, which +// can then be used as the write_offset for the next Write() call. +// +// If the object does not exist (i.e., the object has been deleted, or the +// first Write() has not yet reached the service), this method returns the +// error NOT_FOUND. +// +// The client may call QueryWriteStatus() at any time to determine how +// much data has been processed for this object. This is useful if the +// client is buffering data and needs to know which data can be safely +// evicted. For any sequence of QueryWriteStatus() calls for a given +// object name, the sequence of returned committed_size values will be +// non-decreasing. +func (c *GRPCClient) QueryWriteStatus(ctx context.Context, req *storagepb.QueryWriteStatusRequest, opts ...gax.CallOption) (*storagepb.QueryWriteStatusResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).QueryWriteStatus[0:len((*c.CallOptions).QueryWriteStatus):len((*c.CallOptions).QueryWriteStatus)], opts...) + var resp *storagepb.QueryWriteStatusResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.QueryWriteStatus(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// PatchObject updates an object’s metadata. +func (c *GRPCClient) PatchObject(ctx context.Context, req *storagepb.PatchObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).PatchObject[0:len((*c.CallOptions).PatchObject):len((*c.CallOptions).PatchObject)], opts...) + var resp *storagepb.Object + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.PatchObject(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateObject updates an object’s metadata. Equivalent to PatchObject, but always +// replaces all mutatable fields of the bucket with new values, reverting all +// unspecified fields to their default values. +func (c *GRPCClient) UpdateObject(ctx context.Context, req *storagepb.UpdateObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).UpdateObject[0:len((*c.CallOptions).UpdateObject):len((*c.CallOptions).UpdateObject)], opts...) + var resp *storagepb.Object + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateObject(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetObjectIamPolicy gets the IAM policy for the specified object. +func (c *GRPCClient) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetObjectIamPolicy[0:len((*c.CallOptions).GetObjectIamPolicy):len((*c.CallOptions).GetObjectIamPolicy)], opts...) + var resp *iampb.Policy + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetObjectIamPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// SetObjectIamPolicy updates an IAM policy for the specified object. +func (c *GRPCClient) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).SetObjectIamPolicy[0:len((*c.CallOptions).SetObjectIamPolicy):len((*c.CallOptions).SetObjectIamPolicy)], opts...) + var resp *iampb.Policy + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.SetObjectIamPolicy(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// TestObjectIamPermissions tests a set of permissions on the given object to see which, if +// any, are held by the caller. +func (c *GRPCClient) TestObjectIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).TestObjectIamPermissions[0:len((*c.CallOptions).TestObjectIamPermissions):len((*c.CallOptions).TestObjectIamPermissions)], opts...) + var resp *iampb.TestIamPermissionsResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.TestObjectIamPermissions(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// WatchAllObjects watch for changes on all objects in a bucket. +func (c *GRPCClient) WatchAllObjects(ctx context.Context, req *storagepb.WatchAllObjectsRequest, opts ...gax.CallOption) (*storagepb.Channel, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).WatchAllObjects[0:len((*c.CallOptions).WatchAllObjects):len((*c.CallOptions).WatchAllObjects)], opts...) + var resp *storagepb.Channel + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.WatchAllObjects(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// GetServiceAccount retrieves the name of a project’s Google Cloud Storage service account. +func (c *GRPCClient) GetServiceAccount(ctx context.Context, req *storagepb.GetProjectServiceAccountRequest, opts ...gax.CallOption) (*storagepb.ServiceAccount, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetServiceAccount[0:len((*c.CallOptions).GetServiceAccount):len((*c.CallOptions).GetServiceAccount)], opts...) + var resp *storagepb.ServiceAccount + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetServiceAccount(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateHmacKey creates a new HMAC key for the given service account. +func (c *GRPCClient) CreateHmacKey(ctx context.Context, req *storagepb.CreateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.CreateHmacKeyResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).CreateHmacKey[0:len((*c.CallOptions).CreateHmacKey):len((*c.CallOptions).CreateHmacKey)], opts...) + var resp *storagepb.CreateHmacKeyResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.CreateHmacKey(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeleteHmacKey deletes a given HMAC key. Key must be in an INACTIVE state. +func (c *GRPCClient) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHmacKeyRequest, opts ...gax.CallOption) error { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).DeleteHmacKey[0:len((*c.CallOptions).DeleteHmacKey):len((*c.CallOptions).DeleteHmacKey)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.client.DeleteHmacKey(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetHmacKey gets an existing HMAC key metadata for the given id. +func (c *GRPCClient) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).GetHmacKey[0:len((*c.CallOptions).GetHmacKey):len((*c.CallOptions).GetHmacKey)], opts...) + var resp *storagepb.HmacKeyMetadata + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.GetHmacKey(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// ListHmacKeys lists HMAC keys under a given project with the additional filters provided. +func (c *GRPCClient) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKeysRequest, opts ...gax.CallOption) (*storagepb.ListHmacKeysResponse, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).ListHmacKeys[0:len((*c.CallOptions).ListHmacKeys):len((*c.CallOptions).ListHmacKeys)], opts...) + var resp *storagepb.ListHmacKeysResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.ListHmacKeys(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateHmacKey updates a given HMAC key state between ACTIVE and INACTIVE. +func (c *GRPCClient) UpdateHmacKey(ctx context.Context, req *storagepb.UpdateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { + if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { + cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + defer cancel() + ctx = cctx + } + ctx = insertMetadata(ctx, c.xGoogMetadata) + opts = append((*c.CallOptions).UpdateHmacKey[0:len((*c.CallOptions).UpdateHmacKey):len((*c.CallOptions).UpdateHmacKey)], opts...) + var resp *storagepb.HmacKeyMetadata + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.client.UpdateHmacKey(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/storage/internal/apiv1/storage_client_example_test.go b/storage/internal/apiv1/storage_client_example_test.go new file mode 100644 index 000000000000..6591fc9d209e --- /dev/null +++ b/storage/internal/apiv1/storage_client_example_test.go @@ -0,0 +1,1082 @@ +// Copyright 2021 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/storage/internal/apiv1" + storagepb "google.golang.org/genproto/googleapis/storage/v1" +) + +func ExampleNewClient() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleClient_DeleteBucketAccessControl() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteBucketAccessControlRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetBucketAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetBucketAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertBucketAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.InsertBucketAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.InsertBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListBucketAccessControls() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListBucketAccessControlsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListBucketAccessControls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateBucketAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.UpdateBucketAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchBucketAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.PatchBucketAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PatchBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_DeleteBucket() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteBucketRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetBucket() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetBucketRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertBucket() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.InsertBucketRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.InsertBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListChannels() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListChannelsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListChannels(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListBuckets() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListBucketsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListBuckets(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_LockBucketRetentionPolicy() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.LockRetentionPolicyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.LockBucketRetentionPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetBucketIamPolicy() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetIamPolicyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetBucketIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_SetBucketIamPolicy() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.SetIamPolicyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.SetBucketIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_TestBucketIamPermissions() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.TestIamPermissionsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.TestBucketIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchBucket() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.PatchBucketRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PatchBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateBucket() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.UpdateBucketRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_StopChannel() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.StopChannelRequest{ + // TODO: Fill request struct fields. + } + err = c.StopChannel(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_DeleteDefaultObjectAccessControl() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteDefaultObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetDefaultObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetDefaultObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertDefaultObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.InsertDefaultObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.InsertDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListDefaultObjectAccessControls() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListDefaultObjectAccessControlsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListDefaultObjectAccessControls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchDefaultObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.PatchDefaultObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PatchDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateDefaultObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.UpdateDefaultObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_DeleteNotification() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteNotificationRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteNotification(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetNotification() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetNotificationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetNotification(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertNotification() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.InsertNotificationRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.InsertNotification(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListNotifications() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListNotificationsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListNotifications(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_DeleteObjectAccessControl() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.InsertObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.InsertObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListObjectAccessControls() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListObjectAccessControlsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListObjectAccessControls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.PatchObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PatchObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateObjectAccessControl() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.UpdateObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ComposeObject() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ComposeObjectRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ComposeObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_CopyObject() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.CopyObjectRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CopyObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_DeleteObject() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteObjectRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteObject(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetObject() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetObjectRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListObjects() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListObjectsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListObjects(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_RewriteObject() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.RewriteObjectRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.RewriteObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_StartResumableWrite() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.StartResumableWriteRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.StartResumableWrite(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_QueryWriteStatus() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.QueryWriteStatusRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.QueryWriteStatus(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchObject() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.PatchObjectRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PatchObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateObject() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.UpdateObjectRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetObjectIamPolicy() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetIamPolicyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetObjectIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_SetObjectIamPolicy() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.SetIamPolicyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.SetObjectIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_TestObjectIamPermissions() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.TestIamPermissionsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.TestObjectIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_WatchAllObjects() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.WatchAllObjectsRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.WatchAllObjects(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetServiceAccount() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetProjectServiceAccountRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetServiceAccount(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_CreateHmacKey() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.CreateHmacKeyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.CreateHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_DeleteHmacKey() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.DeleteHmacKeyRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetHmacKey() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.GetHmacKeyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListHmacKeys() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.ListHmacKeysRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.ListHmacKeys(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateHmacKey() { + // import storagepb "google.golang.org/genproto/googleapis/storage/v1" + + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &storagepb.UpdateHmacKeyRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.UpdateHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} From 9eb7d7a3b26ce9d12797138ca2f0685c9ee71dc0 Mon Sep 17 00:00:00 2001 From: noahdietz Date: Tue, 15 Jun 2021 15:59:40 -0700 Subject: [PATCH 2/6] regen and reformat --- storage/internal/apiv1/doc.go | 3 +- storage/internal/apiv1/storage_client.go | 224 +++++++++++------------ 2 files changed, 112 insertions(+), 115 deletions(-) diff --git a/storage/internal/apiv1/doc.go b/storage/internal/apiv1/doc.go index 5310ba49372b..ea45239e75cf 100644 --- a/storage/internal/apiv1/doc.go +++ b/storage/internal/apiv1/doc.go @@ -35,8 +35,8 @@ import ( "context" "os" "runtime" - "strings" "strconv" + "strings" "unicode" "google.golang.org/api/option" @@ -118,4 +118,3 @@ func versionGo() string { } return "UNKNOWN" } - diff --git a/storage/internal/apiv1/storage_client.go b/storage/internal/apiv1/storage_client.go index 05ee0ba1f84b..2f4c597dd9a0 100644 --- a/storage/internal/apiv1/storage_client.go +++ b/storage/internal/apiv1/storage_client.go @@ -36,62 +36,62 @@ var newClientHook clientHook // CallOptions contains the retry settings for each method of Client. type CallOptions struct { - DeleteBucketAccessControl []gax.CallOption - GetBucketAccessControl []gax.CallOption - InsertBucketAccessControl []gax.CallOption - ListBucketAccessControls []gax.CallOption - UpdateBucketAccessControl []gax.CallOption - PatchBucketAccessControl []gax.CallOption - DeleteBucket []gax.CallOption - GetBucket []gax.CallOption - InsertBucket []gax.CallOption - ListChannels []gax.CallOption - ListBuckets []gax.CallOption - LockBucketRetentionPolicy []gax.CallOption - GetBucketIamPolicy []gax.CallOption - SetBucketIamPolicy []gax.CallOption - TestBucketIamPermissions []gax.CallOption - PatchBucket []gax.CallOption - UpdateBucket []gax.CallOption - StopChannel []gax.CallOption + DeleteBucketAccessControl []gax.CallOption + GetBucketAccessControl []gax.CallOption + InsertBucketAccessControl []gax.CallOption + ListBucketAccessControls []gax.CallOption + UpdateBucketAccessControl []gax.CallOption + PatchBucketAccessControl []gax.CallOption + DeleteBucket []gax.CallOption + GetBucket []gax.CallOption + InsertBucket []gax.CallOption + ListChannels []gax.CallOption + ListBuckets []gax.CallOption + LockBucketRetentionPolicy []gax.CallOption + GetBucketIamPolicy []gax.CallOption + SetBucketIamPolicy []gax.CallOption + TestBucketIamPermissions []gax.CallOption + PatchBucket []gax.CallOption + UpdateBucket []gax.CallOption + StopChannel []gax.CallOption DeleteDefaultObjectAccessControl []gax.CallOption - GetDefaultObjectAccessControl []gax.CallOption + GetDefaultObjectAccessControl []gax.CallOption InsertDefaultObjectAccessControl []gax.CallOption - ListDefaultObjectAccessControls []gax.CallOption - PatchDefaultObjectAccessControl []gax.CallOption + ListDefaultObjectAccessControls []gax.CallOption + PatchDefaultObjectAccessControl []gax.CallOption UpdateDefaultObjectAccessControl []gax.CallOption - DeleteNotification []gax.CallOption - GetNotification []gax.CallOption - InsertNotification []gax.CallOption - ListNotifications []gax.CallOption - DeleteObjectAccessControl []gax.CallOption - GetObjectAccessControl []gax.CallOption - InsertObjectAccessControl []gax.CallOption - ListObjectAccessControls []gax.CallOption - PatchObjectAccessControl []gax.CallOption - UpdateObjectAccessControl []gax.CallOption - ComposeObject []gax.CallOption - CopyObject []gax.CallOption - DeleteObject []gax.CallOption - GetObject []gax.CallOption - GetObjectMedia []gax.CallOption - InsertObject []gax.CallOption - ListObjects []gax.CallOption - RewriteObject []gax.CallOption - StartResumableWrite []gax.CallOption - QueryWriteStatus []gax.CallOption - PatchObject []gax.CallOption - UpdateObject []gax.CallOption - GetObjectIamPolicy []gax.CallOption - SetObjectIamPolicy []gax.CallOption - TestObjectIamPermissions []gax.CallOption - WatchAllObjects []gax.CallOption - GetServiceAccount []gax.CallOption - CreateHmacKey []gax.CallOption - DeleteHmacKey []gax.CallOption - GetHmacKey []gax.CallOption - ListHmacKeys []gax.CallOption - UpdateHmacKey []gax.CallOption + DeleteNotification []gax.CallOption + GetNotification []gax.CallOption + InsertNotification []gax.CallOption + ListNotifications []gax.CallOption + DeleteObjectAccessControl []gax.CallOption + GetObjectAccessControl []gax.CallOption + InsertObjectAccessControl []gax.CallOption + ListObjectAccessControls []gax.CallOption + PatchObjectAccessControl []gax.CallOption + UpdateObjectAccessControl []gax.CallOption + ComposeObject []gax.CallOption + CopyObject []gax.CallOption + DeleteObject []gax.CallOption + GetObject []gax.CallOption + GetObjectMedia []gax.CallOption + InsertObject []gax.CallOption + ListObjects []gax.CallOption + RewriteObject []gax.CallOption + StartResumableWrite []gax.CallOption + QueryWriteStatus []gax.CallOption + PatchObject []gax.CallOption + UpdateObject []gax.CallOption + GetObjectIamPolicy []gax.CallOption + SetObjectIamPolicy []gax.CallOption + TestObjectIamPermissions []gax.CallOption + WatchAllObjects []gax.CallOption + GetServiceAccount []gax.CallOption + CreateHmacKey []gax.CallOption + DeleteHmacKey []gax.CallOption + GetHmacKey []gax.CallOption + ListHmacKeys []gax.CallOption + UpdateHmacKey []gax.CallOption } func defaultGRPCClientOptions() []option.ClientOption { @@ -102,7 +102,7 @@ func defaultGRPCClientOptions() []option.ClientOption { internaloption.WithDefaultScopes(DefaultAuthScopes()...), option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), option.WithGRPCDialOption(grpc.WithDefaultCallOptions( - grpc.MaxCallRecvMsgSize(math.MaxInt32))), + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } @@ -854,7 +854,6 @@ type Client struct { // The call options for this service. CallOptions *CallOptions - } // GRPCClient is a client for interacting with Cloud Storage API over gRPC transport. @@ -902,11 +901,10 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error client := Client{CallOptions: defaultCallOptions()} c := &GRPCClient{ - connPool: connPool, + connPool: connPool, disableDeadlines: disableDeadlines, - client: storagepb.NewStorageClient(connPool), - CallOptions: &client.CallOptions, - + client: storagepb.NewStorageClient(connPool), + CallOptions: &client.CallOptions, } c.setGoogleClientInfo() @@ -941,7 +939,7 @@ func (c *GRPCClient) Close() error { // bucket. func (c *GRPCClient) DeleteBucketAccessControl(ctx context.Context, req *storagepb.DeleteBucketAccessControlRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -958,7 +956,7 @@ func (c *GRPCClient) DeleteBucketAccessControl(ctx context.Context, req *storage // GetBucketAccessControl returns the ACL entry for the specified entity on the specified bucket. func (c *GRPCClient) GetBucketAccessControl(ctx context.Context, req *storagepb.GetBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -979,7 +977,7 @@ func (c *GRPCClient) GetBucketAccessControl(ctx context.Context, req *storagepb. // InsertBucketAccessControl creates a new ACL entry on the specified bucket. func (c *GRPCClient) InsertBucketAccessControl(ctx context.Context, req *storagepb.InsertBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1000,7 +998,7 @@ func (c *GRPCClient) InsertBucketAccessControl(ctx context.Context, req *storage // ListBucketAccessControls retrieves ACL entries on the specified bucket. func (c *GRPCClient) ListBucketAccessControls(ctx context.Context, req *storagepb.ListBucketAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListBucketAccessControlsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1023,7 +1021,7 @@ func (c *GRPCClient) ListBucketAccessControls(ctx context.Context, req *storagep // reset to their default values. func (c *GRPCClient) UpdateBucketAccessControl(ctx context.Context, req *storagepb.UpdateBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1044,7 +1042,7 @@ func (c *GRPCClient) UpdateBucketAccessControl(ctx context.Context, req *storage // PatchBucketAccessControl updates an ACL entry on the specified bucket. func (c *GRPCClient) PatchBucketAccessControl(ctx context.Context, req *storagepb.PatchBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1065,7 +1063,7 @@ func (c *GRPCClient) PatchBucketAccessControl(ctx context.Context, req *storagep // DeleteBucket permanently deletes an empty bucket. func (c *GRPCClient) DeleteBucket(ctx context.Context, req *storagepb.DeleteBucketRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1082,7 +1080,7 @@ func (c *GRPCClient) DeleteBucket(ctx context.Context, req *storagepb.DeleteBuck // GetBucket returns metadata for the specified bucket. func (c *GRPCClient) GetBucket(ctx context.Context, req *storagepb.GetBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1103,7 +1101,7 @@ func (c *GRPCClient) GetBucket(ctx context.Context, req *storagepb.GetBucketRequ // InsertBucket creates a new bucket. func (c *GRPCClient) InsertBucket(ctx context.Context, req *storagepb.InsertBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1124,7 +1122,7 @@ func (c *GRPCClient) InsertBucket(ctx context.Context, req *storagepb.InsertBuck // ListChannels list active object change notification channels for this bucket. func (c *GRPCClient) ListChannels(ctx context.Context, req *storagepb.ListChannelsRequest, opts ...gax.CallOption) (*storagepb.ListChannelsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1145,7 +1143,7 @@ func (c *GRPCClient) ListChannels(ctx context.Context, req *storagepb.ListChanne // ListBuckets retrieves a list of buckets for a given project. func (c *GRPCClient) ListBuckets(ctx context.Context, req *storagepb.ListBucketsRequest, opts ...gax.CallOption) (*storagepb.ListBucketsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1166,7 +1164,7 @@ func (c *GRPCClient) ListBuckets(ctx context.Context, req *storagepb.ListBuckets // LockBucketRetentionPolicy locks retention policy on a bucket. func (c *GRPCClient) LockBucketRetentionPolicy(ctx context.Context, req *storagepb.LockRetentionPolicyRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1187,7 +1185,7 @@ func (c *GRPCClient) LockBucketRetentionPolicy(ctx context.Context, req *storage // GetBucketIamPolicy gets the IAM policy for the specified bucket. func (c *GRPCClient) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1208,7 +1206,7 @@ func (c *GRPCClient) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetI // SetBucketIamPolicy updates an IAM policy for the specified bucket. func (c *GRPCClient) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1230,7 +1228,7 @@ func (c *GRPCClient) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetI // any, are held by the caller. func (c *GRPCClient) TestBucketIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1252,7 +1250,7 @@ func (c *GRPCClient) TestBucketIamPermissions(ctx context.Context, req *storagep // writing, but configuration changes may take time to propagate. func (c *GRPCClient) PatchBucket(ctx context.Context, req *storagepb.PatchBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1277,7 +1275,7 @@ func (c *GRPCClient) PatchBucket(ctx context.Context, req *storagepb.PatchBucket // writing, but configuration changes may take time to propagate. func (c *GRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1301,7 +1299,7 @@ func (c *GRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBuck // are stopped using DeleteNotification. func (c *GRPCClient) StopChannel(ctx context.Context, req *storagepb.StopChannelRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1319,7 +1317,7 @@ func (c *GRPCClient) StopChannel(ctx context.Context, req *storagepb.StopChannel // on the specified bucket. func (c *GRPCClient) DeleteDefaultObjectAccessControl(ctx context.Context, req *storagepb.DeleteDefaultObjectAccessControlRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1337,7 +1335,7 @@ func (c *GRPCClient) DeleteDefaultObjectAccessControl(ctx context.Context, req * // specified bucket. func (c *GRPCClient) GetDefaultObjectAccessControl(ctx context.Context, req *storagepb.GetDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1358,7 +1356,7 @@ func (c *GRPCClient) GetDefaultObjectAccessControl(ctx context.Context, req *sto // InsertDefaultObjectAccessControl creates a new default object ACL entry on the specified bucket. func (c *GRPCClient) InsertDefaultObjectAccessControl(ctx context.Context, req *storagepb.InsertDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1379,7 +1377,7 @@ func (c *GRPCClient) InsertDefaultObjectAccessControl(ctx context.Context, req * // ListDefaultObjectAccessControls retrieves default object ACL entries on the specified bucket. func (c *GRPCClient) ListDefaultObjectAccessControls(ctx context.Context, req *storagepb.ListDefaultObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1400,7 +1398,7 @@ func (c *GRPCClient) ListDefaultObjectAccessControls(ctx context.Context, req *s // PatchDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. func (c *GRPCClient) PatchDefaultObjectAccessControl(ctx context.Context, req *storagepb.PatchDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1423,7 +1421,7 @@ func (c *GRPCClient) PatchDefaultObjectAccessControl(ctx context.Context, req *s // their default values. func (c *GRPCClient) UpdateDefaultObjectAccessControl(ctx context.Context, req *storagepb.UpdateDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1446,7 +1444,7 @@ func (c *GRPCClient) UpdateDefaultObjectAccessControl(ctx context.Context, req * // deleted using StopChannel instead. func (c *GRPCClient) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1463,7 +1461,7 @@ func (c *GRPCClient) DeleteNotification(ctx context.Context, req *storagepb.Dele // GetNotification view a notification configuration. func (c *GRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1487,7 +1485,7 @@ func (c *GRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNoti // See https://cloud.google.com/storage/docs/pubsub-notifications (at https://cloud.google.com/storage/docs/pubsub-notifications). func (c *GRPCClient) InsertNotification(ctx context.Context, req *storagepb.InsertNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1508,7 +1506,7 @@ func (c *GRPCClient) InsertNotification(ctx context.Context, req *storagepb.Inse // ListNotifications retrieves a list of notification subscriptions for a given bucket. func (c *GRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) (*storagepb.ListNotificationsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1530,7 +1528,7 @@ func (c *GRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListN // object. func (c *GRPCClient) DeleteObjectAccessControl(ctx context.Context, req *storagepb.DeleteObjectAccessControlRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1547,7 +1545,7 @@ func (c *GRPCClient) DeleteObjectAccessControl(ctx context.Context, req *storage // GetObjectAccessControl returns the ACL entry for the specified entity on the specified object. func (c *GRPCClient) GetObjectAccessControl(ctx context.Context, req *storagepb.GetObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1568,7 +1566,7 @@ func (c *GRPCClient) GetObjectAccessControl(ctx context.Context, req *storagepb. // InsertObjectAccessControl creates a new ACL entry on the specified object. func (c *GRPCClient) InsertObjectAccessControl(ctx context.Context, req *storagepb.InsertObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1589,7 +1587,7 @@ func (c *GRPCClient) InsertObjectAccessControl(ctx context.Context, req *storage // ListObjectAccessControls retrieves ACL entries on the specified object. func (c *GRPCClient) ListObjectAccessControls(ctx context.Context, req *storagepb.ListObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1612,7 +1610,7 @@ func (c *GRPCClient) ListObjectAccessControls(ctx context.Context, req *storagep // object_access_control object. Other fields are unaffected. func (c *GRPCClient) PatchObjectAccessControl(ctx context.Context, req *storagepb.PatchObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1633,7 +1631,7 @@ func (c *GRPCClient) PatchObjectAccessControl(ctx context.Context, req *storagep // UpdateObjectAccessControl updates an ACL entry on the specified object. func (c *GRPCClient) UpdateObjectAccessControl(ctx context.Context, req *storagepb.UpdateObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1655,7 +1653,7 @@ func (c *GRPCClient) UpdateObjectAccessControl(ctx context.Context, req *storage // bucket. func (c *GRPCClient) ComposeObject(ctx context.Context, req *storagepb.ComposeObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1677,7 +1675,7 @@ func (c *GRPCClient) ComposeObject(ctx context.Context, req *storagepb.ComposeOb // metadata. func (c *GRPCClient) CopyObject(ctx context.Context, req *storagepb.CopyObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1700,7 +1698,7 @@ func (c *GRPCClient) CopyObject(ctx context.Context, req *storagepb.CopyObjectRe // is used. func (c *GRPCClient) DeleteObject(ctx context.Context, req *storagepb.DeleteObjectRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1717,7 +1715,7 @@ func (c *GRPCClient) DeleteObject(ctx context.Context, req *storagepb.DeleteObje // GetObject retrieves an object’s metadata. func (c *GRPCClient) GetObject(ctx context.Context, req *storagepb.GetObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1792,7 +1790,7 @@ func (c *GRPCClient) InsertObject(ctx context.Context, opts ...gax.CallOption) ( // ListObjects retrieves a list of objects matching the criteria. func (c *GRPCClient) ListObjects(ctx context.Context, req *storagepb.ListObjectsRequest, opts ...gax.CallOption) (*storagepb.ListObjectsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1814,7 +1812,7 @@ func (c *GRPCClient) ListObjects(ctx context.Context, req *storagepb.ListObjects // metadata. func (c *GRPCClient) RewriteObject(ctx context.Context, req *storagepb.RewriteObjectRequest, opts ...gax.CallOption) (*storagepb.RewriteResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1837,7 +1835,7 @@ func (c *GRPCClient) RewriteObject(ctx context.Context, req *storagepb.RewriteOb // service-dependent. func (c *GRPCClient) StartResumableWrite(ctx context.Context, req *storagepb.StartResumableWriteRequest, opts ...gax.CallOption) (*storagepb.StartResumableWriteResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1870,7 +1868,7 @@ func (c *GRPCClient) StartResumableWrite(ctx context.Context, req *storagepb.Sta // non-decreasing. func (c *GRPCClient) QueryWriteStatus(ctx context.Context, req *storagepb.QueryWriteStatusRequest, opts ...gax.CallOption) (*storagepb.QueryWriteStatusResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1891,7 +1889,7 @@ func (c *GRPCClient) QueryWriteStatus(ctx context.Context, req *storagepb.QueryW // PatchObject updates an object’s metadata. func (c *GRPCClient) PatchObject(ctx context.Context, req *storagepb.PatchObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1914,7 +1912,7 @@ func (c *GRPCClient) PatchObject(ctx context.Context, req *storagepb.PatchObject // unspecified fields to their default values. func (c *GRPCClient) UpdateObject(ctx context.Context, req *storagepb.UpdateObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1935,7 +1933,7 @@ func (c *GRPCClient) UpdateObject(ctx context.Context, req *storagepb.UpdateObje // GetObjectIamPolicy gets the IAM policy for the specified object. func (c *GRPCClient) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1956,7 +1954,7 @@ func (c *GRPCClient) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetI // SetObjectIamPolicy updates an IAM policy for the specified object. func (c *GRPCClient) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1978,7 +1976,7 @@ func (c *GRPCClient) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetI // any, are held by the caller. func (c *GRPCClient) TestObjectIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -1999,7 +1997,7 @@ func (c *GRPCClient) TestObjectIamPermissions(ctx context.Context, req *storagep // WatchAllObjects watch for changes on all objects in a bucket. func (c *GRPCClient) WatchAllObjects(ctx context.Context, req *storagepb.WatchAllObjectsRequest, opts ...gax.CallOption) (*storagepb.Channel, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -2020,7 +2018,7 @@ func (c *GRPCClient) WatchAllObjects(ctx context.Context, req *storagepb.WatchAl // GetServiceAccount retrieves the name of a project’s Google Cloud Storage service account. func (c *GRPCClient) GetServiceAccount(ctx context.Context, req *storagepb.GetProjectServiceAccountRequest, opts ...gax.CallOption) (*storagepb.ServiceAccount, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -2041,7 +2039,7 @@ func (c *GRPCClient) GetServiceAccount(ctx context.Context, req *storagepb.GetPr // CreateHmacKey creates a new HMAC key for the given service account. func (c *GRPCClient) CreateHmacKey(ctx context.Context, req *storagepb.CreateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.CreateHmacKeyResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -2062,7 +2060,7 @@ func (c *GRPCClient) CreateHmacKey(ctx context.Context, req *storagepb.CreateHma // DeleteHmacKey deletes a given HMAC key. Key must be in an INACTIVE state. func (c *GRPCClient) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHmacKeyRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -2079,7 +2077,7 @@ func (c *GRPCClient) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHma // GetHmacKey gets an existing HMAC key metadata for the given id. func (c *GRPCClient) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -2100,7 +2098,7 @@ func (c *GRPCClient) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRe // ListHmacKeys lists HMAC keys under a given project with the additional filters provided. func (c *GRPCClient) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKeysRequest, opts ...gax.CallOption) (*storagepb.ListHmacKeysResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } @@ -2121,7 +2119,7 @@ func (c *GRPCClient) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKe // UpdateHmacKey updates a given HMAC key state between ACTIVE and INACTIVE. func (c *GRPCClient) UpdateHmacKey(ctx context.Context, req *storagepb.UpdateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { - cctx, cancel := context.WithTimeout(ctx, 60000 * time.Millisecond) + cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() ctx = cctx } From 55f839645efc705e1f8dfccccf7b03d3fa1adda8 Mon Sep 17 00:00:00 2001 From: noahdietz Date: Tue, 15 Jun 2021 16:00:57 -0700 Subject: [PATCH 3/6] fix config rebase mistake --- internal/gapicgen/generator/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index e1e4395d8615..615f4af71d4f 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -1202,9 +1202,9 @@ var microgenGapicConfigs = []*microgenConfig{ gRPCServiceConfigPath: "google/cloud/gsuiteaddons/v1/gsuiteaddons_grpc_service_config.json", apiServiceConfigPath: "google/cloud/gsuiteaddons/v1/gsuiteaddons_v1.yaml", // GA after 2021/06/10 + releaseLevel: "beta", }, { - releaseLevel: "beta", inputDirectoryPath: "google/storage/v1", pkg: "storage", importPath: "cloud.google.com/go/storage/internal/apiv1", From 55c4787030b1e3d3ca39067b8cbdfa2a3510359c Mon Sep 17 00:00:00 2001 From: noahdietz Date: Thu, 24 Jun 2021 13:05:38 -0700 Subject: [PATCH 4/6] update with ggg v0.21.0 --- storage/internal/apiv1/gapic_metadata.json | 246 +++---- storage/internal/apiv1/storage_client.go | 626 ++++++++++++------ .../apiv1/storage_client_example_test.go | 148 ++--- 3 files changed, 617 insertions(+), 403 deletions(-) diff --git a/storage/internal/apiv1/gapic_metadata.json b/storage/internal/apiv1/gapic_metadata.json index d7b93b754dec..b3a8f901993c 100644 --- a/storage/internal/apiv1/gapic_metadata.json +++ b/storage/internal/apiv1/gapic_metadata.json @@ -1,292 +1,292 @@ { - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", - "language": "go", - "protoPackage": "google.storage.v1", - "libraryPackage": "cloud.google.com/go/storage/internal/apiv1", - "services": { - "Storage": { - "clients": { - "grpc": { - "libraryClient": "Client", - "rpcs": { - "ComposeObject": { - "methods": [ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods.", + "language": "go", + "protoPackage": "google.storage.v1", + "libraryPackage": "cloud.google.com/go/storage/internal/apiv1", + "services": { + "Storage": { + "clients": { + "grpc": { + "libraryClient": "Client", + "rpcs": { + "ComposeObject": { + "methods": [ "ComposeObject" ] }, - "CopyObject": { - "methods": [ + "CopyObject": { + "methods": [ "CopyObject" ] }, - "CreateHmacKey": { - "methods": [ + "CreateHmacKey": { + "methods": [ "CreateHmacKey" ] }, - "DeleteBucket": { - "methods": [ + "DeleteBucket": { + "methods": [ "DeleteBucket" ] }, - "DeleteBucketAccessControl": { - "methods": [ + "DeleteBucketAccessControl": { + "methods": [ "DeleteBucketAccessControl" ] }, - "DeleteDefaultObjectAccessControl": { - "methods": [ + "DeleteDefaultObjectAccessControl": { + "methods": [ "DeleteDefaultObjectAccessControl" ] }, - "DeleteHmacKey": { - "methods": [ + "DeleteHmacKey": { + "methods": [ "DeleteHmacKey" ] }, - "DeleteNotification": { - "methods": [ + "DeleteNotification": { + "methods": [ "DeleteNotification" ] }, - "DeleteObject": { - "methods": [ + "DeleteObject": { + "methods": [ "DeleteObject" ] }, - "DeleteObjectAccessControl": { - "methods": [ + "DeleteObjectAccessControl": { + "methods": [ "DeleteObjectAccessControl" ] }, - "GetBucket": { - "methods": [ + "GetBucket": { + "methods": [ "GetBucket" ] }, - "GetBucketAccessControl": { - "methods": [ + "GetBucketAccessControl": { + "methods": [ "GetBucketAccessControl" ] }, - "GetBucketIamPolicy": { - "methods": [ + "GetBucketIamPolicy": { + "methods": [ "GetBucketIamPolicy" ] }, - "GetDefaultObjectAccessControl": { - "methods": [ + "GetDefaultObjectAccessControl": { + "methods": [ "GetDefaultObjectAccessControl" ] }, - "GetHmacKey": { - "methods": [ + "GetHmacKey": { + "methods": [ "GetHmacKey" ] }, - "GetNotification": { - "methods": [ + "GetNotification": { + "methods": [ "GetNotification" ] }, - "GetObject": { - "methods": [ + "GetObject": { + "methods": [ "GetObject" ] }, - "GetObjectAccessControl": { - "methods": [ + "GetObjectAccessControl": { + "methods": [ "GetObjectAccessControl" ] }, - "GetObjectIamPolicy": { - "methods": [ + "GetObjectIamPolicy": { + "methods": [ "GetObjectIamPolicy" ] }, - "GetObjectMedia": { - "methods": [ + "GetObjectMedia": { + "methods": [ "GetObjectMedia" ] }, - "GetServiceAccount": { - "methods": [ + "GetServiceAccount": { + "methods": [ "GetServiceAccount" ] }, - "InsertBucket": { - "methods": [ + "InsertBucket": { + "methods": [ "InsertBucket" ] }, - "InsertBucketAccessControl": { - "methods": [ + "InsertBucketAccessControl": { + "methods": [ "InsertBucketAccessControl" ] }, - "InsertDefaultObjectAccessControl": { - "methods": [ + "InsertDefaultObjectAccessControl": { + "methods": [ "InsertDefaultObjectAccessControl" ] }, - "InsertNotification": { - "methods": [ + "InsertNotification": { + "methods": [ "InsertNotification" ] }, - "InsertObject": { - "methods": [ + "InsertObject": { + "methods": [ "InsertObject" ] }, - "InsertObjectAccessControl": { - "methods": [ + "InsertObjectAccessControl": { + "methods": [ "InsertObjectAccessControl" ] }, - "ListBucketAccessControls": { - "methods": [ + "ListBucketAccessControls": { + "methods": [ "ListBucketAccessControls" ] }, - "ListBuckets": { - "methods": [ + "ListBuckets": { + "methods": [ "ListBuckets" ] }, - "ListChannels": { - "methods": [ + "ListChannels": { + "methods": [ "ListChannels" ] }, - "ListDefaultObjectAccessControls": { - "methods": [ + "ListDefaultObjectAccessControls": { + "methods": [ "ListDefaultObjectAccessControls" ] }, - "ListHmacKeys": { - "methods": [ + "ListHmacKeys": { + "methods": [ "ListHmacKeys" ] }, - "ListNotifications": { - "methods": [ + "ListNotifications": { + "methods": [ "ListNotifications" ] }, - "ListObjectAccessControls": { - "methods": [ + "ListObjectAccessControls": { + "methods": [ "ListObjectAccessControls" ] }, - "ListObjects": { - "methods": [ + "ListObjects": { + "methods": [ "ListObjects" ] }, - "LockBucketRetentionPolicy": { - "methods": [ + "LockBucketRetentionPolicy": { + "methods": [ "LockBucketRetentionPolicy" ] }, - "PatchBucket": { - "methods": [ + "PatchBucket": { + "methods": [ "PatchBucket" ] }, - "PatchBucketAccessControl": { - "methods": [ + "PatchBucketAccessControl": { + "methods": [ "PatchBucketAccessControl" ] }, - "PatchDefaultObjectAccessControl": { - "methods": [ + "PatchDefaultObjectAccessControl": { + "methods": [ "PatchDefaultObjectAccessControl" ] }, - "PatchObject": { - "methods": [ + "PatchObject": { + "methods": [ "PatchObject" ] }, - "PatchObjectAccessControl": { - "methods": [ + "PatchObjectAccessControl": { + "methods": [ "PatchObjectAccessControl" ] }, - "QueryWriteStatus": { - "methods": [ + "QueryWriteStatus": { + "methods": [ "QueryWriteStatus" ] }, - "RewriteObject": { - "methods": [ + "RewriteObject": { + "methods": [ "RewriteObject" ] }, - "SetBucketIamPolicy": { - "methods": [ + "SetBucketIamPolicy": { + "methods": [ "SetBucketIamPolicy" ] }, - "SetObjectIamPolicy": { - "methods": [ + "SetObjectIamPolicy": { + "methods": [ "SetObjectIamPolicy" ] }, - "StartResumableWrite": { - "methods": [ + "StartResumableWrite": { + "methods": [ "StartResumableWrite" ] }, - "StopChannel": { - "methods": [ + "StopChannel": { + "methods": [ "StopChannel" ] }, - "TestBucketIamPermissions": { - "methods": [ + "TestBucketIamPermissions": { + "methods": [ "TestBucketIamPermissions" ] }, - "TestObjectIamPermissions": { - "methods": [ + "TestObjectIamPermissions": { + "methods": [ "TestObjectIamPermissions" ] }, - "UpdateBucket": { - "methods": [ + "UpdateBucket": { + "methods": [ "UpdateBucket" ] }, - "UpdateBucketAccessControl": { - "methods": [ + "UpdateBucketAccessControl": { + "methods": [ "UpdateBucketAccessControl" ] }, - "UpdateDefaultObjectAccessControl": { - "methods": [ + "UpdateDefaultObjectAccessControl": { + "methods": [ "UpdateDefaultObjectAccessControl" ] }, - "UpdateHmacKey": { - "methods": [ + "UpdateHmacKey": { + "methods": [ "UpdateHmacKey" ] }, - "UpdateObject": { - "methods": [ + "UpdateObject": { + "methods": [ "UpdateObject" ] }, - "UpdateObjectAccessControl": { - "methods": [ + "UpdateObjectAccessControl": { + "methods": [ "UpdateObjectAccessControl" ] }, - "WatchAllObjects": { - "methods": [ + "WatchAllObjects": { + "methods": [ "WatchAllObjects" ] } diff --git a/storage/internal/apiv1/storage_client.go b/storage/internal/apiv1/storage_client.go index 2f4c597dd9a0..994ed4556f91 100644 --- a/storage/internal/apiv1/storage_client.go +++ b/storage/internal/apiv1/storage_client.go @@ -100,6 +100,7 @@ func defaultGRPCClientOptions() []option.ClientOption { internaloption.WithDefaultMTLSEndpoint("storage.mtls.googleapis.com:443"), internaloption.WithDefaultAudience("https://storage.googleapis.com/"), internaloption.WithDefaultScopes(DefaultAuthScopes()...), + internaloption.EnableJwtWithScope(), option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), option.WithGRPCDialOption(grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(math.MaxInt32))), @@ -848,18 +849,391 @@ type internalClient interface { // Client is a client for interacting with Cloud Storage API. // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +// +// Manages Google Cloud Storage resources. type Client struct { // The internal transport-dependent client. - internalClient + internalClient internalClient // The call options for this service. CallOptions *CallOptions } -// GRPCClient is a client for interacting with Cloud Storage API over gRPC transport. +// Wrapper methods routed to the internal client. + +// 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.internalClient.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) { + c.internalClient.setGoogleClientInfo(keyval...) +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *Client) Connection() *grpc.ClientConn { + return c.internalClient.Connection() +} + +// DeleteBucketAccessControl permanently deletes the ACL entry for the specified entity on the specified +// bucket. +func (c *Client) DeleteBucketAccessControl(ctx context.Context, req *storagepb.DeleteBucketAccessControlRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteBucketAccessControl(ctx, req, opts...) +} + +// GetBucketAccessControl returns the ACL entry for the specified entity on the specified bucket. +func (c *Client) GetBucketAccessControl(ctx context.Context, req *storagepb.GetBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + return c.internalClient.GetBucketAccessControl(ctx, req, opts...) +} + +// InsertBucketAccessControl creates a new ACL entry on the specified bucket. +func (c *Client) InsertBucketAccessControl(ctx context.Context, req *storagepb.InsertBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + return c.internalClient.InsertBucketAccessControl(ctx, req, opts...) +} + +// ListBucketAccessControls retrieves ACL entries on the specified bucket. +func (c *Client) ListBucketAccessControls(ctx context.Context, req *storagepb.ListBucketAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListBucketAccessControlsResponse, error) { + return c.internalClient.ListBucketAccessControls(ctx, req, opts...) +} + +// UpdateBucketAccessControl updates an ACL entry on the specified bucket. Equivalent to +// PatchBucketAccessControl, but all unspecified fields will be +// reset to their default values. +func (c *Client) UpdateBucketAccessControl(ctx context.Context, req *storagepb.UpdateBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + return c.internalClient.UpdateBucketAccessControl(ctx, req, opts...) +} + +// PatchBucketAccessControl updates an ACL entry on the specified bucket. +func (c *Client) PatchBucketAccessControl(ctx context.Context, req *storagepb.PatchBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { + return c.internalClient.PatchBucketAccessControl(ctx, req, opts...) +} + +// DeleteBucket permanently deletes an empty bucket. +func (c *Client) DeleteBucket(ctx context.Context, req *storagepb.DeleteBucketRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteBucket(ctx, req, opts...) +} + +// GetBucket returns metadata for the specified bucket. +func (c *Client) GetBucket(ctx context.Context, req *storagepb.GetBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + return c.internalClient.GetBucket(ctx, req, opts...) +} + +// InsertBucket creates a new bucket. +func (c *Client) InsertBucket(ctx context.Context, req *storagepb.InsertBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + return c.internalClient.InsertBucket(ctx, req, opts...) +} + +// ListChannels list active object change notification channels for this bucket. +func (c *Client) ListChannels(ctx context.Context, req *storagepb.ListChannelsRequest, opts ...gax.CallOption) (*storagepb.ListChannelsResponse, error) { + return c.internalClient.ListChannels(ctx, req, opts...) +} + +// ListBuckets retrieves a list of buckets for a given project. +func (c *Client) ListBuckets(ctx context.Context, req *storagepb.ListBucketsRequest, opts ...gax.CallOption) (*storagepb.ListBucketsResponse, error) { + return c.internalClient.ListBuckets(ctx, req, opts...) +} + +// LockBucketRetentionPolicy locks retention policy on a bucket. +func (c *Client) LockBucketRetentionPolicy(ctx context.Context, req *storagepb.LockRetentionPolicyRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + return c.internalClient.LockBucketRetentionPolicy(ctx, req, opts...) +} + +// GetBucketIamPolicy gets the IAM policy for the specified bucket. +func (c *Client) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + return c.internalClient.GetBucketIamPolicy(ctx, req, opts...) +} + +// SetBucketIamPolicy updates an IAM policy for the specified bucket. +func (c *Client) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + return c.internalClient.SetBucketIamPolicy(ctx, req, opts...) +} + +// TestBucketIamPermissions tests a set of permissions on the given bucket to see which, if +// any, are held by the caller. +func (c *Client) TestBucketIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { + return c.internalClient.TestBucketIamPermissions(ctx, req, opts...) +} + +// PatchBucket updates a bucket. Changes to the bucket will be readable immediately after +// writing, but configuration changes may take time to propagate. +func (c *Client) PatchBucket(ctx context.Context, req *storagepb.PatchBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + return c.internalClient.PatchBucket(ctx, req, opts...) +} + +// UpdateBucket updates a bucket. Equivalent to PatchBucket, but always replaces all +// mutatable fields of the bucket with new values, reverting all +// unspecified fields to their default values. +// Like PatchBucket, Changes to the bucket will be readable immediately after +// writing, but configuration changes may take time to propagate. +func (c *Client) UpdateBucket(ctx context.Context, req *storagepb.UpdateBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { + return c.internalClient.UpdateBucket(ctx, req, opts...) +} + +// StopChannel halts “Object Change Notification” push messagages. +// See https://cloud.google.com/storage/docs/object-change-notification (at https://cloud.google.com/storage/docs/object-change-notification) +// Note: this is not related to the newer “Notifications” resource, which +// are stopped using DeleteNotification. +func (c *Client) StopChannel(ctx context.Context, req *storagepb.StopChannelRequest, opts ...gax.CallOption) error { + return c.internalClient.StopChannel(ctx, req, opts...) +} + +// DeleteDefaultObjectAccessControl permanently deletes the default object ACL entry for the specified entity +// on the specified bucket. +func (c *Client) DeleteDefaultObjectAccessControl(ctx context.Context, req *storagepb.DeleteDefaultObjectAccessControlRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteDefaultObjectAccessControl(ctx, req, opts...) +} + +// GetDefaultObjectAccessControl returns the default object ACL entry for the specified entity on the +// specified bucket. +func (c *Client) GetDefaultObjectAccessControl(ctx context.Context, req *storagepb.GetDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.GetDefaultObjectAccessControl(ctx, req, opts...) +} + +// InsertDefaultObjectAccessControl creates a new default object ACL entry on the specified bucket. +func (c *Client) InsertDefaultObjectAccessControl(ctx context.Context, req *storagepb.InsertDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.InsertDefaultObjectAccessControl(ctx, req, opts...) +} + +// ListDefaultObjectAccessControls retrieves default object ACL entries on the specified bucket. +func (c *Client) ListDefaultObjectAccessControls(ctx context.Context, req *storagepb.ListDefaultObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { + return c.internalClient.ListDefaultObjectAccessControls(ctx, req, opts...) +} + +// PatchDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. +func (c *Client) PatchDefaultObjectAccessControl(ctx context.Context, req *storagepb.PatchDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.PatchDefaultObjectAccessControl(ctx, req, opts...) +} + +// UpdateDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. Equivalent to +// PatchDefaultObjectAccessControl, but modifies all unspecified fields to +// their default values. +func (c *Client) UpdateDefaultObjectAccessControl(ctx context.Context, req *storagepb.UpdateDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.UpdateDefaultObjectAccessControl(ctx, req, opts...) +} + +// DeleteNotification permanently deletes a notification subscription. +// Note: Older, “Object Change Notification” push subscriptions should be +// deleted using StopChannel instead. +func (c *Client) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteNotification(ctx, req, opts...) +} + +// GetNotification view a notification configuration. +func (c *Client) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { + return c.internalClient.GetNotification(ctx, req, opts...) +} + +// InsertNotification creates a notification subscription for a given bucket. +// These notifications, when triggered, publish messages to the specified +// Cloud Pub/Sub topics. +// See https://cloud.google.com/storage/docs/pubsub-notifications (at https://cloud.google.com/storage/docs/pubsub-notifications). +func (c *Client) InsertNotification(ctx context.Context, req *storagepb.InsertNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { + return c.internalClient.InsertNotification(ctx, req, opts...) +} + +// ListNotifications retrieves a list of notification subscriptions for a given bucket. +func (c *Client) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) (*storagepb.ListNotificationsResponse, error) { + return c.internalClient.ListNotifications(ctx, req, opts...) +} + +// DeleteObjectAccessControl permanently deletes the ACL entry for the specified entity on the specified +// object. +func (c *Client) DeleteObjectAccessControl(ctx context.Context, req *storagepb.DeleteObjectAccessControlRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteObjectAccessControl(ctx, req, opts...) +} + +// GetObjectAccessControl returns the ACL entry for the specified entity on the specified object. +func (c *Client) GetObjectAccessControl(ctx context.Context, req *storagepb.GetObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.GetObjectAccessControl(ctx, req, opts...) +} + +// InsertObjectAccessControl creates a new ACL entry on the specified object. +func (c *Client) InsertObjectAccessControl(ctx context.Context, req *storagepb.InsertObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.InsertObjectAccessControl(ctx, req, opts...) +} + +// ListObjectAccessControls retrieves ACL entries on the specified object. +func (c *Client) ListObjectAccessControls(ctx context.Context, req *storagepb.ListObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { + return c.internalClient.ListObjectAccessControls(ctx, req, opts...) +} + +// PatchObjectAccessControl patches an ACL entry on the specified object. Patch is similar to update, +// but only applies or appends the specified fields in the +// object_access_control object. Other fields are unaffected. +func (c *Client) PatchObjectAccessControl(ctx context.Context, req *storagepb.PatchObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.PatchObjectAccessControl(ctx, req, opts...) +} + +// UpdateObjectAccessControl updates an ACL entry on the specified object. +func (c *Client) UpdateObjectAccessControl(ctx context.Context, req *storagepb.UpdateObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { + return c.internalClient.UpdateObjectAccessControl(ctx, req, opts...) +} + +// ComposeObject concatenates a list of existing objects into a new object in the same +// bucket. +func (c *Client) ComposeObject(ctx context.Context, req *storagepb.ComposeObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + return c.internalClient.ComposeObject(ctx, req, opts...) +} + +// CopyObject copies a source object to a destination object. Optionally overrides +// metadata. +func (c *Client) CopyObject(ctx context.Context, req *storagepb.CopyObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + return c.internalClient.CopyObject(ctx, req, opts...) +} + +// DeleteObject deletes an object and its metadata. Deletions are permanent if versioning +// is not enabled for the bucket, or if the generation parameter +// is used. +func (c *Client) DeleteObject(ctx context.Context, req *storagepb.DeleteObjectRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteObject(ctx, req, opts...) +} + +// GetObject retrieves an object’s metadata. +func (c *Client) GetObject(ctx context.Context, req *storagepb.GetObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + return c.internalClient.GetObject(ctx, req, opts...) +} + +// GetObjectMedia reads an object’s data. +func (c *Client) GetObjectMedia(ctx context.Context, req *storagepb.GetObjectMediaRequest, opts ...gax.CallOption) (storagepb.Storage_GetObjectMediaClient, error) { + return c.internalClient.GetObjectMedia(ctx, req, opts...) +} + +// InsertObject stores a new object and metadata. +// +// An object can be written either in a single message stream or in a +// resumable sequence of message streams. To write using a single stream, +// the client should include in the first message of the stream an +// InsertObjectSpec describing the destination bucket, object, and any +// preconditions. Additionally, the final message must set ‘finish_write’ to +// true, or else it is an error. +// +// For a resumable write, the client should instead call +// StartResumableWrite() and provide that method an InsertObjectSpec. +// They should then attach the returned upload_id to the first message of +// each following call to Insert. If there is an error or the connection is +// broken during the resumable Insert(), the client should check the status +// of the Insert() by calling QueryWriteStatus() and continue writing from +// the returned committed_size. This may be less than the amount of data the +// client previously sent. +// +// The service will not view the object as complete until the client has +// sent an Insert with finish_write set to true. Sending any +// requests on a stream after sending a request with finish_write set to +// true will cause an error. The client should check the +// Object it receives to determine how much data the service was +// able to commit and whether the service views the object as complete. +func (c *Client) InsertObject(ctx context.Context, opts ...gax.CallOption) (storagepb.Storage_InsertObjectClient, error) { + return c.internalClient.InsertObject(ctx, opts...) +} + +// ListObjects retrieves a list of objects matching the criteria. +func (c *Client) ListObjects(ctx context.Context, req *storagepb.ListObjectsRequest, opts ...gax.CallOption) (*storagepb.ListObjectsResponse, error) { + return c.internalClient.ListObjects(ctx, req, opts...) +} + +// RewriteObject rewrites a source object to a destination object. Optionally overrides +// metadata. +func (c *Client) RewriteObject(ctx context.Context, req *storagepb.RewriteObjectRequest, opts ...gax.CallOption) (*storagepb.RewriteResponse, error) { + return c.internalClient.RewriteObject(ctx, req, opts...) +} + +// StartResumableWrite starts a resumable write. How long the write operation remains valid, and +// what happens when the write operation becomes invalid, are +// service-dependent. +func (c *Client) StartResumableWrite(ctx context.Context, req *storagepb.StartResumableWriteRequest, opts ...gax.CallOption) (*storagepb.StartResumableWriteResponse, error) { + return c.internalClient.StartResumableWrite(ctx, req, opts...) +} + +// QueryWriteStatus determines the committed_size for an object that is being written, which +// can then be used as the write_offset for the next Write() call. +// +// If the object does not exist (i.e., the object has been deleted, or the +// first Write() has not yet reached the service), this method returns the +// error NOT_FOUND. +// +// The client may call QueryWriteStatus() at any time to determine how +// much data has been processed for this object. This is useful if the +// client is buffering data and needs to know which data can be safely +// evicted. For any sequence of QueryWriteStatus() calls for a given +// object name, the sequence of returned committed_size values will be +// non-decreasing. +func (c *Client) QueryWriteStatus(ctx context.Context, req *storagepb.QueryWriteStatusRequest, opts ...gax.CallOption) (*storagepb.QueryWriteStatusResponse, error) { + return c.internalClient.QueryWriteStatus(ctx, req, opts...) +} + +// PatchObject updates an object’s metadata. +func (c *Client) PatchObject(ctx context.Context, req *storagepb.PatchObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + return c.internalClient.PatchObject(ctx, req, opts...) +} + +// UpdateObject updates an object’s metadata. Equivalent to PatchObject, but always +// replaces all mutatable fields of the bucket with new values, reverting all +// unspecified fields to their default values. +func (c *Client) UpdateObject(ctx context.Context, req *storagepb.UpdateObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { + return c.internalClient.UpdateObject(ctx, req, opts...) +} + +// GetObjectIamPolicy gets the IAM policy for the specified object. +func (c *Client) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + return c.internalClient.GetObjectIamPolicy(ctx, req, opts...) +} + +// SetObjectIamPolicy updates an IAM policy for the specified object. +func (c *Client) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { + return c.internalClient.SetObjectIamPolicy(ctx, req, opts...) +} + +// TestObjectIamPermissions tests a set of permissions on the given object to see which, if +// any, are held by the caller. +func (c *Client) TestObjectIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { + return c.internalClient.TestObjectIamPermissions(ctx, req, opts...) +} + +// WatchAllObjects watch for changes on all objects in a bucket. +func (c *Client) WatchAllObjects(ctx context.Context, req *storagepb.WatchAllObjectsRequest, opts ...gax.CallOption) (*storagepb.Channel, error) { + return c.internalClient.WatchAllObjects(ctx, req, opts...) +} + +// GetServiceAccount retrieves the name of a project’s Google Cloud Storage service account. +func (c *Client) GetServiceAccount(ctx context.Context, req *storagepb.GetProjectServiceAccountRequest, opts ...gax.CallOption) (*storagepb.ServiceAccount, error) { + return c.internalClient.GetServiceAccount(ctx, req, opts...) +} + +// CreateHmacKey creates a new HMAC key for the given service account. +func (c *Client) CreateHmacKey(ctx context.Context, req *storagepb.CreateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.CreateHmacKeyResponse, error) { + return c.internalClient.CreateHmacKey(ctx, req, opts...) +} + +// DeleteHmacKey deletes a given HMAC key. Key must be in an INACTIVE state. +func (c *Client) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHmacKeyRequest, opts ...gax.CallOption) error { + return c.internalClient.DeleteHmacKey(ctx, req, opts...) +} + +// GetHmacKey gets an existing HMAC key metadata for the given id. +func (c *Client) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { + return c.internalClient.GetHmacKey(ctx, req, opts...) +} + +// ListHmacKeys lists HMAC keys under a given project with the additional filters provided. +func (c *Client) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKeysRequest, opts ...gax.CallOption) (*storagepb.ListHmacKeysResponse, error) { + return c.internalClient.ListHmacKeys(ctx, req, opts...) +} + +// UpdateHmacKey updates a given HMAC key state between ACTIVE and INACTIVE. +func (c *Client) UpdateHmacKey(ctx context.Context, req *storagepb.UpdateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { + return c.internalClient.UpdateHmacKey(ctx, req, opts...) +} + +// gRPCClient is a client for interacting with Cloud Storage API over gRPC transport. // // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. -type GRPCClient struct { +type gRPCClient struct { // Connection pool of gRPC connections to the service. connPool gtransport.ConnPool @@ -877,6 +1251,7 @@ type GRPCClient struct { } // NewClient creates a new storage client based on gRPC. +// The returned client must be Closed when it is done being used to clean up its underlying connections. // // Manages Google Cloud Storage resources. func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { @@ -900,7 +1275,7 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error } client := Client{CallOptions: defaultCallOptions()} - c := &GRPCClient{ + c := &gRPCClient{ connPool: connPool, disableDeadlines: disableDeadlines, client: storagepb.NewStorageClient(connPool), @@ -916,14 +1291,14 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error // Connection returns a connection to the API service. // // Deprecated. -func (c *GRPCClient) Connection() *grpc.ClientConn { +func (c *gRPCClient) Connection() *grpc.ClientConn { return c.connPool.Conn() } // 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 *GRPCClient) setGoogleClientInfo(keyval ...string) { +func (c *gRPCClient) 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...)) @@ -931,13 +1306,11 @@ func (c *GRPCClient) setGoogleClientInfo(keyval ...string) { // Close closes the connection to the API service. The user should invoke this when // the client is no longer required. -func (c *GRPCClient) Close() error { +func (c *gRPCClient) Close() error { return c.connPool.Close() } -// DeleteBucketAccessControl permanently deletes the ACL entry for the specified entity on the specified -// bucket. -func (c *GRPCClient) DeleteBucketAccessControl(ctx context.Context, req *storagepb.DeleteBucketAccessControlRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteBucketAccessControl(ctx context.Context, req *storagepb.DeleteBucketAccessControlRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -953,8 +1326,7 @@ func (c *GRPCClient) DeleteBucketAccessControl(ctx context.Context, req *storage return err } -// GetBucketAccessControl returns the ACL entry for the specified entity on the specified bucket. -func (c *GRPCClient) GetBucketAccessControl(ctx context.Context, req *storagepb.GetBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { +func (c *gRPCClient) GetBucketAccessControl(ctx context.Context, req *storagepb.GetBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -974,8 +1346,7 @@ func (c *GRPCClient) GetBucketAccessControl(ctx context.Context, req *storagepb. return resp, nil } -// InsertBucketAccessControl creates a new ACL entry on the specified bucket. -func (c *GRPCClient) InsertBucketAccessControl(ctx context.Context, req *storagepb.InsertBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { +func (c *gRPCClient) InsertBucketAccessControl(ctx context.Context, req *storagepb.InsertBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -995,8 +1366,7 @@ func (c *GRPCClient) InsertBucketAccessControl(ctx context.Context, req *storage return resp, nil } -// ListBucketAccessControls retrieves ACL entries on the specified bucket. -func (c *GRPCClient) ListBucketAccessControls(ctx context.Context, req *storagepb.ListBucketAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListBucketAccessControlsResponse, error) { +func (c *gRPCClient) ListBucketAccessControls(ctx context.Context, req *storagepb.ListBucketAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListBucketAccessControlsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1016,10 +1386,7 @@ func (c *GRPCClient) ListBucketAccessControls(ctx context.Context, req *storagep return resp, nil } -// UpdateBucketAccessControl updates an ACL entry on the specified bucket. Equivalent to -// PatchBucketAccessControl, but all unspecified fields will be -// reset to their default values. -func (c *GRPCClient) UpdateBucketAccessControl(ctx context.Context, req *storagepb.UpdateBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { +func (c *gRPCClient) UpdateBucketAccessControl(ctx context.Context, req *storagepb.UpdateBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1039,8 +1406,7 @@ func (c *GRPCClient) UpdateBucketAccessControl(ctx context.Context, req *storage return resp, nil } -// PatchBucketAccessControl updates an ACL entry on the specified bucket. -func (c *GRPCClient) PatchBucketAccessControl(ctx context.Context, req *storagepb.PatchBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { +func (c *gRPCClient) PatchBucketAccessControl(ctx context.Context, req *storagepb.PatchBucketAccessControlRequest, opts ...gax.CallOption) (*storagepb.BucketAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1060,8 +1426,7 @@ func (c *GRPCClient) PatchBucketAccessControl(ctx context.Context, req *storagep return resp, nil } -// DeleteBucket permanently deletes an empty bucket. -func (c *GRPCClient) DeleteBucket(ctx context.Context, req *storagepb.DeleteBucketRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteBucket(ctx context.Context, req *storagepb.DeleteBucketRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1077,8 +1442,7 @@ func (c *GRPCClient) DeleteBucket(ctx context.Context, req *storagepb.DeleteBuck return err } -// GetBucket returns metadata for the specified bucket. -func (c *GRPCClient) GetBucket(ctx context.Context, req *storagepb.GetBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { +func (c *gRPCClient) GetBucket(ctx context.Context, req *storagepb.GetBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1098,8 +1462,7 @@ func (c *GRPCClient) GetBucket(ctx context.Context, req *storagepb.GetBucketRequ return resp, nil } -// InsertBucket creates a new bucket. -func (c *GRPCClient) InsertBucket(ctx context.Context, req *storagepb.InsertBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { +func (c *gRPCClient) InsertBucket(ctx context.Context, req *storagepb.InsertBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1119,8 +1482,7 @@ func (c *GRPCClient) InsertBucket(ctx context.Context, req *storagepb.InsertBuck return resp, nil } -// ListChannels list active object change notification channels for this bucket. -func (c *GRPCClient) ListChannels(ctx context.Context, req *storagepb.ListChannelsRequest, opts ...gax.CallOption) (*storagepb.ListChannelsResponse, error) { +func (c *gRPCClient) ListChannels(ctx context.Context, req *storagepb.ListChannelsRequest, opts ...gax.CallOption) (*storagepb.ListChannelsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1140,8 +1502,7 @@ func (c *GRPCClient) ListChannels(ctx context.Context, req *storagepb.ListChanne return resp, nil } -// ListBuckets retrieves a list of buckets for a given project. -func (c *GRPCClient) ListBuckets(ctx context.Context, req *storagepb.ListBucketsRequest, opts ...gax.CallOption) (*storagepb.ListBucketsResponse, error) { +func (c *gRPCClient) ListBuckets(ctx context.Context, req *storagepb.ListBucketsRequest, opts ...gax.CallOption) (*storagepb.ListBucketsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1161,8 +1522,7 @@ func (c *GRPCClient) ListBuckets(ctx context.Context, req *storagepb.ListBuckets return resp, nil } -// LockBucketRetentionPolicy locks retention policy on a bucket. -func (c *GRPCClient) LockBucketRetentionPolicy(ctx context.Context, req *storagepb.LockRetentionPolicyRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { +func (c *gRPCClient) LockBucketRetentionPolicy(ctx context.Context, req *storagepb.LockRetentionPolicyRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1182,8 +1542,7 @@ func (c *GRPCClient) LockBucketRetentionPolicy(ctx context.Context, req *storage return resp, nil } -// GetBucketIamPolicy gets the IAM policy for the specified bucket. -func (c *GRPCClient) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { +func (c *gRPCClient) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1203,8 +1562,7 @@ func (c *GRPCClient) GetBucketIamPolicy(ctx context.Context, req *storagepb.GetI return resp, nil } -// SetBucketIamPolicy updates an IAM policy for the specified bucket. -func (c *GRPCClient) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { +func (c *gRPCClient) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1224,9 +1582,7 @@ func (c *GRPCClient) SetBucketIamPolicy(ctx context.Context, req *storagepb.SetI return resp, nil } -// TestBucketIamPermissions tests a set of permissions on the given bucket to see which, if -// any, are held by the caller. -func (c *GRPCClient) TestBucketIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { +func (c *gRPCClient) TestBucketIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1246,9 +1602,7 @@ func (c *GRPCClient) TestBucketIamPermissions(ctx context.Context, req *storagep return resp, nil } -// PatchBucket updates a bucket. Changes to the bucket will be readable immediately after -// writing, but configuration changes may take time to propagate. -func (c *GRPCClient) PatchBucket(ctx context.Context, req *storagepb.PatchBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { +func (c *gRPCClient) PatchBucket(ctx context.Context, req *storagepb.PatchBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1268,12 +1622,7 @@ func (c *GRPCClient) PatchBucket(ctx context.Context, req *storagepb.PatchBucket return resp, nil } -// UpdateBucket updates a bucket. Equivalent to PatchBucket, but always replaces all -// mutatable fields of the bucket with new values, reverting all -// unspecified fields to their default values. -// Like PatchBucket, Changes to the bucket will be readable immediately after -// writing, but configuration changes may take time to propagate. -func (c *GRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { +func (c *gRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBucketRequest, opts ...gax.CallOption) (*storagepb.Bucket, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1293,11 +1642,7 @@ func (c *GRPCClient) UpdateBucket(ctx context.Context, req *storagepb.UpdateBuck return resp, nil } -// StopChannel halts “Object Change Notification” push messagages. -// See https://cloud.google.com/storage/docs/object-change-notification (at https://cloud.google.com/storage/docs/object-change-notification) -// Note: this is not related to the newer “Notifications” resource, which -// are stopped using DeleteNotification. -func (c *GRPCClient) StopChannel(ctx context.Context, req *storagepb.StopChannelRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) StopChannel(ctx context.Context, req *storagepb.StopChannelRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1313,9 +1658,7 @@ func (c *GRPCClient) StopChannel(ctx context.Context, req *storagepb.StopChannel return err } -// DeleteDefaultObjectAccessControl permanently deletes the default object ACL entry for the specified entity -// on the specified bucket. -func (c *GRPCClient) DeleteDefaultObjectAccessControl(ctx context.Context, req *storagepb.DeleteDefaultObjectAccessControlRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteDefaultObjectAccessControl(ctx context.Context, req *storagepb.DeleteDefaultObjectAccessControlRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1331,9 +1674,7 @@ func (c *GRPCClient) DeleteDefaultObjectAccessControl(ctx context.Context, req * return err } -// GetDefaultObjectAccessControl returns the default object ACL entry for the specified entity on the -// specified bucket. -func (c *GRPCClient) GetDefaultObjectAccessControl(ctx context.Context, req *storagepb.GetDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) GetDefaultObjectAccessControl(ctx context.Context, req *storagepb.GetDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1353,8 +1694,7 @@ func (c *GRPCClient) GetDefaultObjectAccessControl(ctx context.Context, req *sto return resp, nil } -// InsertDefaultObjectAccessControl creates a new default object ACL entry on the specified bucket. -func (c *GRPCClient) InsertDefaultObjectAccessControl(ctx context.Context, req *storagepb.InsertDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) InsertDefaultObjectAccessControl(ctx context.Context, req *storagepb.InsertDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1374,8 +1714,7 @@ func (c *GRPCClient) InsertDefaultObjectAccessControl(ctx context.Context, req * return resp, nil } -// ListDefaultObjectAccessControls retrieves default object ACL entries on the specified bucket. -func (c *GRPCClient) ListDefaultObjectAccessControls(ctx context.Context, req *storagepb.ListDefaultObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { +func (c *gRPCClient) ListDefaultObjectAccessControls(ctx context.Context, req *storagepb.ListDefaultObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1395,8 +1734,7 @@ func (c *GRPCClient) ListDefaultObjectAccessControls(ctx context.Context, req *s return resp, nil } -// PatchDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. -func (c *GRPCClient) PatchDefaultObjectAccessControl(ctx context.Context, req *storagepb.PatchDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) PatchDefaultObjectAccessControl(ctx context.Context, req *storagepb.PatchDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1416,10 +1754,7 @@ func (c *GRPCClient) PatchDefaultObjectAccessControl(ctx context.Context, req *s return resp, nil } -// UpdateDefaultObjectAccessControl updates a default object ACL entry on the specified bucket. Equivalent to -// PatchDefaultObjectAccessControl, but modifies all unspecified fields to -// their default values. -func (c *GRPCClient) UpdateDefaultObjectAccessControl(ctx context.Context, req *storagepb.UpdateDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) UpdateDefaultObjectAccessControl(ctx context.Context, req *storagepb.UpdateDefaultObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1439,10 +1774,7 @@ func (c *GRPCClient) UpdateDefaultObjectAccessControl(ctx context.Context, req * return resp, nil } -// DeleteNotification permanently deletes a notification subscription. -// Note: Older, “Object Change Notification” push subscriptions should be -// deleted using StopChannel instead. -func (c *GRPCClient) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteNotification(ctx context.Context, req *storagepb.DeleteNotificationRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1458,8 +1790,7 @@ func (c *GRPCClient) DeleteNotification(ctx context.Context, req *storagepb.Dele return err } -// GetNotification view a notification configuration. -func (c *GRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { +func (c *gRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1479,11 +1810,7 @@ func (c *GRPCClient) GetNotification(ctx context.Context, req *storagepb.GetNoti return resp, nil } -// InsertNotification creates a notification subscription for a given bucket. -// These notifications, when triggered, publish messages to the specified -// Cloud Pub/Sub topics. -// See https://cloud.google.com/storage/docs/pubsub-notifications (at https://cloud.google.com/storage/docs/pubsub-notifications). -func (c *GRPCClient) InsertNotification(ctx context.Context, req *storagepb.InsertNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { +func (c *gRPCClient) InsertNotification(ctx context.Context, req *storagepb.InsertNotificationRequest, opts ...gax.CallOption) (*storagepb.Notification, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1503,8 +1830,7 @@ func (c *GRPCClient) InsertNotification(ctx context.Context, req *storagepb.Inse return resp, nil } -// ListNotifications retrieves a list of notification subscriptions for a given bucket. -func (c *GRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) (*storagepb.ListNotificationsResponse, error) { +func (c *gRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListNotificationsRequest, opts ...gax.CallOption) (*storagepb.ListNotificationsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1524,9 +1850,7 @@ func (c *GRPCClient) ListNotifications(ctx context.Context, req *storagepb.ListN return resp, nil } -// DeleteObjectAccessControl permanently deletes the ACL entry for the specified entity on the specified -// object. -func (c *GRPCClient) DeleteObjectAccessControl(ctx context.Context, req *storagepb.DeleteObjectAccessControlRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteObjectAccessControl(ctx context.Context, req *storagepb.DeleteObjectAccessControlRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1542,8 +1866,7 @@ func (c *GRPCClient) DeleteObjectAccessControl(ctx context.Context, req *storage return err } -// GetObjectAccessControl returns the ACL entry for the specified entity on the specified object. -func (c *GRPCClient) GetObjectAccessControl(ctx context.Context, req *storagepb.GetObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) GetObjectAccessControl(ctx context.Context, req *storagepb.GetObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1563,8 +1886,7 @@ func (c *GRPCClient) GetObjectAccessControl(ctx context.Context, req *storagepb. return resp, nil } -// InsertObjectAccessControl creates a new ACL entry on the specified object. -func (c *GRPCClient) InsertObjectAccessControl(ctx context.Context, req *storagepb.InsertObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) InsertObjectAccessControl(ctx context.Context, req *storagepb.InsertObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1584,8 +1906,7 @@ func (c *GRPCClient) InsertObjectAccessControl(ctx context.Context, req *storage return resp, nil } -// ListObjectAccessControls retrieves ACL entries on the specified object. -func (c *GRPCClient) ListObjectAccessControls(ctx context.Context, req *storagepb.ListObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { +func (c *gRPCClient) ListObjectAccessControls(ctx context.Context, req *storagepb.ListObjectAccessControlsRequest, opts ...gax.CallOption) (*storagepb.ListObjectAccessControlsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1605,10 +1926,7 @@ func (c *GRPCClient) ListObjectAccessControls(ctx context.Context, req *storagep return resp, nil } -// PatchObjectAccessControl patches an ACL entry on the specified object. Patch is similar to update, -// but only applies or appends the specified fields in the -// object_access_control object. Other fields are unaffected. -func (c *GRPCClient) PatchObjectAccessControl(ctx context.Context, req *storagepb.PatchObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) PatchObjectAccessControl(ctx context.Context, req *storagepb.PatchObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1628,8 +1946,7 @@ func (c *GRPCClient) PatchObjectAccessControl(ctx context.Context, req *storagep return resp, nil } -// UpdateObjectAccessControl updates an ACL entry on the specified object. -func (c *GRPCClient) UpdateObjectAccessControl(ctx context.Context, req *storagepb.UpdateObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { +func (c *gRPCClient) UpdateObjectAccessControl(ctx context.Context, req *storagepb.UpdateObjectAccessControlRequest, opts ...gax.CallOption) (*storagepb.ObjectAccessControl, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1649,9 +1966,7 @@ func (c *GRPCClient) UpdateObjectAccessControl(ctx context.Context, req *storage return resp, nil } -// ComposeObject concatenates a list of existing objects into a new object in the same -// bucket. -func (c *GRPCClient) ComposeObject(ctx context.Context, req *storagepb.ComposeObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { +func (c *gRPCClient) ComposeObject(ctx context.Context, req *storagepb.ComposeObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1671,9 +1986,7 @@ func (c *GRPCClient) ComposeObject(ctx context.Context, req *storagepb.ComposeOb return resp, nil } -// CopyObject copies a source object to a destination object. Optionally overrides -// metadata. -func (c *GRPCClient) CopyObject(ctx context.Context, req *storagepb.CopyObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { +func (c *gRPCClient) CopyObject(ctx context.Context, req *storagepb.CopyObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1693,10 +2006,7 @@ func (c *GRPCClient) CopyObject(ctx context.Context, req *storagepb.CopyObjectRe return resp, nil } -// DeleteObject deletes an object and its metadata. Deletions are permanent if versioning -// is not enabled for the bucket, or if the generation parameter -// is used. -func (c *GRPCClient) DeleteObject(ctx context.Context, req *storagepb.DeleteObjectRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteObject(ctx context.Context, req *storagepb.DeleteObjectRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1712,8 +2022,7 @@ func (c *GRPCClient) DeleteObject(ctx context.Context, req *storagepb.DeleteObje return err } -// GetObject retrieves an object’s metadata. -func (c *GRPCClient) GetObject(ctx context.Context, req *storagepb.GetObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { +func (c *gRPCClient) GetObject(ctx context.Context, req *storagepb.GetObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1733,8 +2042,7 @@ func (c *GRPCClient) GetObject(ctx context.Context, req *storagepb.GetObjectRequ return resp, nil } -// GetObjectMedia reads an object’s data. -func (c *GRPCClient) GetObjectMedia(ctx context.Context, req *storagepb.GetObjectMediaRequest, opts ...gax.CallOption) (storagepb.Storage_GetObjectMediaClient, error) { +func (c *gRPCClient) GetObjectMedia(ctx context.Context, req *storagepb.GetObjectMediaRequest, opts ...gax.CallOption) (storagepb.Storage_GetObjectMediaClient, error) { ctx = insertMetadata(ctx, c.xGoogMetadata) var resp storagepb.Storage_GetObjectMediaClient err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { @@ -1748,31 +2056,7 @@ func (c *GRPCClient) GetObjectMedia(ctx context.Context, req *storagepb.GetObjec return resp, nil } -// InsertObject stores a new object and metadata. -// -// An object can be written either in a single message stream or in a -// resumable sequence of message streams. To write using a single stream, -// the client should include in the first message of the stream an -// InsertObjectSpec describing the destination bucket, object, and any -// preconditions. Additionally, the final message must set ‘finish_write’ to -// true, or else it is an error. -// -// For a resumable write, the client should instead call -// StartResumableWrite() and provide that method an InsertObjectSpec. -// They should then attach the returned upload_id to the first message of -// each following call to Insert. If there is an error or the connection is -// broken during the resumable Insert(), the client should check the status -// of the Insert() by calling QueryWriteStatus() and continue writing from -// the returned committed_size. This may be less than the amount of data the -// client previously sent. -// -// The service will not view the object as complete until the client has -// sent an Insert with finish_write set to true. Sending any -// requests on a stream after sending a request with finish_write set to -// true will cause an error. The client should check the -// Object it receives to determine how much data the service was -// able to commit and whether the service views the object as complete. -func (c *GRPCClient) InsertObject(ctx context.Context, opts ...gax.CallOption) (storagepb.Storage_InsertObjectClient, error) { +func (c *gRPCClient) InsertObject(ctx context.Context, opts ...gax.CallOption) (storagepb.Storage_InsertObjectClient, error) { ctx = insertMetadata(ctx, c.xGoogMetadata) var resp storagepb.Storage_InsertObjectClient opts = append((*c.CallOptions).InsertObject[0:len((*c.CallOptions).InsertObject):len((*c.CallOptions).InsertObject)], opts...) @@ -1787,8 +2071,7 @@ func (c *GRPCClient) InsertObject(ctx context.Context, opts ...gax.CallOption) ( return resp, nil } -// ListObjects retrieves a list of objects matching the criteria. -func (c *GRPCClient) ListObjects(ctx context.Context, req *storagepb.ListObjectsRequest, opts ...gax.CallOption) (*storagepb.ListObjectsResponse, error) { +func (c *gRPCClient) ListObjects(ctx context.Context, req *storagepb.ListObjectsRequest, opts ...gax.CallOption) (*storagepb.ListObjectsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1808,9 +2091,7 @@ func (c *GRPCClient) ListObjects(ctx context.Context, req *storagepb.ListObjects return resp, nil } -// RewriteObject rewrites a source object to a destination object. Optionally overrides -// metadata. -func (c *GRPCClient) RewriteObject(ctx context.Context, req *storagepb.RewriteObjectRequest, opts ...gax.CallOption) (*storagepb.RewriteResponse, error) { +func (c *gRPCClient) RewriteObject(ctx context.Context, req *storagepb.RewriteObjectRequest, opts ...gax.CallOption) (*storagepb.RewriteResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1830,10 +2111,7 @@ func (c *GRPCClient) RewriteObject(ctx context.Context, req *storagepb.RewriteOb return resp, nil } -// StartResumableWrite starts a resumable write. How long the write operation remains valid, and -// what happens when the write operation becomes invalid, are -// service-dependent. -func (c *GRPCClient) StartResumableWrite(ctx context.Context, req *storagepb.StartResumableWriteRequest, opts ...gax.CallOption) (*storagepb.StartResumableWriteResponse, error) { +func (c *gRPCClient) StartResumableWrite(ctx context.Context, req *storagepb.StartResumableWriteRequest, opts ...gax.CallOption) (*storagepb.StartResumableWriteResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1853,20 +2131,7 @@ func (c *GRPCClient) StartResumableWrite(ctx context.Context, req *storagepb.Sta return resp, nil } -// QueryWriteStatus determines the committed_size for an object that is being written, which -// can then be used as the write_offset for the next Write() call. -// -// If the object does not exist (i.e., the object has been deleted, or the -// first Write() has not yet reached the service), this method returns the -// error NOT_FOUND. -// -// The client may call QueryWriteStatus() at any time to determine how -// much data has been processed for this object. This is useful if the -// client is buffering data and needs to know which data can be safely -// evicted. For any sequence of QueryWriteStatus() calls for a given -// object name, the sequence of returned committed_size values will be -// non-decreasing. -func (c *GRPCClient) QueryWriteStatus(ctx context.Context, req *storagepb.QueryWriteStatusRequest, opts ...gax.CallOption) (*storagepb.QueryWriteStatusResponse, error) { +func (c *gRPCClient) QueryWriteStatus(ctx context.Context, req *storagepb.QueryWriteStatusRequest, opts ...gax.CallOption) (*storagepb.QueryWriteStatusResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1886,8 +2151,7 @@ func (c *GRPCClient) QueryWriteStatus(ctx context.Context, req *storagepb.QueryW return resp, nil } -// PatchObject updates an object’s metadata. -func (c *GRPCClient) PatchObject(ctx context.Context, req *storagepb.PatchObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { +func (c *gRPCClient) PatchObject(ctx context.Context, req *storagepb.PatchObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1907,10 +2171,7 @@ func (c *GRPCClient) PatchObject(ctx context.Context, req *storagepb.PatchObject return resp, nil } -// UpdateObject updates an object’s metadata. Equivalent to PatchObject, but always -// replaces all mutatable fields of the bucket with new values, reverting all -// unspecified fields to their default values. -func (c *GRPCClient) UpdateObject(ctx context.Context, req *storagepb.UpdateObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { +func (c *gRPCClient) UpdateObject(ctx context.Context, req *storagepb.UpdateObjectRequest, opts ...gax.CallOption) (*storagepb.Object, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1930,8 +2191,7 @@ func (c *GRPCClient) UpdateObject(ctx context.Context, req *storagepb.UpdateObje return resp, nil } -// GetObjectIamPolicy gets the IAM policy for the specified object. -func (c *GRPCClient) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { +func (c *gRPCClient) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1951,8 +2211,7 @@ func (c *GRPCClient) GetObjectIamPolicy(ctx context.Context, req *storagepb.GetI return resp, nil } -// SetObjectIamPolicy updates an IAM policy for the specified object. -func (c *GRPCClient) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { +func (c *gRPCClient) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1972,9 +2231,7 @@ func (c *GRPCClient) SetObjectIamPolicy(ctx context.Context, req *storagepb.SetI return resp, nil } -// TestObjectIamPermissions tests a set of permissions on the given object to see which, if -// any, are held by the caller. -func (c *GRPCClient) TestObjectIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { +func (c *gRPCClient) TestObjectIamPermissions(ctx context.Context, req *storagepb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -1994,8 +2251,7 @@ func (c *GRPCClient) TestObjectIamPermissions(ctx context.Context, req *storagep return resp, nil } -// WatchAllObjects watch for changes on all objects in a bucket. -func (c *GRPCClient) WatchAllObjects(ctx context.Context, req *storagepb.WatchAllObjectsRequest, opts ...gax.CallOption) (*storagepb.Channel, error) { +func (c *gRPCClient) WatchAllObjects(ctx context.Context, req *storagepb.WatchAllObjectsRequest, opts ...gax.CallOption) (*storagepb.Channel, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -2015,8 +2271,7 @@ func (c *GRPCClient) WatchAllObjects(ctx context.Context, req *storagepb.WatchAl return resp, nil } -// GetServiceAccount retrieves the name of a project’s Google Cloud Storage service account. -func (c *GRPCClient) GetServiceAccount(ctx context.Context, req *storagepb.GetProjectServiceAccountRequest, opts ...gax.CallOption) (*storagepb.ServiceAccount, error) { +func (c *gRPCClient) GetServiceAccount(ctx context.Context, req *storagepb.GetProjectServiceAccountRequest, opts ...gax.CallOption) (*storagepb.ServiceAccount, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -2036,8 +2291,7 @@ func (c *GRPCClient) GetServiceAccount(ctx context.Context, req *storagepb.GetPr return resp, nil } -// CreateHmacKey creates a new HMAC key for the given service account. -func (c *GRPCClient) CreateHmacKey(ctx context.Context, req *storagepb.CreateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.CreateHmacKeyResponse, error) { +func (c *gRPCClient) CreateHmacKey(ctx context.Context, req *storagepb.CreateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.CreateHmacKeyResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -2057,8 +2311,7 @@ func (c *GRPCClient) CreateHmacKey(ctx context.Context, req *storagepb.CreateHma return resp, nil } -// DeleteHmacKey deletes a given HMAC key. Key must be in an INACTIVE state. -func (c *GRPCClient) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHmacKeyRequest, opts ...gax.CallOption) error { +func (c *gRPCClient) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHmacKeyRequest, opts ...gax.CallOption) error { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -2074,8 +2327,7 @@ func (c *GRPCClient) DeleteHmacKey(ctx context.Context, req *storagepb.DeleteHma return err } -// GetHmacKey gets an existing HMAC key metadata for the given id. -func (c *GRPCClient) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { +func (c *gRPCClient) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -2095,8 +2347,7 @@ func (c *GRPCClient) GetHmacKey(ctx context.Context, req *storagepb.GetHmacKeyRe return resp, nil } -// ListHmacKeys lists HMAC keys under a given project with the additional filters provided. -func (c *GRPCClient) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKeysRequest, opts ...gax.CallOption) (*storagepb.ListHmacKeysResponse, error) { +func (c *gRPCClient) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKeysRequest, opts ...gax.CallOption) (*storagepb.ListHmacKeysResponse, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() @@ -2116,8 +2367,7 @@ func (c *GRPCClient) ListHmacKeys(ctx context.Context, req *storagepb.ListHmacKe return resp, nil } -// UpdateHmacKey updates a given HMAC key state between ACTIVE and INACTIVE. -func (c *GRPCClient) UpdateHmacKey(ctx context.Context, req *storagepb.UpdateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { +func (c *gRPCClient) UpdateHmacKey(ctx context.Context, req *storagepb.UpdateHmacKeyRequest, opts ...gax.CallOption) (*storagepb.HmacKeyMetadata, error) { if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) defer cancel() diff --git a/storage/internal/apiv1/storage_client_example_test.go b/storage/internal/apiv1/storage_client_example_test.go index 6591fc9d209e..8dbd77f7fbea 100644 --- a/storage/internal/apiv1/storage_client_example_test.go +++ b/storage/internal/apiv1/storage_client_example_test.go @@ -29,6 +29,8 @@ func ExampleNewClient() { if err != nil { // TODO: Handle error. } + defer c.Close() + // TODO: Use client. _ = c } @@ -39,6 +41,7 @@ func ExampleClient_DeleteBucketAccessControl() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteBucketAccessControlRequest{ // TODO: Fill request struct fields. @@ -50,13 +53,12 @@ func ExampleClient_DeleteBucketAccessControl() { } func ExampleClient_GetBucketAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetBucketAccessControlRequest{ // TODO: Fill request struct fields. @@ -70,13 +72,12 @@ func ExampleClient_GetBucketAccessControl() { } func ExampleClient_InsertBucketAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.InsertBucketAccessControlRequest{ // TODO: Fill request struct fields. @@ -90,13 +91,12 @@ func ExampleClient_InsertBucketAccessControl() { } func ExampleClient_ListBucketAccessControls() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListBucketAccessControlsRequest{ // TODO: Fill request struct fields. @@ -110,13 +110,12 @@ func ExampleClient_ListBucketAccessControls() { } func ExampleClient_UpdateBucketAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.UpdateBucketAccessControlRequest{ // TODO: Fill request struct fields. @@ -130,13 +129,12 @@ func ExampleClient_UpdateBucketAccessControl() { } func ExampleClient_PatchBucketAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.PatchBucketAccessControlRequest{ // TODO: Fill request struct fields. @@ -155,6 +153,7 @@ func ExampleClient_DeleteBucket() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteBucketRequest{ // TODO: Fill request struct fields. @@ -166,13 +165,12 @@ func ExampleClient_DeleteBucket() { } func ExampleClient_GetBucket() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetBucketRequest{ // TODO: Fill request struct fields. @@ -186,13 +184,12 @@ func ExampleClient_GetBucket() { } func ExampleClient_InsertBucket() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.InsertBucketRequest{ // TODO: Fill request struct fields. @@ -206,13 +203,12 @@ func ExampleClient_InsertBucket() { } func ExampleClient_ListChannels() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListChannelsRequest{ // TODO: Fill request struct fields. @@ -226,13 +222,12 @@ func ExampleClient_ListChannels() { } func ExampleClient_ListBuckets() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListBucketsRequest{ // TODO: Fill request struct fields. @@ -246,13 +241,12 @@ func ExampleClient_ListBuckets() { } func ExampleClient_LockBucketRetentionPolicy() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.LockRetentionPolicyRequest{ // TODO: Fill request struct fields. @@ -266,13 +260,12 @@ func ExampleClient_LockBucketRetentionPolicy() { } func ExampleClient_GetBucketIamPolicy() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetIamPolicyRequest{ // TODO: Fill request struct fields. @@ -286,13 +279,12 @@ func ExampleClient_GetBucketIamPolicy() { } func ExampleClient_SetBucketIamPolicy() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.SetIamPolicyRequest{ // TODO: Fill request struct fields. @@ -306,13 +298,12 @@ func ExampleClient_SetBucketIamPolicy() { } func ExampleClient_TestBucketIamPermissions() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.TestIamPermissionsRequest{ // TODO: Fill request struct fields. @@ -326,13 +317,12 @@ func ExampleClient_TestBucketIamPermissions() { } func ExampleClient_PatchBucket() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.PatchBucketRequest{ // TODO: Fill request struct fields. @@ -346,13 +336,12 @@ func ExampleClient_PatchBucket() { } func ExampleClient_UpdateBucket() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.UpdateBucketRequest{ // TODO: Fill request struct fields. @@ -371,6 +360,7 @@ func ExampleClient_StopChannel() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.StopChannelRequest{ // TODO: Fill request struct fields. @@ -387,6 +377,7 @@ func ExampleClient_DeleteDefaultObjectAccessControl() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteDefaultObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -398,13 +389,12 @@ func ExampleClient_DeleteDefaultObjectAccessControl() { } func ExampleClient_GetDefaultObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetDefaultObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -418,13 +408,12 @@ func ExampleClient_GetDefaultObjectAccessControl() { } func ExampleClient_InsertDefaultObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.InsertDefaultObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -438,13 +427,12 @@ func ExampleClient_InsertDefaultObjectAccessControl() { } func ExampleClient_ListDefaultObjectAccessControls() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListDefaultObjectAccessControlsRequest{ // TODO: Fill request struct fields. @@ -458,13 +446,12 @@ func ExampleClient_ListDefaultObjectAccessControls() { } func ExampleClient_PatchDefaultObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.PatchDefaultObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -478,13 +465,12 @@ func ExampleClient_PatchDefaultObjectAccessControl() { } func ExampleClient_UpdateDefaultObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.UpdateDefaultObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -503,6 +489,7 @@ func ExampleClient_DeleteNotification() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteNotificationRequest{ // TODO: Fill request struct fields. @@ -514,13 +501,12 @@ func ExampleClient_DeleteNotification() { } func ExampleClient_GetNotification() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetNotificationRequest{ // TODO: Fill request struct fields. @@ -534,13 +520,12 @@ func ExampleClient_GetNotification() { } func ExampleClient_InsertNotification() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.InsertNotificationRequest{ // TODO: Fill request struct fields. @@ -554,13 +539,12 @@ func ExampleClient_InsertNotification() { } func ExampleClient_ListNotifications() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListNotificationsRequest{ // TODO: Fill request struct fields. @@ -579,6 +563,7 @@ func ExampleClient_DeleteObjectAccessControl() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -590,13 +575,12 @@ func ExampleClient_DeleteObjectAccessControl() { } func ExampleClient_GetObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -610,13 +594,12 @@ func ExampleClient_GetObjectAccessControl() { } func ExampleClient_InsertObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.InsertObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -630,13 +613,12 @@ func ExampleClient_InsertObjectAccessControl() { } func ExampleClient_ListObjectAccessControls() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListObjectAccessControlsRequest{ // TODO: Fill request struct fields. @@ -650,13 +632,12 @@ func ExampleClient_ListObjectAccessControls() { } func ExampleClient_PatchObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.PatchObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -670,13 +651,12 @@ func ExampleClient_PatchObjectAccessControl() { } func ExampleClient_UpdateObjectAccessControl() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.UpdateObjectAccessControlRequest{ // TODO: Fill request struct fields. @@ -690,13 +670,12 @@ func ExampleClient_UpdateObjectAccessControl() { } func ExampleClient_ComposeObject() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ComposeObjectRequest{ // TODO: Fill request struct fields. @@ -710,13 +689,12 @@ func ExampleClient_ComposeObject() { } func ExampleClient_CopyObject() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.CopyObjectRequest{ // TODO: Fill request struct fields. @@ -735,6 +713,7 @@ func ExampleClient_DeleteObject() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteObjectRequest{ // TODO: Fill request struct fields. @@ -746,13 +725,12 @@ func ExampleClient_DeleteObject() { } func ExampleClient_GetObject() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetObjectRequest{ // TODO: Fill request struct fields. @@ -766,13 +744,12 @@ func ExampleClient_GetObject() { } func ExampleClient_ListObjects() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListObjectsRequest{ // TODO: Fill request struct fields. @@ -786,13 +763,12 @@ func ExampleClient_ListObjects() { } func ExampleClient_RewriteObject() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.RewriteObjectRequest{ // TODO: Fill request struct fields. @@ -806,13 +782,12 @@ func ExampleClient_RewriteObject() { } func ExampleClient_StartResumableWrite() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.StartResumableWriteRequest{ // TODO: Fill request struct fields. @@ -826,13 +801,12 @@ func ExampleClient_StartResumableWrite() { } func ExampleClient_QueryWriteStatus() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.QueryWriteStatusRequest{ // TODO: Fill request struct fields. @@ -846,13 +820,12 @@ func ExampleClient_QueryWriteStatus() { } func ExampleClient_PatchObject() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.PatchObjectRequest{ // TODO: Fill request struct fields. @@ -866,13 +839,12 @@ func ExampleClient_PatchObject() { } func ExampleClient_UpdateObject() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.UpdateObjectRequest{ // TODO: Fill request struct fields. @@ -886,13 +858,12 @@ func ExampleClient_UpdateObject() { } func ExampleClient_GetObjectIamPolicy() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetIamPolicyRequest{ // TODO: Fill request struct fields. @@ -906,13 +877,12 @@ func ExampleClient_GetObjectIamPolicy() { } func ExampleClient_SetObjectIamPolicy() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.SetIamPolicyRequest{ // TODO: Fill request struct fields. @@ -926,13 +896,12 @@ func ExampleClient_SetObjectIamPolicy() { } func ExampleClient_TestObjectIamPermissions() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.TestIamPermissionsRequest{ // TODO: Fill request struct fields. @@ -946,13 +915,12 @@ func ExampleClient_TestObjectIamPermissions() { } func ExampleClient_WatchAllObjects() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.WatchAllObjectsRequest{ // TODO: Fill request struct fields. @@ -966,13 +934,12 @@ func ExampleClient_WatchAllObjects() { } func ExampleClient_GetServiceAccount() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetProjectServiceAccountRequest{ // TODO: Fill request struct fields. @@ -986,13 +953,12 @@ func ExampleClient_GetServiceAccount() { } func ExampleClient_CreateHmacKey() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.CreateHmacKeyRequest{ // TODO: Fill request struct fields. @@ -1011,6 +977,7 @@ func ExampleClient_DeleteHmacKey() { if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.DeleteHmacKeyRequest{ // TODO: Fill request struct fields. @@ -1022,13 +989,12 @@ func ExampleClient_DeleteHmacKey() { } func ExampleClient_GetHmacKey() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.GetHmacKeyRequest{ // TODO: Fill request struct fields. @@ -1042,13 +1008,12 @@ func ExampleClient_GetHmacKey() { } func ExampleClient_ListHmacKeys() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.ListHmacKeysRequest{ // TODO: Fill request struct fields. @@ -1062,13 +1027,12 @@ func ExampleClient_ListHmacKeys() { } func ExampleClient_UpdateHmacKey() { - // import storagepb "google.golang.org/genproto/googleapis/storage/v1" - ctx := context.Background() c, err := storage.NewClient(ctx) if err != nil { // TODO: Handle error. } + defer c.Close() req := &storagepb.UpdateHmacKeyRequest{ // TODO: Fill request struct fields. From 9f682c07d89bf665a8ba884361c906a045893e02 Mon Sep 17 00:00:00 2001 From: noahdietz Date: Thu, 24 Jun 2021 15:12:15 -0700 Subject: [PATCH 5/6] fix microgen config test --- internal/gapicgen/generator/config.go | 1 + internal/gapicgen/generator/config_test.go | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 615f4af71d4f..4447a95260fa 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -1210,5 +1210,6 @@ var microgenGapicConfigs = []*microgenConfig{ importPath: "cloud.google.com/go/storage/internal/apiv1", gRPCServiceConfigPath: "google/storage/v1/storage_grpc_service_config.json", apiServiceConfigPath: "google/storage/v1/storage_v1.yaml", + releaseLevel: "alpha", }, } diff --git a/internal/gapicgen/generator/config_test.go b/internal/gapicgen/generator/config_test.go index b5d61a77b51f..6145b7d0a85d 100644 --- a/internal/gapicgen/generator/config_test.go +++ b/internal/gapicgen/generator/config_test.go @@ -26,10 +26,11 @@ var allowedReleaseLevels = map[string]bool{ } var apivExceptions = map[string]bool{ - "cloud.google.com/go/longrunning/autogen": true, - "cloud.google.com/go/firestore/apiv1/admin": true, - "cloud.google.com/go/cloudbuild/apiv1/v2": true, - "cloud.google.com/go/monitoring/apiv3/v2": true, + "cloud.google.com/go/longrunning/autogen": true, + "cloud.google.com/go/firestore/apiv1/admin": true, + "cloud.google.com/go/cloudbuild/apiv1/v2": true, + "cloud.google.com/go/monitoring/apiv3/v2": true, + "cloud.google.com/go/storage/internal/apiv1": true, } var packagePathExceptions = map[string]bool{ From e992c2f4c3965e5204078c789f182df646441602 Mon Sep 17 00:00:00 2001 From: noahdietz Date: Thu, 24 Jun 2021 15:39:25 -0700 Subject: [PATCH 6/6] fix config test --- internal/gapicgen/generator/config_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/gapicgen/generator/config_test.go b/internal/gapicgen/generator/config_test.go index 6145b7d0a85d..9460acf0c852 100644 --- a/internal/gapicgen/generator/config_test.go +++ b/internal/gapicgen/generator/config_test.go @@ -26,16 +26,16 @@ var allowedReleaseLevels = map[string]bool{ } var apivExceptions = map[string]bool{ - "cloud.google.com/go/longrunning/autogen": true, - "cloud.google.com/go/firestore/apiv1/admin": true, - "cloud.google.com/go/cloudbuild/apiv1/v2": true, - "cloud.google.com/go/monitoring/apiv3/v2": true, - "cloud.google.com/go/storage/internal/apiv1": true, + "cloud.google.com/go/longrunning/autogen": true, + "cloud.google.com/go/firestore/apiv1/admin": true, + "cloud.google.com/go/cloudbuild/apiv1/v2": true, + "cloud.google.com/go/monitoring/apiv3/v2": true, } var packagePathExceptions = map[string]bool{ - "cloud.google.com/go/longrunning/autogen": true, - "cloud.google.com/go/firestore/apiv1/admin": true, + "cloud.google.com/go/longrunning/autogen": true, + "cloud.google.com/go/firestore/apiv1/admin": true, + "cloud.google.com/go/storage/internal/apiv1": true, } // TestMicrogenConfigs validates config entries.