cloud.google.com/go/aiplatform@v1.106.0/apiv1/helpers.go (about) 1 // Copyright 2025 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17 package aiplatform 18 19 import ( 20 "context" 21 "fmt" 22 "log/slog" 23 24 "github.com/googleapis/gax-go/v2/internallog/grpclog" 25 "google.golang.org/api/option" 26 "google.golang.org/grpc" 27 "google.golang.org/protobuf/proto" 28 "google.golang.org/protobuf/runtime/protoimpl" 29 ) 30 31 const serviceName = "aiplatform.googleapis.com" 32 33 var protoVersion = fmt.Sprintf("1.%d", protoimpl.MaxVersion) 34 35 // For more information on implementing a client constructor hook, see 36 // https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. 37 type clientHookParams struct{} 38 type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) 39 40 var versionClient string 41 42 func getVersionClient() string { 43 if versionClient == "" { 44 return "UNKNOWN" 45 } 46 return versionClient 47 } 48 49 // DefaultAuthScopes reports the default set of authentication scopes to use with this package. 50 func DefaultAuthScopes() []string { 51 return []string{ 52 "https://www.googleapis.com/auth/cloud-platform", 53 "https://www.googleapis.com/auth/cloud-platform.read-only", 54 } 55 } 56 57 func executeRPC[I proto.Message, O proto.Message](ctx context.Context, fn func(context.Context, I, ...grpc.CallOption) (O, error), req I, opts []grpc.CallOption, logger *slog.Logger, rpc string) (O, error) { 58 var zero O 59 logger.DebugContext(ctx, "api request", "serviceName", serviceName, "rpcName", rpc, "request", grpclog.ProtoMessageRequest(ctx, req)) 60 resp, err := fn(ctx, req, opts...) 61 if err != nil { 62 return zero, err 63 } 64 logger.DebugContext(ctx, "api response", "serviceName", serviceName, "rpcName", rpc, "response", grpclog.ProtoMessageResponse(resp)) 65 return resp, err 66 }