cloud.google.com/go/aiplatform@v1.106.0/apiv1/prediction_client.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  	"math"
    24  	"net/url"
    25  
    26  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1/aiplatformpb"
    27  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    28  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    29  	gax "github.com/googleapis/gax-go/v2"
    30  	"google.golang.org/api/iterator"
    31  	"google.golang.org/api/option"
    32  	"google.golang.org/api/option/internaloption"
    33  	gtransport "google.golang.org/api/transport/grpc"
    34  	httpbodypb "google.golang.org/genproto/googleapis/api/httpbody"
    35  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    36  	"google.golang.org/grpc"
    37  	"google.golang.org/protobuf/proto"
    38  )
    39  
    40  var newPredictionClientHook clientHook
    41  
    42  // PredictionCallOptions contains the retry settings for each method of PredictionClient.
    43  type PredictionCallOptions struct {
    44  	Predict                []gax.CallOption
    45  	RawPredict             []gax.CallOption
    46  	StreamRawPredict       []gax.CallOption
    47  	DirectPredict          []gax.CallOption
    48  	DirectRawPredict       []gax.CallOption
    49  	StreamDirectPredict    []gax.CallOption
    50  	StreamDirectRawPredict []gax.CallOption
    51  	StreamingPredict       []gax.CallOption
    52  	ServerStreamingPredict []gax.CallOption
    53  	StreamingRawPredict    []gax.CallOption
    54  	Explain                []gax.CallOption
    55  	GenerateContent        []gax.CallOption
    56  	StreamGenerateContent  []gax.CallOption
    57  	GetLocation            []gax.CallOption
    58  	ListLocations          []gax.CallOption
    59  	GetIamPolicy           []gax.CallOption
    60  	SetIamPolicy           []gax.CallOption
    61  	TestIamPermissions     []gax.CallOption
    62  	CancelOperation        []gax.CallOption
    63  	DeleteOperation        []gax.CallOption
    64  	GetOperation           []gax.CallOption
    65  	ListOperations         []gax.CallOption
    66  	WaitOperation          []gax.CallOption
    67  }
    68  
    69  func defaultPredictionGRPCClientOptions() []option.ClientOption {
    70  	return []option.ClientOption{
    71  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    72  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    73  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    74  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    75  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    76  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    77  		internaloption.EnableJwtWithScope(),
    78  		internaloption.EnableNewAuthLibrary(),
    79  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    80  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    81  	}
    82  }
    83  
    84  func defaultPredictionCallOptions() *PredictionCallOptions {
    85  	return &PredictionCallOptions{
    86  		Predict:                []gax.CallOption{},
    87  		RawPredict:             []gax.CallOption{},
    88  		StreamRawPredict:       []gax.CallOption{},
    89  		DirectPredict:          []gax.CallOption{},
    90  		DirectRawPredict:       []gax.CallOption{},
    91  		StreamDirectPredict:    []gax.CallOption{},
    92  		StreamDirectRawPredict: []gax.CallOption{},
    93  		StreamingPredict:       []gax.CallOption{},
    94  		ServerStreamingPredict: []gax.CallOption{},
    95  		StreamingRawPredict:    []gax.CallOption{},
    96  		Explain:                []gax.CallOption{},
    97  		GenerateContent:        []gax.CallOption{},
    98  		StreamGenerateContent:  []gax.CallOption{},
    99  		GetLocation:            []gax.CallOption{},
   100  		ListLocations:          []gax.CallOption{},
   101  		GetIamPolicy:           []gax.CallOption{},
   102  		SetIamPolicy:           []gax.CallOption{},
   103  		TestIamPermissions:     []gax.CallOption{},
   104  		CancelOperation:        []gax.CallOption{},
   105  		DeleteOperation:        []gax.CallOption{},
   106  		GetOperation:           []gax.CallOption{},
   107  		ListOperations:         []gax.CallOption{},
   108  		WaitOperation:          []gax.CallOption{},
   109  	}
   110  }
   111  
   112  // internalPredictionClient is an interface that defines the methods available from Vertex AI API.
   113  type internalPredictionClient interface {
   114  	Close() error
   115  	setGoogleClientInfo(...string)
   116  	Connection() *grpc.ClientConn
   117  	Predict(context.Context, *aiplatformpb.PredictRequest, ...gax.CallOption) (*aiplatformpb.PredictResponse, error)
   118  	RawPredict(context.Context, *aiplatformpb.RawPredictRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
   119  	StreamRawPredict(context.Context, *aiplatformpb.StreamRawPredictRequest, ...gax.CallOption) (aiplatformpb.PredictionService_StreamRawPredictClient, error)
   120  	DirectPredict(context.Context, *aiplatformpb.DirectPredictRequest, ...gax.CallOption) (*aiplatformpb.DirectPredictResponse, error)
   121  	DirectRawPredict(context.Context, *aiplatformpb.DirectRawPredictRequest, ...gax.CallOption) (*aiplatformpb.DirectRawPredictResponse, error)
   122  	StreamDirectPredict(context.Context, ...gax.CallOption) (aiplatformpb.PredictionService_StreamDirectPredictClient, error)
   123  	StreamDirectRawPredict(context.Context, ...gax.CallOption) (aiplatformpb.PredictionService_StreamDirectRawPredictClient, error)
   124  	StreamingPredict(context.Context, ...gax.CallOption) (aiplatformpb.PredictionService_StreamingPredictClient, error)
   125  	ServerStreamingPredict(context.Context, *aiplatformpb.StreamingPredictRequest, ...gax.CallOption) (aiplatformpb.PredictionService_ServerStreamingPredictClient, error)
   126  	StreamingRawPredict(context.Context, ...gax.CallOption) (aiplatformpb.PredictionService_StreamingRawPredictClient, error)
   127  	Explain(context.Context, *aiplatformpb.ExplainRequest, ...gax.CallOption) (*aiplatformpb.ExplainResponse, error)
   128  	GenerateContent(context.Context, *aiplatformpb.GenerateContentRequest, ...gax.CallOption) (*aiplatformpb.GenerateContentResponse, error)
   129  	StreamGenerateContent(context.Context, *aiplatformpb.GenerateContentRequest, ...gax.CallOption) (aiplatformpb.PredictionService_StreamGenerateContentClient, error)
   130  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   131  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   132  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   133  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   134  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   135  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   136  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   137  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   138  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   139  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   140  }
   141  
   142  // PredictionClient is a client for interacting with Vertex AI API.
   143  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   144  //
   145  // A service for online predictions and explanations.
   146  type PredictionClient struct {
   147  	// The internal transport-dependent client.
   148  	internalClient internalPredictionClient
   149  
   150  	// The call options for this service.
   151  	CallOptions *PredictionCallOptions
   152  }
   153  
   154  // Wrapper methods routed to the internal client.
   155  
   156  // Close closes the connection to the API service. The user should invoke this when
   157  // the client is no longer required.
   158  func (c *PredictionClient) Close() error {
   159  	return c.internalClient.Close()
   160  }
   161  
   162  // setGoogleClientInfo sets the name and version of the application in
   163  // the `x-goog-api-client` header passed on each request. Intended for
   164  // use by Google-written clients.
   165  func (c *PredictionClient) setGoogleClientInfo(keyval ...string) {
   166  	c.internalClient.setGoogleClientInfo(keyval...)
   167  }
   168  
   169  // Connection returns a connection to the API service.
   170  //
   171  // Deprecated: Connections are now pooled so this method does not always
   172  // return the same resource.
   173  func (c *PredictionClient) Connection() *grpc.ClientConn {
   174  	return c.internalClient.Connection()
   175  }
   176  
   177  // Predict perform an online prediction.
   178  func (c *PredictionClient) Predict(ctx context.Context, req *aiplatformpb.PredictRequest, opts ...gax.CallOption) (*aiplatformpb.PredictResponse, error) {
   179  	return c.internalClient.Predict(ctx, req, opts...)
   180  }
   181  
   182  // RawPredict perform an online prediction with an arbitrary HTTP payload.
   183  //
   184  // The response includes the following HTTP headers:
   185  //
   186  //	X-Vertex-AI-Endpoint-Id: ID of the
   187  //	Endpoint that served this
   188  //	prediction.
   189  //
   190  //	X-Vertex-AI-Deployed-Model-Id: ID of the Endpoint’s
   191  //	DeployedModel that served this
   192  //	prediction.
   193  func (c *PredictionClient) RawPredict(ctx context.Context, req *aiplatformpb.RawPredictRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
   194  	return c.internalClient.RawPredict(ctx, req, opts...)
   195  }
   196  
   197  // StreamRawPredict perform a streaming online prediction with an arbitrary HTTP payload.
   198  func (c *PredictionClient) StreamRawPredict(ctx context.Context, req *aiplatformpb.StreamRawPredictRequest, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamRawPredictClient, error) {
   199  	return c.internalClient.StreamRawPredict(ctx, req, opts...)
   200  }
   201  
   202  // DirectPredict perform an unary online prediction request to a gRPC model server for
   203  // Vertex first-party products and frameworks.
   204  func (c *PredictionClient) DirectPredict(ctx context.Context, req *aiplatformpb.DirectPredictRequest, opts ...gax.CallOption) (*aiplatformpb.DirectPredictResponse, error) {
   205  	return c.internalClient.DirectPredict(ctx, req, opts...)
   206  }
   207  
   208  // DirectRawPredict perform an unary online prediction request to a gRPC model server for
   209  // custom containers.
   210  func (c *PredictionClient) DirectRawPredict(ctx context.Context, req *aiplatformpb.DirectRawPredictRequest, opts ...gax.CallOption) (*aiplatformpb.DirectRawPredictResponse, error) {
   211  	return c.internalClient.DirectRawPredict(ctx, req, opts...)
   212  }
   213  
   214  // StreamDirectPredict perform a streaming online prediction request to a gRPC model server for
   215  // Vertex first-party products and frameworks.
   216  func (c *PredictionClient) StreamDirectPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamDirectPredictClient, error) {
   217  	return c.internalClient.StreamDirectPredict(ctx, opts...)
   218  }
   219  
   220  // StreamDirectRawPredict perform a streaming online prediction request to a gRPC model server for
   221  // custom containers.
   222  func (c *PredictionClient) StreamDirectRawPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamDirectRawPredictClient, error) {
   223  	return c.internalClient.StreamDirectRawPredict(ctx, opts...)
   224  }
   225  
   226  // StreamingPredict perform a streaming online prediction request for Vertex first-party
   227  // products and frameworks.
   228  func (c *PredictionClient) StreamingPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamingPredictClient, error) {
   229  	return c.internalClient.StreamingPredict(ctx, opts...)
   230  }
   231  
   232  // ServerStreamingPredict perform a server-side streaming online prediction request for Vertex
   233  // LLM streaming.
   234  func (c *PredictionClient) ServerStreamingPredict(ctx context.Context, req *aiplatformpb.StreamingPredictRequest, opts ...gax.CallOption) (aiplatformpb.PredictionService_ServerStreamingPredictClient, error) {
   235  	return c.internalClient.ServerStreamingPredict(ctx, req, opts...)
   236  }
   237  
   238  // StreamingRawPredict perform a streaming online prediction request through gRPC.
   239  func (c *PredictionClient) StreamingRawPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamingRawPredictClient, error) {
   240  	return c.internalClient.StreamingRawPredict(ctx, opts...)
   241  }
   242  
   243  // Explain perform an online explanation.
   244  //
   245  // If
   246  // deployed_model_id
   247  // is specified, the corresponding DeployModel must have
   248  // explanation_spec
   249  // populated. If
   250  // deployed_model_id
   251  // is not specified, all DeployedModels must have
   252  // explanation_spec
   253  // populated.
   254  func (c *PredictionClient) Explain(ctx context.Context, req *aiplatformpb.ExplainRequest, opts ...gax.CallOption) (*aiplatformpb.ExplainResponse, error) {
   255  	return c.internalClient.Explain(ctx, req, opts...)
   256  }
   257  
   258  // GenerateContent generate content with multimodal inputs.
   259  func (c *PredictionClient) GenerateContent(ctx context.Context, req *aiplatformpb.GenerateContentRequest, opts ...gax.CallOption) (*aiplatformpb.GenerateContentResponse, error) {
   260  	return c.internalClient.GenerateContent(ctx, req, opts...)
   261  }
   262  
   263  // StreamGenerateContent generate content with multimodal inputs with streaming support.
   264  func (c *PredictionClient) StreamGenerateContent(ctx context.Context, req *aiplatformpb.GenerateContentRequest, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamGenerateContentClient, error) {
   265  	return c.internalClient.StreamGenerateContent(ctx, req, opts...)
   266  }
   267  
   268  // GetLocation gets information about a location.
   269  func (c *PredictionClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   270  	return c.internalClient.GetLocation(ctx, req, opts...)
   271  }
   272  
   273  // ListLocations lists information about the supported locations for this service.
   274  func (c *PredictionClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   275  	return c.internalClient.ListLocations(ctx, req, opts...)
   276  }
   277  
   278  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   279  // if the resource exists and does not have a policy set.
   280  func (c *PredictionClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   281  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   282  }
   283  
   284  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   285  // any existing policy.
   286  //
   287  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   288  // errors.
   289  func (c *PredictionClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   290  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   291  }
   292  
   293  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   294  // resource does not exist, this will return an empty set of
   295  // permissions, not a NOT_FOUND error.
   296  //
   297  // Note: This operation is designed to be used for building
   298  // permission-aware UIs and command-line tools, not for authorization
   299  // checking. This operation may “fail open” without warning.
   300  func (c *PredictionClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   301  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   302  }
   303  
   304  // CancelOperation is a utility method from google.longrunning.Operations.
   305  func (c *PredictionClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   306  	return c.internalClient.CancelOperation(ctx, req, opts...)
   307  }
   308  
   309  // DeleteOperation is a utility method from google.longrunning.Operations.
   310  func (c *PredictionClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   311  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   312  }
   313  
   314  // GetOperation is a utility method from google.longrunning.Operations.
   315  func (c *PredictionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   316  	return c.internalClient.GetOperation(ctx, req, opts...)
   317  }
   318  
   319  // ListOperations is a utility method from google.longrunning.Operations.
   320  func (c *PredictionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   321  	return c.internalClient.ListOperations(ctx, req, opts...)
   322  }
   323  
   324  // WaitOperation is a utility method from google.longrunning.Operations.
   325  func (c *PredictionClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   326  	return c.internalClient.WaitOperation(ctx, req, opts...)
   327  }
   328  
   329  // predictionGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   330  //
   331  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   332  type predictionGRPCClient struct {
   333  	// Connection pool of gRPC connections to the service.
   334  	connPool gtransport.ConnPool
   335  
   336  	// Points back to the CallOptions field of the containing PredictionClient
   337  	CallOptions **PredictionCallOptions
   338  
   339  	// The gRPC API client.
   340  	predictionClient aiplatformpb.PredictionServiceClient
   341  
   342  	operationsClient longrunningpb.OperationsClient
   343  
   344  	iamPolicyClient iampb.IAMPolicyClient
   345  
   346  	locationsClient locationpb.LocationsClient
   347  
   348  	// The x-goog-* metadata to be sent with each request.
   349  	xGoogHeaders []string
   350  
   351  	logger *slog.Logger
   352  }
   353  
   354  // NewPredictionClient creates a new prediction service client based on gRPC.
   355  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   356  //
   357  // A service for online predictions and explanations.
   358  func NewPredictionClient(ctx context.Context, opts ...option.ClientOption) (*PredictionClient, error) {
   359  	clientOpts := defaultPredictionGRPCClientOptions()
   360  	if newPredictionClientHook != nil {
   361  		hookOpts, err := newPredictionClientHook(ctx, clientHookParams{})
   362  		if err != nil {
   363  			return nil, err
   364  		}
   365  		clientOpts = append(clientOpts, hookOpts...)
   366  	}
   367  
   368  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   369  	if err != nil {
   370  		return nil, err
   371  	}
   372  	client := PredictionClient{CallOptions: defaultPredictionCallOptions()}
   373  
   374  	c := &predictionGRPCClient{
   375  		connPool:         connPool,
   376  		predictionClient: aiplatformpb.NewPredictionServiceClient(connPool),
   377  		CallOptions:      &client.CallOptions,
   378  		logger:           internaloption.GetLogger(opts),
   379  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   380  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   381  		locationsClient:  locationpb.NewLocationsClient(connPool),
   382  	}
   383  	c.setGoogleClientInfo()
   384  
   385  	client.internalClient = c
   386  
   387  	return &client, nil
   388  }
   389  
   390  // Connection returns a connection to the API service.
   391  //
   392  // Deprecated: Connections are now pooled so this method does not always
   393  // return the same resource.
   394  func (c *predictionGRPCClient) Connection() *grpc.ClientConn {
   395  	return c.connPool.Conn()
   396  }
   397  
   398  // setGoogleClientInfo sets the name and version of the application in
   399  // the `x-goog-api-client` header passed on each request. Intended for
   400  // use by Google-written clients.
   401  func (c *predictionGRPCClient) setGoogleClientInfo(keyval ...string) {
   402  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   403  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   404  	c.xGoogHeaders = []string{
   405  		"x-goog-api-client", gax.XGoogHeader(kv...),
   406  	}
   407  }
   408  
   409  // Close closes the connection to the API service. The user should invoke this when
   410  // the client is no longer required.
   411  func (c *predictionGRPCClient) Close() error {
   412  	return c.connPool.Close()
   413  }
   414  
   415  func (c *predictionGRPCClient) Predict(ctx context.Context, req *aiplatformpb.PredictRequest, opts ...gax.CallOption) (*aiplatformpb.PredictResponse, error) {
   416  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   417  
   418  	hds = append(c.xGoogHeaders, hds...)
   419  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   420  	opts = append((*c.CallOptions).Predict[0:len((*c.CallOptions).Predict):len((*c.CallOptions).Predict)], opts...)
   421  	var resp *aiplatformpb.PredictResponse
   422  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   423  		var err error
   424  		resp, err = executeRPC(ctx, c.predictionClient.Predict, req, settings.GRPC, c.logger, "Predict")
   425  		return err
   426  	}, opts...)
   427  	if err != nil {
   428  		return nil, err
   429  	}
   430  	return resp, nil
   431  }
   432  
   433  func (c *predictionGRPCClient) RawPredict(ctx context.Context, req *aiplatformpb.RawPredictRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
   434  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   435  
   436  	hds = append(c.xGoogHeaders, hds...)
   437  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   438  	opts = append((*c.CallOptions).RawPredict[0:len((*c.CallOptions).RawPredict):len((*c.CallOptions).RawPredict)], opts...)
   439  	var resp *httpbodypb.HttpBody
   440  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   441  		var err error
   442  		resp, err = executeRPC(ctx, c.predictionClient.RawPredict, req, settings.GRPC, c.logger, "RawPredict")
   443  		return err
   444  	}, opts...)
   445  	if err != nil {
   446  		return nil, err
   447  	}
   448  	return resp, nil
   449  }
   450  
   451  func (c *predictionGRPCClient) StreamRawPredict(ctx context.Context, req *aiplatformpb.StreamRawPredictRequest, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamRawPredictClient, error) {
   452  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   453  
   454  	hds = append(c.xGoogHeaders, hds...)
   455  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   456  	opts = append((*c.CallOptions).StreamRawPredict[0:len((*c.CallOptions).StreamRawPredict):len((*c.CallOptions).StreamRawPredict)], opts...)
   457  	var resp aiplatformpb.PredictionService_StreamRawPredictClient
   458  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   459  		var err error
   460  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamRawPredict")
   461  		resp, err = c.predictionClient.StreamRawPredict(ctx, req, settings.GRPC...)
   462  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamRawPredict")
   463  		return err
   464  	}, opts...)
   465  	if err != nil {
   466  		return nil, err
   467  	}
   468  	return resp, nil
   469  }
   470  
   471  func (c *predictionGRPCClient) DirectPredict(ctx context.Context, req *aiplatformpb.DirectPredictRequest, opts ...gax.CallOption) (*aiplatformpb.DirectPredictResponse, error) {
   472  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   473  
   474  	hds = append(c.xGoogHeaders, hds...)
   475  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   476  	opts = append((*c.CallOptions).DirectPredict[0:len((*c.CallOptions).DirectPredict):len((*c.CallOptions).DirectPredict)], opts...)
   477  	var resp *aiplatformpb.DirectPredictResponse
   478  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   479  		var err error
   480  		resp, err = executeRPC(ctx, c.predictionClient.DirectPredict, req, settings.GRPC, c.logger, "DirectPredict")
   481  		return err
   482  	}, opts...)
   483  	if err != nil {
   484  		return nil, err
   485  	}
   486  	return resp, nil
   487  }
   488  
   489  func (c *predictionGRPCClient) DirectRawPredict(ctx context.Context, req *aiplatformpb.DirectRawPredictRequest, opts ...gax.CallOption) (*aiplatformpb.DirectRawPredictResponse, error) {
   490  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   491  
   492  	hds = append(c.xGoogHeaders, hds...)
   493  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   494  	opts = append((*c.CallOptions).DirectRawPredict[0:len((*c.CallOptions).DirectRawPredict):len((*c.CallOptions).DirectRawPredict)], opts...)
   495  	var resp *aiplatformpb.DirectRawPredictResponse
   496  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   497  		var err error
   498  		resp, err = executeRPC(ctx, c.predictionClient.DirectRawPredict, req, settings.GRPC, c.logger, "DirectRawPredict")
   499  		return err
   500  	}, opts...)
   501  	if err != nil {
   502  		return nil, err
   503  	}
   504  	return resp, nil
   505  }
   506  
   507  func (c *predictionGRPCClient) StreamDirectPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamDirectPredictClient, error) {
   508  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
   509  	var resp aiplatformpb.PredictionService_StreamDirectPredictClient
   510  	opts = append((*c.CallOptions).StreamDirectPredict[0:len((*c.CallOptions).StreamDirectPredict):len((*c.CallOptions).StreamDirectPredict)], opts...)
   511  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   512  		var err error
   513  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamDirectPredict")
   514  		resp, err = c.predictionClient.StreamDirectPredict(ctx, settings.GRPC...)
   515  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamDirectPredict")
   516  		return err
   517  	}, opts...)
   518  	if err != nil {
   519  		return nil, err
   520  	}
   521  	return resp, nil
   522  }
   523  
   524  func (c *predictionGRPCClient) StreamDirectRawPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamDirectRawPredictClient, error) {
   525  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
   526  	var resp aiplatformpb.PredictionService_StreamDirectRawPredictClient
   527  	opts = append((*c.CallOptions).StreamDirectRawPredict[0:len((*c.CallOptions).StreamDirectRawPredict):len((*c.CallOptions).StreamDirectRawPredict)], opts...)
   528  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   529  		var err error
   530  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamDirectRawPredict")
   531  		resp, err = c.predictionClient.StreamDirectRawPredict(ctx, settings.GRPC...)
   532  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamDirectRawPredict")
   533  		return err
   534  	}, opts...)
   535  	if err != nil {
   536  		return nil, err
   537  	}
   538  	return resp, nil
   539  }
   540  
   541  func (c *predictionGRPCClient) StreamingPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamingPredictClient, error) {
   542  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
   543  	var resp aiplatformpb.PredictionService_StreamingPredictClient
   544  	opts = append((*c.CallOptions).StreamingPredict[0:len((*c.CallOptions).StreamingPredict):len((*c.CallOptions).StreamingPredict)], opts...)
   545  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   546  		var err error
   547  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamingPredict")
   548  		resp, err = c.predictionClient.StreamingPredict(ctx, settings.GRPC...)
   549  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamingPredict")
   550  		return err
   551  	}, opts...)
   552  	if err != nil {
   553  		return nil, err
   554  	}
   555  	return resp, nil
   556  }
   557  
   558  func (c *predictionGRPCClient) ServerStreamingPredict(ctx context.Context, req *aiplatformpb.StreamingPredictRequest, opts ...gax.CallOption) (aiplatformpb.PredictionService_ServerStreamingPredictClient, error) {
   559  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   560  
   561  	hds = append(c.xGoogHeaders, hds...)
   562  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   563  	opts = append((*c.CallOptions).ServerStreamingPredict[0:len((*c.CallOptions).ServerStreamingPredict):len((*c.CallOptions).ServerStreamingPredict)], opts...)
   564  	var resp aiplatformpb.PredictionService_ServerStreamingPredictClient
   565  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   566  		var err error
   567  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "ServerStreamingPredict")
   568  		resp, err = c.predictionClient.ServerStreamingPredict(ctx, req, settings.GRPC...)
   569  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "ServerStreamingPredict")
   570  		return err
   571  	}, opts...)
   572  	if err != nil {
   573  		return nil, err
   574  	}
   575  	return resp, nil
   576  }
   577  
   578  func (c *predictionGRPCClient) StreamingRawPredict(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamingRawPredictClient, error) {
   579  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
   580  	var resp aiplatformpb.PredictionService_StreamingRawPredictClient
   581  	opts = append((*c.CallOptions).StreamingRawPredict[0:len((*c.CallOptions).StreamingRawPredict):len((*c.CallOptions).StreamingRawPredict)], opts...)
   582  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   583  		var err error
   584  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamingRawPredict")
   585  		resp, err = c.predictionClient.StreamingRawPredict(ctx, settings.GRPC...)
   586  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamingRawPredict")
   587  		return err
   588  	}, opts...)
   589  	if err != nil {
   590  		return nil, err
   591  	}
   592  	return resp, nil
   593  }
   594  
   595  func (c *predictionGRPCClient) Explain(ctx context.Context, req *aiplatformpb.ExplainRequest, opts ...gax.CallOption) (*aiplatformpb.ExplainResponse, error) {
   596  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "endpoint", url.QueryEscape(req.GetEndpoint()))}
   597  
   598  	hds = append(c.xGoogHeaders, hds...)
   599  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   600  	opts = append((*c.CallOptions).Explain[0:len((*c.CallOptions).Explain):len((*c.CallOptions).Explain)], opts...)
   601  	var resp *aiplatformpb.ExplainResponse
   602  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   603  		var err error
   604  		resp, err = executeRPC(ctx, c.predictionClient.Explain, req, settings.GRPC, c.logger, "Explain")
   605  		return err
   606  	}, opts...)
   607  	if err != nil {
   608  		return nil, err
   609  	}
   610  	return resp, nil
   611  }
   612  
   613  func (c *predictionGRPCClient) GenerateContent(ctx context.Context, req *aiplatformpb.GenerateContentRequest, opts ...gax.CallOption) (*aiplatformpb.GenerateContentResponse, error) {
   614  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model", url.QueryEscape(req.GetModel()))}
   615  
   616  	hds = append(c.xGoogHeaders, hds...)
   617  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   618  	opts = append((*c.CallOptions).GenerateContent[0:len((*c.CallOptions).GenerateContent):len((*c.CallOptions).GenerateContent)], opts...)
   619  	var resp *aiplatformpb.GenerateContentResponse
   620  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   621  		var err error
   622  		resp, err = executeRPC(ctx, c.predictionClient.GenerateContent, req, settings.GRPC, c.logger, "GenerateContent")
   623  		return err
   624  	}, opts...)
   625  	if err != nil {
   626  		return nil, err
   627  	}
   628  	return resp, nil
   629  }
   630  
   631  func (c *predictionGRPCClient) StreamGenerateContent(ctx context.Context, req *aiplatformpb.GenerateContentRequest, opts ...gax.CallOption) (aiplatformpb.PredictionService_StreamGenerateContentClient, error) {
   632  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model", url.QueryEscape(req.GetModel()))}
   633  
   634  	hds = append(c.xGoogHeaders, hds...)
   635  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   636  	opts = append((*c.CallOptions).StreamGenerateContent[0:len((*c.CallOptions).StreamGenerateContent):len((*c.CallOptions).StreamGenerateContent)], opts...)
   637  	var resp aiplatformpb.PredictionService_StreamGenerateContentClient
   638  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   639  		var err error
   640  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamGenerateContent")
   641  		resp, err = c.predictionClient.StreamGenerateContent(ctx, req, settings.GRPC...)
   642  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamGenerateContent")
   643  		return err
   644  	}, opts...)
   645  	if err != nil {
   646  		return nil, err
   647  	}
   648  	return resp, nil
   649  }
   650  
   651  func (c *predictionGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   652  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   653  
   654  	hds = append(c.xGoogHeaders, hds...)
   655  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   656  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
   657  	var resp *locationpb.Location
   658  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   659  		var err error
   660  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
   661  		return err
   662  	}, opts...)
   663  	if err != nil {
   664  		return nil, err
   665  	}
   666  	return resp, nil
   667  }
   668  
   669  func (c *predictionGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   670  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   671  
   672  	hds = append(c.xGoogHeaders, hds...)
   673  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   674  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
   675  	it := &LocationIterator{}
   676  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
   677  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
   678  		resp := &locationpb.ListLocationsResponse{}
   679  		if pageToken != "" {
   680  			req.PageToken = pageToken
   681  		}
   682  		if pageSize > math.MaxInt32 {
   683  			req.PageSize = math.MaxInt32
   684  		} else if pageSize != 0 {
   685  			req.PageSize = int32(pageSize)
   686  		}
   687  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   688  			var err error
   689  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
   690  			return err
   691  		}, opts...)
   692  		if err != nil {
   693  			return nil, "", err
   694  		}
   695  
   696  		it.Response = resp
   697  		return resp.GetLocations(), resp.GetNextPageToken(), nil
   698  	}
   699  	fetch := func(pageSize int, pageToken string) (string, error) {
   700  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   701  		if err != nil {
   702  			return "", err
   703  		}
   704  		it.items = append(it.items, items...)
   705  		return nextPageToken, nil
   706  	}
   707  
   708  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   709  	it.pageInfo.MaxSize = int(req.GetPageSize())
   710  	it.pageInfo.Token = req.GetPageToken()
   711  
   712  	return it
   713  }
   714  
   715  func (c *predictionGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   716  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   717  
   718  	hds = append(c.xGoogHeaders, hds...)
   719  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   720  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
   721  	var resp *iampb.Policy
   722  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   723  		var err error
   724  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
   725  		return err
   726  	}, opts...)
   727  	if err != nil {
   728  		return nil, err
   729  	}
   730  	return resp, nil
   731  }
   732  
   733  func (c *predictionGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   734  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   735  
   736  	hds = append(c.xGoogHeaders, hds...)
   737  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   738  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
   739  	var resp *iampb.Policy
   740  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   741  		var err error
   742  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
   743  		return err
   744  	}, opts...)
   745  	if err != nil {
   746  		return nil, err
   747  	}
   748  	return resp, nil
   749  }
   750  
   751  func (c *predictionGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   752  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   753  
   754  	hds = append(c.xGoogHeaders, hds...)
   755  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   756  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
   757  	var resp *iampb.TestIamPermissionsResponse
   758  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   759  		var err error
   760  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
   761  		return err
   762  	}, opts...)
   763  	if err != nil {
   764  		return nil, err
   765  	}
   766  	return resp, nil
   767  }
   768  
   769  func (c *predictionGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   770  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   771  
   772  	hds = append(c.xGoogHeaders, hds...)
   773  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   774  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
   775  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   776  		var err error
   777  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
   778  		return err
   779  	}, opts...)
   780  	return err
   781  }
   782  
   783  func (c *predictionGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   784  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   785  
   786  	hds = append(c.xGoogHeaders, hds...)
   787  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   788  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
   789  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   790  		var err error
   791  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
   792  		return err
   793  	}, opts...)
   794  	return err
   795  }
   796  
   797  func (c *predictionGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   798  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   799  
   800  	hds = append(c.xGoogHeaders, hds...)
   801  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   802  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
   803  	var resp *longrunningpb.Operation
   804  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   805  		var err error
   806  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
   807  		return err
   808  	}, opts...)
   809  	if err != nil {
   810  		return nil, err
   811  	}
   812  	return resp, nil
   813  }
   814  
   815  func (c *predictionGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   816  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   817  
   818  	hds = append(c.xGoogHeaders, hds...)
   819  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   820  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
   821  	it := &OperationIterator{}
   822  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
   823  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
   824  		resp := &longrunningpb.ListOperationsResponse{}
   825  		if pageToken != "" {
   826  			req.PageToken = pageToken
   827  		}
   828  		if pageSize > math.MaxInt32 {
   829  			req.PageSize = math.MaxInt32
   830  		} else if pageSize != 0 {
   831  			req.PageSize = int32(pageSize)
   832  		}
   833  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   834  			var err error
   835  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
   836  			return err
   837  		}, opts...)
   838  		if err != nil {
   839  			return nil, "", err
   840  		}
   841  
   842  		it.Response = resp
   843  		return resp.GetOperations(), resp.GetNextPageToken(), nil
   844  	}
   845  	fetch := func(pageSize int, pageToken string) (string, error) {
   846  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   847  		if err != nil {
   848  			return "", err
   849  		}
   850  		it.items = append(it.items, items...)
   851  		return nextPageToken, nil
   852  	}
   853  
   854  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   855  	it.pageInfo.MaxSize = int(req.GetPageSize())
   856  	it.pageInfo.Token = req.GetPageToken()
   857  
   858  	return it
   859  }
   860  
   861  func (c *predictionGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   862  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   863  
   864  	hds = append(c.xGoogHeaders, hds...)
   865  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   866  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
   867  	var resp *longrunningpb.Operation
   868  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   869  		var err error
   870  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
   871  		return err
   872  	}, opts...)
   873  	if err != nil {
   874  		return nil, err
   875  	}
   876  	return resp, nil
   877  }