cloud.google.com/go/aiplatform@v1.106.0/apiv1/model_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  	"cloud.google.com/go/longrunning"
    29  	lroauto "cloud.google.com/go/longrunning/autogen"
    30  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    31  	gax "github.com/googleapis/gax-go/v2"
    32  	"google.golang.org/api/iterator"
    33  	"google.golang.org/api/option"
    34  	"google.golang.org/api/option/internaloption"
    35  	gtransport "google.golang.org/api/transport/grpc"
    36  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    37  	"google.golang.org/grpc"
    38  	"google.golang.org/protobuf/proto"
    39  )
    40  
    41  var newModelClientHook clientHook
    42  
    43  // ModelCallOptions contains the retry settings for each method of ModelClient.
    44  type ModelCallOptions struct {
    45  	UploadModel                      []gax.CallOption
    46  	GetModel                         []gax.CallOption
    47  	ListModels                       []gax.CallOption
    48  	ListModelVersions                []gax.CallOption
    49  	ListModelVersionCheckpoints      []gax.CallOption
    50  	UpdateModel                      []gax.CallOption
    51  	UpdateExplanationDataset         []gax.CallOption
    52  	DeleteModel                      []gax.CallOption
    53  	DeleteModelVersion               []gax.CallOption
    54  	MergeVersionAliases              []gax.CallOption
    55  	ExportModel                      []gax.CallOption
    56  	CopyModel                        []gax.CallOption
    57  	ImportModelEvaluation            []gax.CallOption
    58  	BatchImportModelEvaluationSlices []gax.CallOption
    59  	BatchImportEvaluatedAnnotations  []gax.CallOption
    60  	GetModelEvaluation               []gax.CallOption
    61  	ListModelEvaluations             []gax.CallOption
    62  	GetModelEvaluationSlice          []gax.CallOption
    63  	ListModelEvaluationSlices        []gax.CallOption
    64  	GetLocation                      []gax.CallOption
    65  	ListLocations                    []gax.CallOption
    66  	GetIamPolicy                     []gax.CallOption
    67  	SetIamPolicy                     []gax.CallOption
    68  	TestIamPermissions               []gax.CallOption
    69  	CancelOperation                  []gax.CallOption
    70  	DeleteOperation                  []gax.CallOption
    71  	GetOperation                     []gax.CallOption
    72  	ListOperations                   []gax.CallOption
    73  	WaitOperation                    []gax.CallOption
    74  }
    75  
    76  func defaultModelGRPCClientOptions() []option.ClientOption {
    77  	return []option.ClientOption{
    78  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    79  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    80  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    81  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    82  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    83  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    84  		internaloption.EnableJwtWithScope(),
    85  		internaloption.EnableNewAuthLibrary(),
    86  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    87  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    88  	}
    89  }
    90  
    91  func defaultModelCallOptions() *ModelCallOptions {
    92  	return &ModelCallOptions{
    93  		UploadModel:                      []gax.CallOption{},
    94  		GetModel:                         []gax.CallOption{},
    95  		ListModels:                       []gax.CallOption{},
    96  		ListModelVersions:                []gax.CallOption{},
    97  		ListModelVersionCheckpoints:      []gax.CallOption{},
    98  		UpdateModel:                      []gax.CallOption{},
    99  		UpdateExplanationDataset:         []gax.CallOption{},
   100  		DeleteModel:                      []gax.CallOption{},
   101  		DeleteModelVersion:               []gax.CallOption{},
   102  		MergeVersionAliases:              []gax.CallOption{},
   103  		ExportModel:                      []gax.CallOption{},
   104  		CopyModel:                        []gax.CallOption{},
   105  		ImportModelEvaluation:            []gax.CallOption{},
   106  		BatchImportModelEvaluationSlices: []gax.CallOption{},
   107  		BatchImportEvaluatedAnnotations:  []gax.CallOption{},
   108  		GetModelEvaluation:               []gax.CallOption{},
   109  		ListModelEvaluations:             []gax.CallOption{},
   110  		GetModelEvaluationSlice:          []gax.CallOption{},
   111  		ListModelEvaluationSlices:        []gax.CallOption{},
   112  		GetLocation:                      []gax.CallOption{},
   113  		ListLocations:                    []gax.CallOption{},
   114  		GetIamPolicy:                     []gax.CallOption{},
   115  		SetIamPolicy:                     []gax.CallOption{},
   116  		TestIamPermissions:               []gax.CallOption{},
   117  		CancelOperation:                  []gax.CallOption{},
   118  		DeleteOperation:                  []gax.CallOption{},
   119  		GetOperation:                     []gax.CallOption{},
   120  		ListOperations:                   []gax.CallOption{},
   121  		WaitOperation:                    []gax.CallOption{},
   122  	}
   123  }
   124  
   125  // internalModelClient is an interface that defines the methods available from Vertex AI API.
   126  type internalModelClient interface {
   127  	Close() error
   128  	setGoogleClientInfo(...string)
   129  	Connection() *grpc.ClientConn
   130  	UploadModel(context.Context, *aiplatformpb.UploadModelRequest, ...gax.CallOption) (*UploadModelOperation, error)
   131  	UploadModelOperation(name string) *UploadModelOperation
   132  	GetModel(context.Context, *aiplatformpb.GetModelRequest, ...gax.CallOption) (*aiplatformpb.Model, error)
   133  	ListModels(context.Context, *aiplatformpb.ListModelsRequest, ...gax.CallOption) *ModelIterator
   134  	ListModelVersions(context.Context, *aiplatformpb.ListModelVersionsRequest, ...gax.CallOption) *ModelIterator
   135  	ListModelVersionCheckpoints(context.Context, *aiplatformpb.ListModelVersionCheckpointsRequest, ...gax.CallOption) *ModelVersionCheckpointIterator
   136  	UpdateModel(context.Context, *aiplatformpb.UpdateModelRequest, ...gax.CallOption) (*aiplatformpb.Model, error)
   137  	UpdateExplanationDataset(context.Context, *aiplatformpb.UpdateExplanationDatasetRequest, ...gax.CallOption) (*UpdateExplanationDatasetOperation, error)
   138  	UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation
   139  	DeleteModel(context.Context, *aiplatformpb.DeleteModelRequest, ...gax.CallOption) (*DeleteModelOperation, error)
   140  	DeleteModelOperation(name string) *DeleteModelOperation
   141  	DeleteModelVersion(context.Context, *aiplatformpb.DeleteModelVersionRequest, ...gax.CallOption) (*DeleteModelVersionOperation, error)
   142  	DeleteModelVersionOperation(name string) *DeleteModelVersionOperation
   143  	MergeVersionAliases(context.Context, *aiplatformpb.MergeVersionAliasesRequest, ...gax.CallOption) (*aiplatformpb.Model, error)
   144  	ExportModel(context.Context, *aiplatformpb.ExportModelRequest, ...gax.CallOption) (*ExportModelOperation, error)
   145  	ExportModelOperation(name string) *ExportModelOperation
   146  	CopyModel(context.Context, *aiplatformpb.CopyModelRequest, ...gax.CallOption) (*CopyModelOperation, error)
   147  	CopyModelOperation(name string) *CopyModelOperation
   148  	ImportModelEvaluation(context.Context, *aiplatformpb.ImportModelEvaluationRequest, ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error)
   149  	BatchImportModelEvaluationSlices(context.Context, *aiplatformpb.BatchImportModelEvaluationSlicesRequest, ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error)
   150  	BatchImportEvaluatedAnnotations(context.Context, *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error)
   151  	GetModelEvaluation(context.Context, *aiplatformpb.GetModelEvaluationRequest, ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error)
   152  	ListModelEvaluations(context.Context, *aiplatformpb.ListModelEvaluationsRequest, ...gax.CallOption) *ModelEvaluationIterator
   153  	GetModelEvaluationSlice(context.Context, *aiplatformpb.GetModelEvaluationSliceRequest, ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error)
   154  	ListModelEvaluationSlices(context.Context, *aiplatformpb.ListModelEvaluationSlicesRequest, ...gax.CallOption) *ModelEvaluationSliceIterator
   155  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   156  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   157  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   158  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   159  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   160  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   161  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   162  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   163  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   164  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   165  }
   166  
   167  // ModelClient is a client for interacting with Vertex AI API.
   168  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   169  //
   170  // A service for managing Vertex AI’s machine learning Models.
   171  type ModelClient struct {
   172  	// The internal transport-dependent client.
   173  	internalClient internalModelClient
   174  
   175  	// The call options for this service.
   176  	CallOptions *ModelCallOptions
   177  
   178  	// LROClient is used internally to handle long-running operations.
   179  	// It is exposed so that its CallOptions can be modified if required.
   180  	// Users should not Close this client.
   181  	LROClient *lroauto.OperationsClient
   182  }
   183  
   184  // Wrapper methods routed to the internal client.
   185  
   186  // Close closes the connection to the API service. The user should invoke this when
   187  // the client is no longer required.
   188  func (c *ModelClient) Close() error {
   189  	return c.internalClient.Close()
   190  }
   191  
   192  // setGoogleClientInfo sets the name and version of the application in
   193  // the `x-goog-api-client` header passed on each request. Intended for
   194  // use by Google-written clients.
   195  func (c *ModelClient) setGoogleClientInfo(keyval ...string) {
   196  	c.internalClient.setGoogleClientInfo(keyval...)
   197  }
   198  
   199  // Connection returns a connection to the API service.
   200  //
   201  // Deprecated: Connections are now pooled so this method does not always
   202  // return the same resource.
   203  func (c *ModelClient) Connection() *grpc.ClientConn {
   204  	return c.internalClient.Connection()
   205  }
   206  
   207  // UploadModel uploads a Model artifact into Vertex AI.
   208  func (c *ModelClient) UploadModel(ctx context.Context, req *aiplatformpb.UploadModelRequest, opts ...gax.CallOption) (*UploadModelOperation, error) {
   209  	return c.internalClient.UploadModel(ctx, req, opts...)
   210  }
   211  
   212  // UploadModelOperation returns a new UploadModelOperation from a given name.
   213  // The name must be that of a previously created UploadModelOperation, possibly from a different process.
   214  func (c *ModelClient) UploadModelOperation(name string) *UploadModelOperation {
   215  	return c.internalClient.UploadModelOperation(name)
   216  }
   217  
   218  // GetModel gets a Model.
   219  func (c *ModelClient) GetModel(ctx context.Context, req *aiplatformpb.GetModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   220  	return c.internalClient.GetModel(ctx, req, opts...)
   221  }
   222  
   223  // ListModels lists Models in a Location.
   224  func (c *ModelClient) ListModels(ctx context.Context, req *aiplatformpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
   225  	return c.internalClient.ListModels(ctx, req, opts...)
   226  }
   227  
   228  // ListModelVersions lists versions of the specified model.
   229  func (c *ModelClient) ListModelVersions(ctx context.Context, req *aiplatformpb.ListModelVersionsRequest, opts ...gax.CallOption) *ModelIterator {
   230  	return c.internalClient.ListModelVersions(ctx, req, opts...)
   231  }
   232  
   233  // ListModelVersionCheckpoints lists checkpoints of the specified model version.
   234  func (c *ModelClient) ListModelVersionCheckpoints(ctx context.Context, req *aiplatformpb.ListModelVersionCheckpointsRequest, opts ...gax.CallOption) *ModelVersionCheckpointIterator {
   235  	return c.internalClient.ListModelVersionCheckpoints(ctx, req, opts...)
   236  }
   237  
   238  // UpdateModel updates a Model.
   239  func (c *ModelClient) UpdateModel(ctx context.Context, req *aiplatformpb.UpdateModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   240  	return c.internalClient.UpdateModel(ctx, req, opts...)
   241  }
   242  
   243  // UpdateExplanationDataset incrementally update the dataset used for an examples model.
   244  func (c *ModelClient) UpdateExplanationDataset(ctx context.Context, req *aiplatformpb.UpdateExplanationDatasetRequest, opts ...gax.CallOption) (*UpdateExplanationDatasetOperation, error) {
   245  	return c.internalClient.UpdateExplanationDataset(ctx, req, opts...)
   246  }
   247  
   248  // UpdateExplanationDatasetOperation returns a new UpdateExplanationDatasetOperation from a given name.
   249  // The name must be that of a previously created UpdateExplanationDatasetOperation, possibly from a different process.
   250  func (c *ModelClient) UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation {
   251  	return c.internalClient.UpdateExplanationDatasetOperation(name)
   252  }
   253  
   254  // DeleteModel deletes a Model.
   255  //
   256  // A model cannot be deleted if any
   257  // Endpoint resource has a
   258  // DeployedModel based on the
   259  // model in its
   260  // deployed_models
   261  // field.
   262  func (c *ModelClient) DeleteModel(ctx context.Context, req *aiplatformpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
   263  	return c.internalClient.DeleteModel(ctx, req, opts...)
   264  }
   265  
   266  // DeleteModelOperation returns a new DeleteModelOperation from a given name.
   267  // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
   268  func (c *ModelClient) DeleteModelOperation(name string) *DeleteModelOperation {
   269  	return c.internalClient.DeleteModelOperation(name)
   270  }
   271  
   272  // DeleteModelVersion deletes a Model version.
   273  //
   274  // Model version can only be deleted if there are no
   275  // DeployedModels created from it.
   276  // Deleting the only version in the Model is not allowed. Use
   277  // DeleteModel for
   278  // deleting the Model instead.
   279  func (c *ModelClient) DeleteModelVersion(ctx context.Context, req *aiplatformpb.DeleteModelVersionRequest, opts ...gax.CallOption) (*DeleteModelVersionOperation, error) {
   280  	return c.internalClient.DeleteModelVersion(ctx, req, opts...)
   281  }
   282  
   283  // DeleteModelVersionOperation returns a new DeleteModelVersionOperation from a given name.
   284  // The name must be that of a previously created DeleteModelVersionOperation, possibly from a different process.
   285  func (c *ModelClient) DeleteModelVersionOperation(name string) *DeleteModelVersionOperation {
   286  	return c.internalClient.DeleteModelVersionOperation(name)
   287  }
   288  
   289  // MergeVersionAliases merges a set of aliases for a Model version.
   290  func (c *ModelClient) MergeVersionAliases(ctx context.Context, req *aiplatformpb.MergeVersionAliasesRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   291  	return c.internalClient.MergeVersionAliases(ctx, req, opts...)
   292  }
   293  
   294  // ExportModel exports a trained, exportable Model to a location specified by the
   295  // user. A Model is considered to be exportable if it has at least one
   296  // [supported export
   297  // format][google.cloud.aiplatform.v1.Model.supported_export_formats].
   298  func (c *ModelClient) ExportModel(ctx context.Context, req *aiplatformpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
   299  	return c.internalClient.ExportModel(ctx, req, opts...)
   300  }
   301  
   302  // ExportModelOperation returns a new ExportModelOperation from a given name.
   303  // The name must be that of a previously created ExportModelOperation, possibly from a different process.
   304  func (c *ModelClient) ExportModelOperation(name string) *ExportModelOperation {
   305  	return c.internalClient.ExportModelOperation(name)
   306  }
   307  
   308  // CopyModel copies an already existing Vertex AI Model into the specified Location.
   309  // The source Model must exist in the same Project.
   310  // When copying custom Models, the users themselves are responsible for
   311  // Model.metadata content to be
   312  // region-agnostic, as well as making sure that any resources (e.g. files) it
   313  // depends on remain accessible.
   314  func (c *ModelClient) CopyModel(ctx context.Context, req *aiplatformpb.CopyModelRequest, opts ...gax.CallOption) (*CopyModelOperation, error) {
   315  	return c.internalClient.CopyModel(ctx, req, opts...)
   316  }
   317  
   318  // CopyModelOperation returns a new CopyModelOperation from a given name.
   319  // The name must be that of a previously created CopyModelOperation, possibly from a different process.
   320  func (c *ModelClient) CopyModelOperation(name string) *CopyModelOperation {
   321  	return c.internalClient.CopyModelOperation(name)
   322  }
   323  
   324  // ImportModelEvaluation imports an externally generated ModelEvaluation.
   325  func (c *ModelClient) ImportModelEvaluation(ctx context.Context, req *aiplatformpb.ImportModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
   326  	return c.internalClient.ImportModelEvaluation(ctx, req, opts...)
   327  }
   328  
   329  // BatchImportModelEvaluationSlices imports a list of externally generated ModelEvaluationSlice.
   330  func (c *ModelClient) BatchImportModelEvaluationSlices(ctx context.Context, req *aiplatformpb.BatchImportModelEvaluationSlicesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error) {
   331  	return c.internalClient.BatchImportModelEvaluationSlices(ctx, req, opts...)
   332  }
   333  
   334  // BatchImportEvaluatedAnnotations imports a list of externally generated EvaluatedAnnotations.
   335  func (c *ModelClient) BatchImportEvaluatedAnnotations(ctx context.Context, req *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error) {
   336  	return c.internalClient.BatchImportEvaluatedAnnotations(ctx, req, opts...)
   337  }
   338  
   339  // GetModelEvaluation gets a ModelEvaluation.
   340  func (c *ModelClient) GetModelEvaluation(ctx context.Context, req *aiplatformpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
   341  	return c.internalClient.GetModelEvaluation(ctx, req, opts...)
   342  }
   343  
   344  // ListModelEvaluations lists ModelEvaluations in a Model.
   345  func (c *ModelClient) ListModelEvaluations(ctx context.Context, req *aiplatformpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
   346  	return c.internalClient.ListModelEvaluations(ctx, req, opts...)
   347  }
   348  
   349  // GetModelEvaluationSlice gets a ModelEvaluationSlice.
   350  func (c *ModelClient) GetModelEvaluationSlice(ctx context.Context, req *aiplatformpb.GetModelEvaluationSliceRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error) {
   351  	return c.internalClient.GetModelEvaluationSlice(ctx, req, opts...)
   352  }
   353  
   354  // ListModelEvaluationSlices lists ModelEvaluationSlices in a ModelEvaluation.
   355  func (c *ModelClient) ListModelEvaluationSlices(ctx context.Context, req *aiplatformpb.ListModelEvaluationSlicesRequest, opts ...gax.CallOption) *ModelEvaluationSliceIterator {
   356  	return c.internalClient.ListModelEvaluationSlices(ctx, req, opts...)
   357  }
   358  
   359  // GetLocation gets information about a location.
   360  func (c *ModelClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   361  	return c.internalClient.GetLocation(ctx, req, opts...)
   362  }
   363  
   364  // ListLocations lists information about the supported locations for this service.
   365  func (c *ModelClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   366  	return c.internalClient.ListLocations(ctx, req, opts...)
   367  }
   368  
   369  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   370  // if the resource exists and does not have a policy set.
   371  func (c *ModelClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   372  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   373  }
   374  
   375  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   376  // any existing policy.
   377  //
   378  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   379  // errors.
   380  func (c *ModelClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   381  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   382  }
   383  
   384  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   385  // resource does not exist, this will return an empty set of
   386  // permissions, not a NOT_FOUND error.
   387  //
   388  // Note: This operation is designed to be used for building
   389  // permission-aware UIs and command-line tools, not for authorization
   390  // checking. This operation may “fail open” without warning.
   391  func (c *ModelClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   392  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   393  }
   394  
   395  // CancelOperation is a utility method from google.longrunning.Operations.
   396  func (c *ModelClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   397  	return c.internalClient.CancelOperation(ctx, req, opts...)
   398  }
   399  
   400  // DeleteOperation is a utility method from google.longrunning.Operations.
   401  func (c *ModelClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   402  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   403  }
   404  
   405  // GetOperation is a utility method from google.longrunning.Operations.
   406  func (c *ModelClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   407  	return c.internalClient.GetOperation(ctx, req, opts...)
   408  }
   409  
   410  // ListOperations is a utility method from google.longrunning.Operations.
   411  func (c *ModelClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   412  	return c.internalClient.ListOperations(ctx, req, opts...)
   413  }
   414  
   415  // WaitOperation is a utility method from google.longrunning.Operations.
   416  func (c *ModelClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   417  	return c.internalClient.WaitOperation(ctx, req, opts...)
   418  }
   419  
   420  // modelGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   421  //
   422  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   423  type modelGRPCClient struct {
   424  	// Connection pool of gRPC connections to the service.
   425  	connPool gtransport.ConnPool
   426  
   427  	// Points back to the CallOptions field of the containing ModelClient
   428  	CallOptions **ModelCallOptions
   429  
   430  	// The gRPC API client.
   431  	modelClient aiplatformpb.ModelServiceClient
   432  
   433  	// LROClient is used internally to handle long-running operations.
   434  	// It is exposed so that its CallOptions can be modified if required.
   435  	// Users should not Close this client.
   436  	LROClient **lroauto.OperationsClient
   437  
   438  	operationsClient longrunningpb.OperationsClient
   439  
   440  	iamPolicyClient iampb.IAMPolicyClient
   441  
   442  	locationsClient locationpb.LocationsClient
   443  
   444  	// The x-goog-* metadata to be sent with each request.
   445  	xGoogHeaders []string
   446  
   447  	logger *slog.Logger
   448  }
   449  
   450  // NewModelClient creates a new model service client based on gRPC.
   451  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   452  //
   453  // A service for managing Vertex AI’s machine learning Models.
   454  func NewModelClient(ctx context.Context, opts ...option.ClientOption) (*ModelClient, error) {
   455  	clientOpts := defaultModelGRPCClientOptions()
   456  	if newModelClientHook != nil {
   457  		hookOpts, err := newModelClientHook(ctx, clientHookParams{})
   458  		if err != nil {
   459  			return nil, err
   460  		}
   461  		clientOpts = append(clientOpts, hookOpts...)
   462  	}
   463  
   464  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   465  	if err != nil {
   466  		return nil, err
   467  	}
   468  	client := ModelClient{CallOptions: defaultModelCallOptions()}
   469  
   470  	c := &modelGRPCClient{
   471  		connPool:         connPool,
   472  		modelClient:      aiplatformpb.NewModelServiceClient(connPool),
   473  		CallOptions:      &client.CallOptions,
   474  		logger:           internaloption.GetLogger(opts),
   475  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   476  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   477  		locationsClient:  locationpb.NewLocationsClient(connPool),
   478  	}
   479  	c.setGoogleClientInfo()
   480  
   481  	client.internalClient = c
   482  
   483  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   484  	if err != nil {
   485  		// This error "should not happen", since we are just reusing old connection pool
   486  		// and never actually need to dial.
   487  		// If this does happen, we could leak connp. However, we cannot close conn:
   488  		// If the user invoked the constructor with option.WithGRPCConn,
   489  		// we would close a connection that's still in use.
   490  		// TODO: investigate error conditions.
   491  		return nil, err
   492  	}
   493  	c.LROClient = &client.LROClient
   494  	return &client, nil
   495  }
   496  
   497  // Connection returns a connection to the API service.
   498  //
   499  // Deprecated: Connections are now pooled so this method does not always
   500  // return the same resource.
   501  func (c *modelGRPCClient) Connection() *grpc.ClientConn {
   502  	return c.connPool.Conn()
   503  }
   504  
   505  // setGoogleClientInfo sets the name and version of the application in
   506  // the `x-goog-api-client` header passed on each request. Intended for
   507  // use by Google-written clients.
   508  func (c *modelGRPCClient) setGoogleClientInfo(keyval ...string) {
   509  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   510  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   511  	c.xGoogHeaders = []string{
   512  		"x-goog-api-client", gax.XGoogHeader(kv...),
   513  	}
   514  }
   515  
   516  // Close closes the connection to the API service. The user should invoke this when
   517  // the client is no longer required.
   518  func (c *modelGRPCClient) Close() error {
   519  	return c.connPool.Close()
   520  }
   521  
   522  func (c *modelGRPCClient) UploadModel(ctx context.Context, req *aiplatformpb.UploadModelRequest, opts ...gax.CallOption) (*UploadModelOperation, error) {
   523  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   524  
   525  	hds = append(c.xGoogHeaders, hds...)
   526  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   527  	opts = append((*c.CallOptions).UploadModel[0:len((*c.CallOptions).UploadModel):len((*c.CallOptions).UploadModel)], opts...)
   528  	var resp *longrunningpb.Operation
   529  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   530  		var err error
   531  		resp, err = executeRPC(ctx, c.modelClient.UploadModel, req, settings.GRPC, c.logger, "UploadModel")
   532  		return err
   533  	}, opts...)
   534  	if err != nil {
   535  		return nil, err
   536  	}
   537  	return &UploadModelOperation{
   538  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   539  	}, nil
   540  }
   541  
   542  func (c *modelGRPCClient) GetModel(ctx context.Context, req *aiplatformpb.GetModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   543  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   544  
   545  	hds = append(c.xGoogHeaders, hds...)
   546  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   547  	opts = append((*c.CallOptions).GetModel[0:len((*c.CallOptions).GetModel):len((*c.CallOptions).GetModel)], opts...)
   548  	var resp *aiplatformpb.Model
   549  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   550  		var err error
   551  		resp, err = executeRPC(ctx, c.modelClient.GetModel, req, settings.GRPC, c.logger, "GetModel")
   552  		return err
   553  	}, opts...)
   554  	if err != nil {
   555  		return nil, err
   556  	}
   557  	return resp, nil
   558  }
   559  
   560  func (c *modelGRPCClient) ListModels(ctx context.Context, req *aiplatformpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
   561  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   562  
   563  	hds = append(c.xGoogHeaders, hds...)
   564  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   565  	opts = append((*c.CallOptions).ListModels[0:len((*c.CallOptions).ListModels):len((*c.CallOptions).ListModels)], opts...)
   566  	it := &ModelIterator{}
   567  	req = proto.Clone(req).(*aiplatformpb.ListModelsRequest)
   568  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Model, string, error) {
   569  		resp := &aiplatformpb.ListModelsResponse{}
   570  		if pageToken != "" {
   571  			req.PageToken = pageToken
   572  		}
   573  		if pageSize > math.MaxInt32 {
   574  			req.PageSize = math.MaxInt32
   575  		} else if pageSize != 0 {
   576  			req.PageSize = int32(pageSize)
   577  		}
   578  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   579  			var err error
   580  			resp, err = executeRPC(ctx, c.modelClient.ListModels, req, settings.GRPC, c.logger, "ListModels")
   581  			return err
   582  		}, opts...)
   583  		if err != nil {
   584  			return nil, "", err
   585  		}
   586  
   587  		it.Response = resp
   588  		return resp.GetModels(), resp.GetNextPageToken(), nil
   589  	}
   590  	fetch := func(pageSize int, pageToken string) (string, error) {
   591  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   592  		if err != nil {
   593  			return "", err
   594  		}
   595  		it.items = append(it.items, items...)
   596  		return nextPageToken, nil
   597  	}
   598  
   599  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   600  	it.pageInfo.MaxSize = int(req.GetPageSize())
   601  	it.pageInfo.Token = req.GetPageToken()
   602  
   603  	return it
   604  }
   605  
   606  func (c *modelGRPCClient) ListModelVersions(ctx context.Context, req *aiplatformpb.ListModelVersionsRequest, opts ...gax.CallOption) *ModelIterator {
   607  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   608  
   609  	hds = append(c.xGoogHeaders, hds...)
   610  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   611  	opts = append((*c.CallOptions).ListModelVersions[0:len((*c.CallOptions).ListModelVersions):len((*c.CallOptions).ListModelVersions)], opts...)
   612  	it := &ModelIterator{}
   613  	req = proto.Clone(req).(*aiplatformpb.ListModelVersionsRequest)
   614  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Model, string, error) {
   615  		resp := &aiplatformpb.ListModelVersionsResponse{}
   616  		if pageToken != "" {
   617  			req.PageToken = pageToken
   618  		}
   619  		if pageSize > math.MaxInt32 {
   620  			req.PageSize = math.MaxInt32
   621  		} else if pageSize != 0 {
   622  			req.PageSize = int32(pageSize)
   623  		}
   624  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   625  			var err error
   626  			resp, err = executeRPC(ctx, c.modelClient.ListModelVersions, req, settings.GRPC, c.logger, "ListModelVersions")
   627  			return err
   628  		}, opts...)
   629  		if err != nil {
   630  			return nil, "", err
   631  		}
   632  
   633  		it.Response = resp
   634  		return resp.GetModels(), resp.GetNextPageToken(), nil
   635  	}
   636  	fetch := func(pageSize int, pageToken string) (string, error) {
   637  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   638  		if err != nil {
   639  			return "", err
   640  		}
   641  		it.items = append(it.items, items...)
   642  		return nextPageToken, nil
   643  	}
   644  
   645  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   646  	it.pageInfo.MaxSize = int(req.GetPageSize())
   647  	it.pageInfo.Token = req.GetPageToken()
   648  
   649  	return it
   650  }
   651  
   652  func (c *modelGRPCClient) ListModelVersionCheckpoints(ctx context.Context, req *aiplatformpb.ListModelVersionCheckpointsRequest, opts ...gax.CallOption) *ModelVersionCheckpointIterator {
   653  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   654  
   655  	hds = append(c.xGoogHeaders, hds...)
   656  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   657  	opts = append((*c.CallOptions).ListModelVersionCheckpoints[0:len((*c.CallOptions).ListModelVersionCheckpoints):len((*c.CallOptions).ListModelVersionCheckpoints)], opts...)
   658  	it := &ModelVersionCheckpointIterator{}
   659  	req = proto.Clone(req).(*aiplatformpb.ListModelVersionCheckpointsRequest)
   660  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelVersionCheckpoint, string, error) {
   661  		resp := &aiplatformpb.ListModelVersionCheckpointsResponse{}
   662  		if pageToken != "" {
   663  			req.PageToken = pageToken
   664  		}
   665  		if pageSize > math.MaxInt32 {
   666  			req.PageSize = math.MaxInt32
   667  		} else if pageSize != 0 {
   668  			req.PageSize = int32(pageSize)
   669  		}
   670  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   671  			var err error
   672  			resp, err = executeRPC(ctx, c.modelClient.ListModelVersionCheckpoints, req, settings.GRPC, c.logger, "ListModelVersionCheckpoints")
   673  			return err
   674  		}, opts...)
   675  		if err != nil {
   676  			return nil, "", err
   677  		}
   678  
   679  		it.Response = resp
   680  		return resp.GetCheckpoints(), resp.GetNextPageToken(), nil
   681  	}
   682  	fetch := func(pageSize int, pageToken string) (string, error) {
   683  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   684  		if err != nil {
   685  			return "", err
   686  		}
   687  		it.items = append(it.items, items...)
   688  		return nextPageToken, nil
   689  	}
   690  
   691  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   692  	it.pageInfo.MaxSize = int(req.GetPageSize())
   693  	it.pageInfo.Token = req.GetPageToken()
   694  
   695  	return it
   696  }
   697  
   698  func (c *modelGRPCClient) UpdateModel(ctx context.Context, req *aiplatformpb.UpdateModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   699  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model.name", url.QueryEscape(req.GetModel().GetName()))}
   700  
   701  	hds = append(c.xGoogHeaders, hds...)
   702  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   703  	opts = append((*c.CallOptions).UpdateModel[0:len((*c.CallOptions).UpdateModel):len((*c.CallOptions).UpdateModel)], opts...)
   704  	var resp *aiplatformpb.Model
   705  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   706  		var err error
   707  		resp, err = executeRPC(ctx, c.modelClient.UpdateModel, req, settings.GRPC, c.logger, "UpdateModel")
   708  		return err
   709  	}, opts...)
   710  	if err != nil {
   711  		return nil, err
   712  	}
   713  	return resp, nil
   714  }
   715  
   716  func (c *modelGRPCClient) UpdateExplanationDataset(ctx context.Context, req *aiplatformpb.UpdateExplanationDatasetRequest, opts ...gax.CallOption) (*UpdateExplanationDatasetOperation, error) {
   717  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model", url.QueryEscape(req.GetModel()))}
   718  
   719  	hds = append(c.xGoogHeaders, hds...)
   720  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   721  	opts = append((*c.CallOptions).UpdateExplanationDataset[0:len((*c.CallOptions).UpdateExplanationDataset):len((*c.CallOptions).UpdateExplanationDataset)], opts...)
   722  	var resp *longrunningpb.Operation
   723  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   724  		var err error
   725  		resp, err = executeRPC(ctx, c.modelClient.UpdateExplanationDataset, req, settings.GRPC, c.logger, "UpdateExplanationDataset")
   726  		return err
   727  	}, opts...)
   728  	if err != nil {
   729  		return nil, err
   730  	}
   731  	return &UpdateExplanationDatasetOperation{
   732  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   733  	}, nil
   734  }
   735  
   736  func (c *modelGRPCClient) DeleteModel(ctx context.Context, req *aiplatformpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
   737  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   738  
   739  	hds = append(c.xGoogHeaders, hds...)
   740  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   741  	opts = append((*c.CallOptions).DeleteModel[0:len((*c.CallOptions).DeleteModel):len((*c.CallOptions).DeleteModel)], opts...)
   742  	var resp *longrunningpb.Operation
   743  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   744  		var err error
   745  		resp, err = executeRPC(ctx, c.modelClient.DeleteModel, req, settings.GRPC, c.logger, "DeleteModel")
   746  		return err
   747  	}, opts...)
   748  	if err != nil {
   749  		return nil, err
   750  	}
   751  	return &DeleteModelOperation{
   752  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   753  	}, nil
   754  }
   755  
   756  func (c *modelGRPCClient) DeleteModelVersion(ctx context.Context, req *aiplatformpb.DeleteModelVersionRequest, opts ...gax.CallOption) (*DeleteModelVersionOperation, error) {
   757  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   758  
   759  	hds = append(c.xGoogHeaders, hds...)
   760  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   761  	opts = append((*c.CallOptions).DeleteModelVersion[0:len((*c.CallOptions).DeleteModelVersion):len((*c.CallOptions).DeleteModelVersion)], opts...)
   762  	var resp *longrunningpb.Operation
   763  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   764  		var err error
   765  		resp, err = executeRPC(ctx, c.modelClient.DeleteModelVersion, req, settings.GRPC, c.logger, "DeleteModelVersion")
   766  		return err
   767  	}, opts...)
   768  	if err != nil {
   769  		return nil, err
   770  	}
   771  	return &DeleteModelVersionOperation{
   772  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   773  	}, nil
   774  }
   775  
   776  func (c *modelGRPCClient) MergeVersionAliases(ctx context.Context, req *aiplatformpb.MergeVersionAliasesRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   777  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   778  
   779  	hds = append(c.xGoogHeaders, hds...)
   780  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   781  	opts = append((*c.CallOptions).MergeVersionAliases[0:len((*c.CallOptions).MergeVersionAliases):len((*c.CallOptions).MergeVersionAliases)], opts...)
   782  	var resp *aiplatformpb.Model
   783  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   784  		var err error
   785  		resp, err = executeRPC(ctx, c.modelClient.MergeVersionAliases, req, settings.GRPC, c.logger, "MergeVersionAliases")
   786  		return err
   787  	}, opts...)
   788  	if err != nil {
   789  		return nil, err
   790  	}
   791  	return resp, nil
   792  }
   793  
   794  func (c *modelGRPCClient) ExportModel(ctx context.Context, req *aiplatformpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
   795  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   796  
   797  	hds = append(c.xGoogHeaders, hds...)
   798  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   799  	opts = append((*c.CallOptions).ExportModel[0:len((*c.CallOptions).ExportModel):len((*c.CallOptions).ExportModel)], opts...)
   800  	var resp *longrunningpb.Operation
   801  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   802  		var err error
   803  		resp, err = executeRPC(ctx, c.modelClient.ExportModel, req, settings.GRPC, c.logger, "ExportModel")
   804  		return err
   805  	}, opts...)
   806  	if err != nil {
   807  		return nil, err
   808  	}
   809  	return &ExportModelOperation{
   810  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   811  	}, nil
   812  }
   813  
   814  func (c *modelGRPCClient) CopyModel(ctx context.Context, req *aiplatformpb.CopyModelRequest, opts ...gax.CallOption) (*CopyModelOperation, error) {
   815  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   816  
   817  	hds = append(c.xGoogHeaders, hds...)
   818  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   819  	opts = append((*c.CallOptions).CopyModel[0:len((*c.CallOptions).CopyModel):len((*c.CallOptions).CopyModel)], opts...)
   820  	var resp *longrunningpb.Operation
   821  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   822  		var err error
   823  		resp, err = executeRPC(ctx, c.modelClient.CopyModel, req, settings.GRPC, c.logger, "CopyModel")
   824  		return err
   825  	}, opts...)
   826  	if err != nil {
   827  		return nil, err
   828  	}
   829  	return &CopyModelOperation{
   830  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   831  	}, nil
   832  }
   833  
   834  func (c *modelGRPCClient) ImportModelEvaluation(ctx context.Context, req *aiplatformpb.ImportModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
   835  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   836  
   837  	hds = append(c.xGoogHeaders, hds...)
   838  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   839  	opts = append((*c.CallOptions).ImportModelEvaluation[0:len((*c.CallOptions).ImportModelEvaluation):len((*c.CallOptions).ImportModelEvaluation)], opts...)
   840  	var resp *aiplatformpb.ModelEvaluation
   841  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   842  		var err error
   843  		resp, err = executeRPC(ctx, c.modelClient.ImportModelEvaluation, req, settings.GRPC, c.logger, "ImportModelEvaluation")
   844  		return err
   845  	}, opts...)
   846  	if err != nil {
   847  		return nil, err
   848  	}
   849  	return resp, nil
   850  }
   851  
   852  func (c *modelGRPCClient) BatchImportModelEvaluationSlices(ctx context.Context, req *aiplatformpb.BatchImportModelEvaluationSlicesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error) {
   853  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   854  
   855  	hds = append(c.xGoogHeaders, hds...)
   856  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   857  	opts = append((*c.CallOptions).BatchImportModelEvaluationSlices[0:len((*c.CallOptions).BatchImportModelEvaluationSlices):len((*c.CallOptions).BatchImportModelEvaluationSlices)], opts...)
   858  	var resp *aiplatformpb.BatchImportModelEvaluationSlicesResponse
   859  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   860  		var err error
   861  		resp, err = executeRPC(ctx, c.modelClient.BatchImportModelEvaluationSlices, req, settings.GRPC, c.logger, "BatchImportModelEvaluationSlices")
   862  		return err
   863  	}, opts...)
   864  	if err != nil {
   865  		return nil, err
   866  	}
   867  	return resp, nil
   868  }
   869  
   870  func (c *modelGRPCClient) BatchImportEvaluatedAnnotations(ctx context.Context, req *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error) {
   871  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   872  
   873  	hds = append(c.xGoogHeaders, hds...)
   874  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   875  	opts = append((*c.CallOptions).BatchImportEvaluatedAnnotations[0:len((*c.CallOptions).BatchImportEvaluatedAnnotations):len((*c.CallOptions).BatchImportEvaluatedAnnotations)], opts...)
   876  	var resp *aiplatformpb.BatchImportEvaluatedAnnotationsResponse
   877  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   878  		var err error
   879  		resp, err = executeRPC(ctx, c.modelClient.BatchImportEvaluatedAnnotations, req, settings.GRPC, c.logger, "BatchImportEvaluatedAnnotations")
   880  		return err
   881  	}, opts...)
   882  	if err != nil {
   883  		return nil, err
   884  	}
   885  	return resp, nil
   886  }
   887  
   888  func (c *modelGRPCClient) GetModelEvaluation(ctx context.Context, req *aiplatformpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
   889  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   890  
   891  	hds = append(c.xGoogHeaders, hds...)
   892  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   893  	opts = append((*c.CallOptions).GetModelEvaluation[0:len((*c.CallOptions).GetModelEvaluation):len((*c.CallOptions).GetModelEvaluation)], opts...)
   894  	var resp *aiplatformpb.ModelEvaluation
   895  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   896  		var err error
   897  		resp, err = executeRPC(ctx, c.modelClient.GetModelEvaluation, req, settings.GRPC, c.logger, "GetModelEvaluation")
   898  		return err
   899  	}, opts...)
   900  	if err != nil {
   901  		return nil, err
   902  	}
   903  	return resp, nil
   904  }
   905  
   906  func (c *modelGRPCClient) ListModelEvaluations(ctx context.Context, req *aiplatformpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
   907  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   908  
   909  	hds = append(c.xGoogHeaders, hds...)
   910  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   911  	opts = append((*c.CallOptions).ListModelEvaluations[0:len((*c.CallOptions).ListModelEvaluations):len((*c.CallOptions).ListModelEvaluations)], opts...)
   912  	it := &ModelEvaluationIterator{}
   913  	req = proto.Clone(req).(*aiplatformpb.ListModelEvaluationsRequest)
   914  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelEvaluation, string, error) {
   915  		resp := &aiplatformpb.ListModelEvaluationsResponse{}
   916  		if pageToken != "" {
   917  			req.PageToken = pageToken
   918  		}
   919  		if pageSize > math.MaxInt32 {
   920  			req.PageSize = math.MaxInt32
   921  		} else if pageSize != 0 {
   922  			req.PageSize = int32(pageSize)
   923  		}
   924  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   925  			var err error
   926  			resp, err = executeRPC(ctx, c.modelClient.ListModelEvaluations, req, settings.GRPC, c.logger, "ListModelEvaluations")
   927  			return err
   928  		}, opts...)
   929  		if err != nil {
   930  			return nil, "", err
   931  		}
   932  
   933  		it.Response = resp
   934  		return resp.GetModelEvaluations(), resp.GetNextPageToken(), nil
   935  	}
   936  	fetch := func(pageSize int, pageToken string) (string, error) {
   937  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   938  		if err != nil {
   939  			return "", err
   940  		}
   941  		it.items = append(it.items, items...)
   942  		return nextPageToken, nil
   943  	}
   944  
   945  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   946  	it.pageInfo.MaxSize = int(req.GetPageSize())
   947  	it.pageInfo.Token = req.GetPageToken()
   948  
   949  	return it
   950  }
   951  
   952  func (c *modelGRPCClient) GetModelEvaluationSlice(ctx context.Context, req *aiplatformpb.GetModelEvaluationSliceRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error) {
   953  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   954  
   955  	hds = append(c.xGoogHeaders, hds...)
   956  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   957  	opts = append((*c.CallOptions).GetModelEvaluationSlice[0:len((*c.CallOptions).GetModelEvaluationSlice):len((*c.CallOptions).GetModelEvaluationSlice)], opts...)
   958  	var resp *aiplatformpb.ModelEvaluationSlice
   959  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   960  		var err error
   961  		resp, err = executeRPC(ctx, c.modelClient.GetModelEvaluationSlice, req, settings.GRPC, c.logger, "GetModelEvaluationSlice")
   962  		return err
   963  	}, opts...)
   964  	if err != nil {
   965  		return nil, err
   966  	}
   967  	return resp, nil
   968  }
   969  
   970  func (c *modelGRPCClient) ListModelEvaluationSlices(ctx context.Context, req *aiplatformpb.ListModelEvaluationSlicesRequest, opts ...gax.CallOption) *ModelEvaluationSliceIterator {
   971  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   972  
   973  	hds = append(c.xGoogHeaders, hds...)
   974  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   975  	opts = append((*c.CallOptions).ListModelEvaluationSlices[0:len((*c.CallOptions).ListModelEvaluationSlices):len((*c.CallOptions).ListModelEvaluationSlices)], opts...)
   976  	it := &ModelEvaluationSliceIterator{}
   977  	req = proto.Clone(req).(*aiplatformpb.ListModelEvaluationSlicesRequest)
   978  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelEvaluationSlice, string, error) {
   979  		resp := &aiplatformpb.ListModelEvaluationSlicesResponse{}
   980  		if pageToken != "" {
   981  			req.PageToken = pageToken
   982  		}
   983  		if pageSize > math.MaxInt32 {
   984  			req.PageSize = math.MaxInt32
   985  		} else if pageSize != 0 {
   986  			req.PageSize = int32(pageSize)
   987  		}
   988  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   989  			var err error
   990  			resp, err = executeRPC(ctx, c.modelClient.ListModelEvaluationSlices, req, settings.GRPC, c.logger, "ListModelEvaluationSlices")
   991  			return err
   992  		}, opts...)
   993  		if err != nil {
   994  			return nil, "", err
   995  		}
   996  
   997  		it.Response = resp
   998  		return resp.GetModelEvaluationSlices(), resp.GetNextPageToken(), nil
   999  	}
  1000  	fetch := func(pageSize int, pageToken string) (string, error) {
  1001  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1002  		if err != nil {
  1003  			return "", err
  1004  		}
  1005  		it.items = append(it.items, items...)
  1006  		return nextPageToken, nil
  1007  	}
  1008  
  1009  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1010  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1011  	it.pageInfo.Token = req.GetPageToken()
  1012  
  1013  	return it
  1014  }
  1015  
  1016  func (c *modelGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1017  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1018  
  1019  	hds = append(c.xGoogHeaders, hds...)
  1020  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1021  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1022  	var resp *locationpb.Location
  1023  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1024  		var err error
  1025  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
  1026  		return err
  1027  	}, opts...)
  1028  	if err != nil {
  1029  		return nil, err
  1030  	}
  1031  	return resp, nil
  1032  }
  1033  
  1034  func (c *modelGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1035  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1036  
  1037  	hds = append(c.xGoogHeaders, hds...)
  1038  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1039  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
  1040  	it := &LocationIterator{}
  1041  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1042  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1043  		resp := &locationpb.ListLocationsResponse{}
  1044  		if pageToken != "" {
  1045  			req.PageToken = pageToken
  1046  		}
  1047  		if pageSize > math.MaxInt32 {
  1048  			req.PageSize = math.MaxInt32
  1049  		} else if pageSize != 0 {
  1050  			req.PageSize = int32(pageSize)
  1051  		}
  1052  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1053  			var err error
  1054  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
  1055  			return err
  1056  		}, opts...)
  1057  		if err != nil {
  1058  			return nil, "", err
  1059  		}
  1060  
  1061  		it.Response = resp
  1062  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1063  	}
  1064  	fetch := func(pageSize int, pageToken string) (string, error) {
  1065  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1066  		if err != nil {
  1067  			return "", err
  1068  		}
  1069  		it.items = append(it.items, items...)
  1070  		return nextPageToken, nil
  1071  	}
  1072  
  1073  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1074  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1075  	it.pageInfo.Token = req.GetPageToken()
  1076  
  1077  	return it
  1078  }
  1079  
  1080  func (c *modelGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1081  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1082  
  1083  	hds = append(c.xGoogHeaders, hds...)
  1084  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1085  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1086  	var resp *iampb.Policy
  1087  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1088  		var err error
  1089  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
  1090  		return err
  1091  	}, opts...)
  1092  	if err != nil {
  1093  		return nil, err
  1094  	}
  1095  	return resp, nil
  1096  }
  1097  
  1098  func (c *modelGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1099  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1100  
  1101  	hds = append(c.xGoogHeaders, hds...)
  1102  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1103  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1104  	var resp *iampb.Policy
  1105  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1106  		var err error
  1107  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
  1108  		return err
  1109  	}, opts...)
  1110  	if err != nil {
  1111  		return nil, err
  1112  	}
  1113  	return resp, nil
  1114  }
  1115  
  1116  func (c *modelGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1117  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1118  
  1119  	hds = append(c.xGoogHeaders, hds...)
  1120  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1121  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1122  	var resp *iampb.TestIamPermissionsResponse
  1123  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1124  		var err error
  1125  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
  1126  		return err
  1127  	}, opts...)
  1128  	if err != nil {
  1129  		return nil, err
  1130  	}
  1131  	return resp, nil
  1132  }
  1133  
  1134  func (c *modelGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1135  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1136  
  1137  	hds = append(c.xGoogHeaders, hds...)
  1138  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1139  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
  1140  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1141  		var err error
  1142  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
  1143  		return err
  1144  	}, opts...)
  1145  	return err
  1146  }
  1147  
  1148  func (c *modelGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1149  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1150  
  1151  	hds = append(c.xGoogHeaders, hds...)
  1152  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1153  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
  1154  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1155  		var err error
  1156  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
  1157  		return err
  1158  	}, opts...)
  1159  	return err
  1160  }
  1161  
  1162  func (c *modelGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1163  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1164  
  1165  	hds = append(c.xGoogHeaders, hds...)
  1166  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1167  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1168  	var resp *longrunningpb.Operation
  1169  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1170  		var err error
  1171  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
  1172  		return err
  1173  	}, opts...)
  1174  	if err != nil {
  1175  		return nil, err
  1176  	}
  1177  	return resp, nil
  1178  }
  1179  
  1180  func (c *modelGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1181  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1182  
  1183  	hds = append(c.xGoogHeaders, hds...)
  1184  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1185  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
  1186  	it := &OperationIterator{}
  1187  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1188  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1189  		resp := &longrunningpb.ListOperationsResponse{}
  1190  		if pageToken != "" {
  1191  			req.PageToken = pageToken
  1192  		}
  1193  		if pageSize > math.MaxInt32 {
  1194  			req.PageSize = math.MaxInt32
  1195  		} else if pageSize != 0 {
  1196  			req.PageSize = int32(pageSize)
  1197  		}
  1198  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1199  			var err error
  1200  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
  1201  			return err
  1202  		}, opts...)
  1203  		if err != nil {
  1204  			return nil, "", err
  1205  		}
  1206  
  1207  		it.Response = resp
  1208  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1209  	}
  1210  	fetch := func(pageSize int, pageToken string) (string, error) {
  1211  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1212  		if err != nil {
  1213  			return "", err
  1214  		}
  1215  		it.items = append(it.items, items...)
  1216  		return nextPageToken, nil
  1217  	}
  1218  
  1219  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1220  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1221  	it.pageInfo.Token = req.GetPageToken()
  1222  
  1223  	return it
  1224  }
  1225  
  1226  func (c *modelGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1227  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1228  
  1229  	hds = append(c.xGoogHeaders, hds...)
  1230  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1231  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1232  	var resp *longrunningpb.Operation
  1233  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1234  		var err error
  1235  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
  1236  		return err
  1237  	}, opts...)
  1238  	if err != nil {
  1239  		return nil, err
  1240  	}
  1241  	return resp, nil
  1242  }
  1243  
  1244  // CopyModelOperation returns a new CopyModelOperation from a given name.
  1245  // The name must be that of a previously created CopyModelOperation, possibly from a different process.
  1246  func (c *modelGRPCClient) CopyModelOperation(name string) *CopyModelOperation {
  1247  	return &CopyModelOperation{
  1248  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1249  	}
  1250  }
  1251  
  1252  // DeleteModelOperation returns a new DeleteModelOperation from a given name.
  1253  // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
  1254  func (c *modelGRPCClient) DeleteModelOperation(name string) *DeleteModelOperation {
  1255  	return &DeleteModelOperation{
  1256  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1257  	}
  1258  }
  1259  
  1260  // DeleteModelVersionOperation returns a new DeleteModelVersionOperation from a given name.
  1261  // The name must be that of a previously created DeleteModelVersionOperation, possibly from a different process.
  1262  func (c *modelGRPCClient) DeleteModelVersionOperation(name string) *DeleteModelVersionOperation {
  1263  	return &DeleteModelVersionOperation{
  1264  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1265  	}
  1266  }
  1267  
  1268  // ExportModelOperation returns a new ExportModelOperation from a given name.
  1269  // The name must be that of a previously created ExportModelOperation, possibly from a different process.
  1270  func (c *modelGRPCClient) ExportModelOperation(name string) *ExportModelOperation {
  1271  	return &ExportModelOperation{
  1272  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1273  	}
  1274  }
  1275  
  1276  // UpdateExplanationDatasetOperation returns a new UpdateExplanationDatasetOperation from a given name.
  1277  // The name must be that of a previously created UpdateExplanationDatasetOperation, possibly from a different process.
  1278  func (c *modelGRPCClient) UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation {
  1279  	return &UpdateExplanationDatasetOperation{
  1280  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1281  	}
  1282  }
  1283  
  1284  // UploadModelOperation returns a new UploadModelOperation from a given name.
  1285  // The name must be that of a previously created UploadModelOperation, possibly from a different process.
  1286  func (c *modelGRPCClient) UploadModelOperation(name string) *UploadModelOperation {
  1287  	return &UploadModelOperation{
  1288  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1289  	}
  1290  }