From 63fdb2ee21d70e2de71641a5c19a448fd1c39f56 Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Tue, 29 Jun 2021 14:22:35 -0700 Subject: [PATCH] chore(storage): generate GAPIC under internal subdir (#4018) Add a gRPC Go GAPIC for the Storage API under an internal subdirectory of the submodule to ensure no one can import it. This GAPIC is being added for proof of concept development and should not be used in production or by any other client library. Generated with the following: ```bash $ cd google-cloud-go $ export GOOGLE_CLOUD_GO=$(pwd) $ cd internal/gapicgen $ go run cloud.google.com/go/internal/gapicgen/cmd/genbot \ -local \ -regen-only \ -only-gapics \ -gapic=cloud.google.com/go/storage/internal/apiv1 \ -gocloud-dir=$GOOGLE_CLOUD_GO ``` --- internal/gapicgen/generator/config.go | 8 + internal/gapicgen/generator/config_test.go | 5 +- storage/internal/apiv1/doc.go | 120 + storage/internal/apiv1/gapic_metadata.json | 298 ++ storage/internal/apiv1/storage_client.go | 2388 +++++++++++++++++ .../apiv1/storage_client_example_test.go | 1046 ++++++++ 6 files changed, 3863 insertions(+), 2 deletions(-) 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 8234ba355781..b7f4ea4fb3e5 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -1222,4 +1222,12 @@ var microgenGapicConfigs = []*microgenConfig{ // GA after 2021/06/10 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", + releaseLevel: "alpha", + }, } diff --git a/internal/gapicgen/generator/config_test.go b/internal/gapicgen/generator/config_test.go index b5d61a77b51f..9460acf0c852 100644 --- a/internal/gapicgen/generator/config_test.go +++ b/internal/gapicgen/generator/config_test.go @@ -33,8 +33,9 @@ var apivExceptions = map[string]bool{ } 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. diff --git a/storage/internal/apiv1/doc.go b/storage/internal/apiv1/doc.go new file mode 100644 index 000000000000..ea45239e75cf --- /dev/null +++ b/storage/internal/apiv1/doc.go @@ -0,0 +1,120 @@ +// 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" + "strconv" + "strings" + "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..b3a8f901993c --- /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..994ed4556f91 --- /dev/null +++ b/storage/internal/apiv1/storage_client.go @@ -0,0 +1,2388 @@ +// 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()...), + internaloption.EnableJwtWithScope(), + 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. +// +// Manages Google Cloud Storage resources. +type Client struct { + // The internal transport-dependent client. + internalClient internalClient + + // The call options for this service. + CallOptions *CallOptions +} + +// 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 { + // 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. +// 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) { + 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() +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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 +} + +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..8dbd77f7fbea --- /dev/null +++ b/storage/internal/apiv1/storage_client_example_test.go @@ -0,0 +1,1046 @@ +// 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. + } + defer c.Close() + + // TODO: Use client. + _ = c +} + +func ExampleClient_DeleteBucketAccessControl() { + ctx := context.Background() + c, err := storage.NewClient(ctx) + if err != nil { + // TODO: Handle error. + } + defer c.Close() + + req := &storagepb.DeleteBucketAccessControlRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetBucketAccessControl() { + 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. + } + resp, err := c.GetBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertBucketAccessControl() { + 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. + } + resp, err := c.InsertBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListBucketAccessControls() { + 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. + } + resp, err := c.ListBucketAccessControls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateBucketAccessControl() { + 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. + } + resp, err := c.UpdateBucketAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchBucketAccessControl() { + 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. + } + 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. + } + defer c.Close() + + req := &storagepb.DeleteBucketRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetBucket() { + 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. + } + resp, err := c.GetBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertBucket() { + 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. + } + resp, err := c.InsertBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListChannels() { + 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. + } + resp, err := c.ListChannels(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListBuckets() { + 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. + } + resp, err := c.ListBuckets(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_LockBucketRetentionPolicy() { + 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. + } + resp, err := c.LockBucketRetentionPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetBucketIamPolicy() { + 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. + } + resp, err := c.GetBucketIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_SetBucketIamPolicy() { + 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. + } + resp, err := c.SetBucketIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_TestBucketIamPermissions() { + 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. + } + resp, err := c.TestBucketIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchBucket() { + 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. + } + resp, err := c.PatchBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateBucket() { + 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. + } + 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. + } + defer c.Close() + + 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. + } + defer c.Close() + + req := &storagepb.DeleteDefaultObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetDefaultObjectAccessControl() { + 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. + } + resp, err := c.GetDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertDefaultObjectAccessControl() { + 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. + } + resp, err := c.InsertDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListDefaultObjectAccessControls() { + 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. + } + resp, err := c.ListDefaultObjectAccessControls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchDefaultObjectAccessControl() { + 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. + } + resp, err := c.PatchDefaultObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateDefaultObjectAccessControl() { + 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. + } + 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. + } + defer c.Close() + + req := &storagepb.DeleteNotificationRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteNotification(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetNotification() { + 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. + } + resp, err := c.GetNotification(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertNotification() { + 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. + } + resp, err := c.InsertNotification(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListNotifications() { + 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. + } + 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. + } + defer c.Close() + + req := &storagepb.DeleteObjectAccessControlRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetObjectAccessControl() { + 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. + } + resp, err := c.GetObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_InsertObjectAccessControl() { + 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. + } + resp, err := c.InsertObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListObjectAccessControls() { + 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. + } + resp, err := c.ListObjectAccessControls(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchObjectAccessControl() { + 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. + } + resp, err := c.PatchObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateObjectAccessControl() { + 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. + } + resp, err := c.UpdateObjectAccessControl(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ComposeObject() { + 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. + } + resp, err := c.ComposeObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_CopyObject() { + 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. + } + 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. + } + defer c.Close() + + req := &storagepb.DeleteObjectRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteObject(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetObject() { + 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. + } + resp, err := c.GetObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListObjects() { + 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. + } + resp, err := c.ListObjects(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_RewriteObject() { + 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. + } + resp, err := c.RewriteObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_StartResumableWrite() { + 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. + } + resp, err := c.StartResumableWrite(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_QueryWriteStatus() { + 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. + } + resp, err := c.QueryWriteStatus(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_PatchObject() { + 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. + } + resp, err := c.PatchObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateObject() { + 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. + } + resp, err := c.UpdateObject(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetObjectIamPolicy() { + 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. + } + resp, err := c.GetObjectIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_SetObjectIamPolicy() { + 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. + } + resp, err := c.SetObjectIamPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_TestObjectIamPermissions() { + 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. + } + resp, err := c.TestObjectIamPermissions(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_WatchAllObjects() { + 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. + } + resp, err := c.WatchAllObjects(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_GetServiceAccount() { + 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. + } + resp, err := c.GetServiceAccount(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_CreateHmacKey() { + 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. + } + 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. + } + defer c.Close() + + req := &storagepb.DeleteHmacKeyRequest{ + // TODO: Fill request struct fields. + } + err = c.DeleteHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleClient_GetHmacKey() { + 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. + } + resp, err := c.GetHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_ListHmacKeys() { + 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. + } + resp, err := c.ListHmacKeys(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleClient_UpdateHmacKey() { + 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. + } + resp, err := c.UpdateHmacKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +}