cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/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  	"bytes"
    21  	"context"
    22  	"fmt"
    23  	"log/slog"
    24  	"math"
    25  	"net/http"
    26  	"net/url"
    27  	"time"
    28  
    29  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
    30  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    31  	"cloud.google.com/go/longrunning"
    32  	lroauto "cloud.google.com/go/longrunning/autogen"
    33  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    34  	gax "github.com/googleapis/gax-go/v2"
    35  	"google.golang.org/api/iterator"
    36  	"google.golang.org/api/option"
    37  	"google.golang.org/api/option/internaloption"
    38  	gtransport "google.golang.org/api/transport/grpc"
    39  	httptransport "google.golang.org/api/transport/http"
    40  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    41  	"google.golang.org/grpc"
    42  	"google.golang.org/protobuf/encoding/protojson"
    43  	"google.golang.org/protobuf/proto"
    44  )
    45  
    46  var newModelClientHook clientHook
    47  
    48  // ModelCallOptions contains the retry settings for each method of ModelClient.
    49  type ModelCallOptions struct {
    50  	UploadModel                      []gax.CallOption
    51  	GetModel                         []gax.CallOption
    52  	ListModels                       []gax.CallOption
    53  	ListModelVersions                []gax.CallOption
    54  	ListModelVersionCheckpoints      []gax.CallOption
    55  	UpdateModel                      []gax.CallOption
    56  	UpdateExplanationDataset         []gax.CallOption
    57  	DeleteModel                      []gax.CallOption
    58  	DeleteModelVersion               []gax.CallOption
    59  	MergeVersionAliases              []gax.CallOption
    60  	ExportModel                      []gax.CallOption
    61  	CopyModel                        []gax.CallOption
    62  	ImportModelEvaluation            []gax.CallOption
    63  	BatchImportModelEvaluationSlices []gax.CallOption
    64  	BatchImportEvaluatedAnnotations  []gax.CallOption
    65  	GetModelEvaluation               []gax.CallOption
    66  	ListModelEvaluations             []gax.CallOption
    67  	GetModelEvaluationSlice          []gax.CallOption
    68  	ListModelEvaluationSlices        []gax.CallOption
    69  	RecommendSpec                    []gax.CallOption
    70  	GetLocation                      []gax.CallOption
    71  	ListLocations                    []gax.CallOption
    72  	GetIamPolicy                     []gax.CallOption
    73  	SetIamPolicy                     []gax.CallOption
    74  	TestIamPermissions               []gax.CallOption
    75  	CancelOperation                  []gax.CallOption
    76  	DeleteOperation                  []gax.CallOption
    77  	GetOperation                     []gax.CallOption
    78  	ListOperations                   []gax.CallOption
    79  	WaitOperation                    []gax.CallOption
    80  }
    81  
    82  func defaultModelGRPCClientOptions() []option.ClientOption {
    83  	return []option.ClientOption{
    84  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    85  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    86  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    87  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    88  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    89  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    90  		internaloption.EnableJwtWithScope(),
    91  		internaloption.EnableNewAuthLibrary(),
    92  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    93  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    94  	}
    95  }
    96  
    97  func defaultModelCallOptions() *ModelCallOptions {
    98  	return &ModelCallOptions{
    99  		UploadModel: []gax.CallOption{
   100  			gax.WithTimeout(5000 * time.Millisecond),
   101  		},
   102  		GetModel: []gax.CallOption{
   103  			gax.WithTimeout(5000 * time.Millisecond),
   104  		},
   105  		ListModels: []gax.CallOption{
   106  			gax.WithTimeout(5000 * time.Millisecond),
   107  		},
   108  		ListModelVersions:           []gax.CallOption{},
   109  		ListModelVersionCheckpoints: []gax.CallOption{},
   110  		UpdateModel: []gax.CallOption{
   111  			gax.WithTimeout(5000 * time.Millisecond),
   112  		},
   113  		UpdateExplanationDataset: []gax.CallOption{},
   114  		DeleteModel: []gax.CallOption{
   115  			gax.WithTimeout(5000 * time.Millisecond),
   116  		},
   117  		DeleteModelVersion:  []gax.CallOption{},
   118  		MergeVersionAliases: []gax.CallOption{},
   119  		ExportModel: []gax.CallOption{
   120  			gax.WithTimeout(5000 * time.Millisecond),
   121  		},
   122  		CopyModel: []gax.CallOption{
   123  			gax.WithTimeout(5000 * time.Millisecond),
   124  		},
   125  		ImportModelEvaluation:            []gax.CallOption{},
   126  		BatchImportModelEvaluationSlices: []gax.CallOption{},
   127  		BatchImportEvaluatedAnnotations:  []gax.CallOption{},
   128  		GetModelEvaluation: []gax.CallOption{
   129  			gax.WithTimeout(5000 * time.Millisecond),
   130  		},
   131  		ListModelEvaluations: []gax.CallOption{
   132  			gax.WithTimeout(5000 * time.Millisecond),
   133  		},
   134  		GetModelEvaluationSlice: []gax.CallOption{
   135  			gax.WithTimeout(5000 * time.Millisecond),
   136  		},
   137  		ListModelEvaluationSlices: []gax.CallOption{
   138  			gax.WithTimeout(5000 * time.Millisecond),
   139  		},
   140  		RecommendSpec:      []gax.CallOption{},
   141  		GetLocation:        []gax.CallOption{},
   142  		ListLocations:      []gax.CallOption{},
   143  		GetIamPolicy:       []gax.CallOption{},
   144  		SetIamPolicy:       []gax.CallOption{},
   145  		TestIamPermissions: []gax.CallOption{},
   146  		CancelOperation:    []gax.CallOption{},
   147  		DeleteOperation:    []gax.CallOption{},
   148  		GetOperation:       []gax.CallOption{},
   149  		ListOperations:     []gax.CallOption{},
   150  		WaitOperation:      []gax.CallOption{},
   151  	}
   152  }
   153  
   154  func defaultModelRESTCallOptions() *ModelCallOptions {
   155  	return &ModelCallOptions{
   156  		UploadModel: []gax.CallOption{
   157  			gax.WithTimeout(5000 * time.Millisecond),
   158  		},
   159  		GetModel: []gax.CallOption{
   160  			gax.WithTimeout(5000 * time.Millisecond),
   161  		},
   162  		ListModels: []gax.CallOption{
   163  			gax.WithTimeout(5000 * time.Millisecond),
   164  		},
   165  		ListModelVersions:           []gax.CallOption{},
   166  		ListModelVersionCheckpoints: []gax.CallOption{},
   167  		UpdateModel: []gax.CallOption{
   168  			gax.WithTimeout(5000 * time.Millisecond),
   169  		},
   170  		UpdateExplanationDataset: []gax.CallOption{},
   171  		DeleteModel: []gax.CallOption{
   172  			gax.WithTimeout(5000 * time.Millisecond),
   173  		},
   174  		DeleteModelVersion:  []gax.CallOption{},
   175  		MergeVersionAliases: []gax.CallOption{},
   176  		ExportModel: []gax.CallOption{
   177  			gax.WithTimeout(5000 * time.Millisecond),
   178  		},
   179  		CopyModel: []gax.CallOption{
   180  			gax.WithTimeout(5000 * time.Millisecond),
   181  		},
   182  		ImportModelEvaluation:            []gax.CallOption{},
   183  		BatchImportModelEvaluationSlices: []gax.CallOption{},
   184  		BatchImportEvaluatedAnnotations:  []gax.CallOption{},
   185  		GetModelEvaluation: []gax.CallOption{
   186  			gax.WithTimeout(5000 * time.Millisecond),
   187  		},
   188  		ListModelEvaluations: []gax.CallOption{
   189  			gax.WithTimeout(5000 * time.Millisecond),
   190  		},
   191  		GetModelEvaluationSlice: []gax.CallOption{
   192  			gax.WithTimeout(5000 * time.Millisecond),
   193  		},
   194  		ListModelEvaluationSlices: []gax.CallOption{
   195  			gax.WithTimeout(5000 * time.Millisecond),
   196  		},
   197  		RecommendSpec:      []gax.CallOption{},
   198  		GetLocation:        []gax.CallOption{},
   199  		ListLocations:      []gax.CallOption{},
   200  		GetIamPolicy:       []gax.CallOption{},
   201  		SetIamPolicy:       []gax.CallOption{},
   202  		TestIamPermissions: []gax.CallOption{},
   203  		CancelOperation:    []gax.CallOption{},
   204  		DeleteOperation:    []gax.CallOption{},
   205  		GetOperation:       []gax.CallOption{},
   206  		ListOperations:     []gax.CallOption{},
   207  		WaitOperation:      []gax.CallOption{},
   208  	}
   209  }
   210  
   211  // internalModelClient is an interface that defines the methods available from Vertex AI API.
   212  type internalModelClient interface {
   213  	Close() error
   214  	setGoogleClientInfo(...string)
   215  	Connection() *grpc.ClientConn
   216  	UploadModel(context.Context, *aiplatformpb.UploadModelRequest, ...gax.CallOption) (*UploadModelOperation, error)
   217  	UploadModelOperation(name string) *UploadModelOperation
   218  	GetModel(context.Context, *aiplatformpb.GetModelRequest, ...gax.CallOption) (*aiplatformpb.Model, error)
   219  	ListModels(context.Context, *aiplatformpb.ListModelsRequest, ...gax.CallOption) *ModelIterator
   220  	ListModelVersions(context.Context, *aiplatformpb.ListModelVersionsRequest, ...gax.CallOption) *ModelIterator
   221  	ListModelVersionCheckpoints(context.Context, *aiplatformpb.ListModelVersionCheckpointsRequest, ...gax.CallOption) *ModelVersionCheckpointIterator
   222  	UpdateModel(context.Context, *aiplatformpb.UpdateModelRequest, ...gax.CallOption) (*aiplatformpb.Model, error)
   223  	UpdateExplanationDataset(context.Context, *aiplatformpb.UpdateExplanationDatasetRequest, ...gax.CallOption) (*UpdateExplanationDatasetOperation, error)
   224  	UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation
   225  	DeleteModel(context.Context, *aiplatformpb.DeleteModelRequest, ...gax.CallOption) (*DeleteModelOperation, error)
   226  	DeleteModelOperation(name string) *DeleteModelOperation
   227  	DeleteModelVersion(context.Context, *aiplatformpb.DeleteModelVersionRequest, ...gax.CallOption) (*DeleteModelVersionOperation, error)
   228  	DeleteModelVersionOperation(name string) *DeleteModelVersionOperation
   229  	MergeVersionAliases(context.Context, *aiplatformpb.MergeVersionAliasesRequest, ...gax.CallOption) (*aiplatformpb.Model, error)
   230  	ExportModel(context.Context, *aiplatformpb.ExportModelRequest, ...gax.CallOption) (*ExportModelOperation, error)
   231  	ExportModelOperation(name string) *ExportModelOperation
   232  	CopyModel(context.Context, *aiplatformpb.CopyModelRequest, ...gax.CallOption) (*CopyModelOperation, error)
   233  	CopyModelOperation(name string) *CopyModelOperation
   234  	ImportModelEvaluation(context.Context, *aiplatformpb.ImportModelEvaluationRequest, ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error)
   235  	BatchImportModelEvaluationSlices(context.Context, *aiplatformpb.BatchImportModelEvaluationSlicesRequest, ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error)
   236  	BatchImportEvaluatedAnnotations(context.Context, *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error)
   237  	GetModelEvaluation(context.Context, *aiplatformpb.GetModelEvaluationRequest, ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error)
   238  	ListModelEvaluations(context.Context, *aiplatformpb.ListModelEvaluationsRequest, ...gax.CallOption) *ModelEvaluationIterator
   239  	GetModelEvaluationSlice(context.Context, *aiplatformpb.GetModelEvaluationSliceRequest, ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error)
   240  	ListModelEvaluationSlices(context.Context, *aiplatformpb.ListModelEvaluationSlicesRequest, ...gax.CallOption) *ModelEvaluationSliceIterator
   241  	RecommendSpec(context.Context, *aiplatformpb.RecommendSpecRequest, ...gax.CallOption) (*aiplatformpb.RecommendSpecResponse, error)
   242  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   243  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   244  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   245  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   246  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   247  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   248  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   249  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   250  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   251  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   252  }
   253  
   254  // ModelClient is a client for interacting with Vertex AI API.
   255  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   256  //
   257  // A service for managing Vertex AI’s machine learning Models.
   258  type ModelClient struct {
   259  	// The internal transport-dependent client.
   260  	internalClient internalModelClient
   261  
   262  	// The call options for this service.
   263  	CallOptions *ModelCallOptions
   264  
   265  	// LROClient is used internally to handle long-running operations.
   266  	// It is exposed so that its CallOptions can be modified if required.
   267  	// Users should not Close this client.
   268  	LROClient *lroauto.OperationsClient
   269  }
   270  
   271  // Wrapper methods routed to the internal client.
   272  
   273  // Close closes the connection to the API service. The user should invoke this when
   274  // the client is no longer required.
   275  func (c *ModelClient) Close() error {
   276  	return c.internalClient.Close()
   277  }
   278  
   279  // setGoogleClientInfo sets the name and version of the application in
   280  // the `x-goog-api-client` header passed on each request. Intended for
   281  // use by Google-written clients.
   282  func (c *ModelClient) setGoogleClientInfo(keyval ...string) {
   283  	c.internalClient.setGoogleClientInfo(keyval...)
   284  }
   285  
   286  // Connection returns a connection to the API service.
   287  //
   288  // Deprecated: Connections are now pooled so this method does not always
   289  // return the same resource.
   290  func (c *ModelClient) Connection() *grpc.ClientConn {
   291  	return c.internalClient.Connection()
   292  }
   293  
   294  // UploadModel uploads a Model artifact into Vertex AI.
   295  func (c *ModelClient) UploadModel(ctx context.Context, req *aiplatformpb.UploadModelRequest, opts ...gax.CallOption) (*UploadModelOperation, error) {
   296  	return c.internalClient.UploadModel(ctx, req, opts...)
   297  }
   298  
   299  // UploadModelOperation returns a new UploadModelOperation from a given name.
   300  // The name must be that of a previously created UploadModelOperation, possibly from a different process.
   301  func (c *ModelClient) UploadModelOperation(name string) *UploadModelOperation {
   302  	return c.internalClient.UploadModelOperation(name)
   303  }
   304  
   305  // GetModel gets a Model.
   306  func (c *ModelClient) GetModel(ctx context.Context, req *aiplatformpb.GetModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   307  	return c.internalClient.GetModel(ctx, req, opts...)
   308  }
   309  
   310  // ListModels lists Models in a Location.
   311  func (c *ModelClient) ListModels(ctx context.Context, req *aiplatformpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
   312  	return c.internalClient.ListModels(ctx, req, opts...)
   313  }
   314  
   315  // ListModelVersions lists versions of the specified model.
   316  func (c *ModelClient) ListModelVersions(ctx context.Context, req *aiplatformpb.ListModelVersionsRequest, opts ...gax.CallOption) *ModelIterator {
   317  	return c.internalClient.ListModelVersions(ctx, req, opts...)
   318  }
   319  
   320  // ListModelVersionCheckpoints lists checkpoints of the specified model version.
   321  func (c *ModelClient) ListModelVersionCheckpoints(ctx context.Context, req *aiplatformpb.ListModelVersionCheckpointsRequest, opts ...gax.CallOption) *ModelVersionCheckpointIterator {
   322  	return c.internalClient.ListModelVersionCheckpoints(ctx, req, opts...)
   323  }
   324  
   325  // UpdateModel updates a Model.
   326  func (c *ModelClient) UpdateModel(ctx context.Context, req *aiplatformpb.UpdateModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   327  	return c.internalClient.UpdateModel(ctx, req, opts...)
   328  }
   329  
   330  // UpdateExplanationDataset incrementally update the dataset used for an examples model.
   331  func (c *ModelClient) UpdateExplanationDataset(ctx context.Context, req *aiplatformpb.UpdateExplanationDatasetRequest, opts ...gax.CallOption) (*UpdateExplanationDatasetOperation, error) {
   332  	return c.internalClient.UpdateExplanationDataset(ctx, req, opts...)
   333  }
   334  
   335  // UpdateExplanationDatasetOperation returns a new UpdateExplanationDatasetOperation from a given name.
   336  // The name must be that of a previously created UpdateExplanationDatasetOperation, possibly from a different process.
   337  func (c *ModelClient) UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation {
   338  	return c.internalClient.UpdateExplanationDatasetOperation(name)
   339  }
   340  
   341  // DeleteModel deletes a Model.
   342  //
   343  // A model cannot be deleted if any
   344  // Endpoint resource has a
   345  // DeployedModel based on the
   346  // model in its
   347  // deployed_models
   348  // field.
   349  func (c *ModelClient) DeleteModel(ctx context.Context, req *aiplatformpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
   350  	return c.internalClient.DeleteModel(ctx, req, opts...)
   351  }
   352  
   353  // DeleteModelOperation returns a new DeleteModelOperation from a given name.
   354  // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
   355  func (c *ModelClient) DeleteModelOperation(name string) *DeleteModelOperation {
   356  	return c.internalClient.DeleteModelOperation(name)
   357  }
   358  
   359  // DeleteModelVersion deletes a Model version.
   360  //
   361  // Model version can only be deleted if there are no
   362  // DeployedModels created
   363  // from it. Deleting the only version in the Model is not allowed. Use
   364  // DeleteModel for
   365  // deleting the Model instead.
   366  func (c *ModelClient) DeleteModelVersion(ctx context.Context, req *aiplatformpb.DeleteModelVersionRequest, opts ...gax.CallOption) (*DeleteModelVersionOperation, error) {
   367  	return c.internalClient.DeleteModelVersion(ctx, req, opts...)
   368  }
   369  
   370  // DeleteModelVersionOperation returns a new DeleteModelVersionOperation from a given name.
   371  // The name must be that of a previously created DeleteModelVersionOperation, possibly from a different process.
   372  func (c *ModelClient) DeleteModelVersionOperation(name string) *DeleteModelVersionOperation {
   373  	return c.internalClient.DeleteModelVersionOperation(name)
   374  }
   375  
   376  // MergeVersionAliases merges a set of aliases for a Model version.
   377  func (c *ModelClient) MergeVersionAliases(ctx context.Context, req *aiplatformpb.MergeVersionAliasesRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   378  	return c.internalClient.MergeVersionAliases(ctx, req, opts...)
   379  }
   380  
   381  // ExportModel exports a trained, exportable Model to a location specified by the
   382  // user. A Model is considered to be exportable if it has at least one
   383  // [supported export
   384  // format][google.cloud.aiplatform.v1beta1.Model.supported_export_formats].
   385  func (c *ModelClient) ExportModel(ctx context.Context, req *aiplatformpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
   386  	return c.internalClient.ExportModel(ctx, req, opts...)
   387  }
   388  
   389  // ExportModelOperation returns a new ExportModelOperation from a given name.
   390  // The name must be that of a previously created ExportModelOperation, possibly from a different process.
   391  func (c *ModelClient) ExportModelOperation(name string) *ExportModelOperation {
   392  	return c.internalClient.ExportModelOperation(name)
   393  }
   394  
   395  // CopyModel copies an already existing Vertex AI Model into the specified Location.
   396  // The source Model must exist in the same Project.
   397  // When copying custom Models, the users themselves are responsible for
   398  // Model.metadata content to
   399  // be region-agnostic, as well as making sure that any resources (e.g. files)
   400  // it depends on remain accessible.
   401  func (c *ModelClient) CopyModel(ctx context.Context, req *aiplatformpb.CopyModelRequest, opts ...gax.CallOption) (*CopyModelOperation, error) {
   402  	return c.internalClient.CopyModel(ctx, req, opts...)
   403  }
   404  
   405  // CopyModelOperation returns a new CopyModelOperation from a given name.
   406  // The name must be that of a previously created CopyModelOperation, possibly from a different process.
   407  func (c *ModelClient) CopyModelOperation(name string) *CopyModelOperation {
   408  	return c.internalClient.CopyModelOperation(name)
   409  }
   410  
   411  // ImportModelEvaluation imports an externally generated ModelEvaluation.
   412  func (c *ModelClient) ImportModelEvaluation(ctx context.Context, req *aiplatformpb.ImportModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
   413  	return c.internalClient.ImportModelEvaluation(ctx, req, opts...)
   414  }
   415  
   416  // BatchImportModelEvaluationSlices imports a list of externally generated ModelEvaluationSlice.
   417  func (c *ModelClient) BatchImportModelEvaluationSlices(ctx context.Context, req *aiplatformpb.BatchImportModelEvaluationSlicesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error) {
   418  	return c.internalClient.BatchImportModelEvaluationSlices(ctx, req, opts...)
   419  }
   420  
   421  // BatchImportEvaluatedAnnotations imports a list of externally generated EvaluatedAnnotations.
   422  func (c *ModelClient) BatchImportEvaluatedAnnotations(ctx context.Context, req *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error) {
   423  	return c.internalClient.BatchImportEvaluatedAnnotations(ctx, req, opts...)
   424  }
   425  
   426  // GetModelEvaluation gets a ModelEvaluation.
   427  func (c *ModelClient) GetModelEvaluation(ctx context.Context, req *aiplatformpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
   428  	return c.internalClient.GetModelEvaluation(ctx, req, opts...)
   429  }
   430  
   431  // ListModelEvaluations lists ModelEvaluations in a Model.
   432  func (c *ModelClient) ListModelEvaluations(ctx context.Context, req *aiplatformpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
   433  	return c.internalClient.ListModelEvaluations(ctx, req, opts...)
   434  }
   435  
   436  // GetModelEvaluationSlice gets a ModelEvaluationSlice.
   437  func (c *ModelClient) GetModelEvaluationSlice(ctx context.Context, req *aiplatformpb.GetModelEvaluationSliceRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error) {
   438  	return c.internalClient.GetModelEvaluationSlice(ctx, req, opts...)
   439  }
   440  
   441  // ListModelEvaluationSlices lists ModelEvaluationSlices in a ModelEvaluation.
   442  func (c *ModelClient) ListModelEvaluationSlices(ctx context.Context, req *aiplatformpb.ListModelEvaluationSlicesRequest, opts ...gax.CallOption) *ModelEvaluationSliceIterator {
   443  	return c.internalClient.ListModelEvaluationSlices(ctx, req, opts...)
   444  }
   445  
   446  // RecommendSpec gets a Model’s spec recommendations.
   447  func (c *ModelClient) RecommendSpec(ctx context.Context, req *aiplatformpb.RecommendSpecRequest, opts ...gax.CallOption) (*aiplatformpb.RecommendSpecResponse, error) {
   448  	return c.internalClient.RecommendSpec(ctx, req, opts...)
   449  }
   450  
   451  // GetLocation gets information about a location.
   452  func (c *ModelClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   453  	return c.internalClient.GetLocation(ctx, req, opts...)
   454  }
   455  
   456  // ListLocations lists information about the supported locations for this service.
   457  func (c *ModelClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   458  	return c.internalClient.ListLocations(ctx, req, opts...)
   459  }
   460  
   461  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   462  // if the resource exists and does not have a policy set.
   463  func (c *ModelClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   464  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   465  }
   466  
   467  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   468  // any existing policy.
   469  //
   470  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   471  // errors.
   472  func (c *ModelClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   473  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   474  }
   475  
   476  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   477  // resource does not exist, this will return an empty set of
   478  // permissions, not a NOT_FOUND error.
   479  //
   480  // Note: This operation is designed to be used for building
   481  // permission-aware UIs and command-line tools, not for authorization
   482  // checking. This operation may “fail open” without warning.
   483  func (c *ModelClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   484  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   485  }
   486  
   487  // CancelOperation is a utility method from google.longrunning.Operations.
   488  func (c *ModelClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   489  	return c.internalClient.CancelOperation(ctx, req, opts...)
   490  }
   491  
   492  // DeleteOperation is a utility method from google.longrunning.Operations.
   493  func (c *ModelClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   494  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   495  }
   496  
   497  // GetOperation is a utility method from google.longrunning.Operations.
   498  func (c *ModelClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   499  	return c.internalClient.GetOperation(ctx, req, opts...)
   500  }
   501  
   502  // ListOperations is a utility method from google.longrunning.Operations.
   503  func (c *ModelClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   504  	return c.internalClient.ListOperations(ctx, req, opts...)
   505  }
   506  
   507  // WaitOperation is a utility method from google.longrunning.Operations.
   508  func (c *ModelClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   509  	return c.internalClient.WaitOperation(ctx, req, opts...)
   510  }
   511  
   512  // modelGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   513  //
   514  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   515  type modelGRPCClient struct {
   516  	// Connection pool of gRPC connections to the service.
   517  	connPool gtransport.ConnPool
   518  
   519  	// Points back to the CallOptions field of the containing ModelClient
   520  	CallOptions **ModelCallOptions
   521  
   522  	// The gRPC API client.
   523  	modelClient aiplatformpb.ModelServiceClient
   524  
   525  	// LROClient is used internally to handle long-running operations.
   526  	// It is exposed so that its CallOptions can be modified if required.
   527  	// Users should not Close this client.
   528  	LROClient **lroauto.OperationsClient
   529  
   530  	operationsClient longrunningpb.OperationsClient
   531  
   532  	iamPolicyClient iampb.IAMPolicyClient
   533  
   534  	locationsClient locationpb.LocationsClient
   535  
   536  	// The x-goog-* metadata to be sent with each request.
   537  	xGoogHeaders []string
   538  
   539  	logger *slog.Logger
   540  }
   541  
   542  // NewModelClient creates a new model service client based on gRPC.
   543  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   544  //
   545  // A service for managing Vertex AI’s machine learning Models.
   546  func NewModelClient(ctx context.Context, opts ...option.ClientOption) (*ModelClient, error) {
   547  	clientOpts := defaultModelGRPCClientOptions()
   548  	if newModelClientHook != nil {
   549  		hookOpts, err := newModelClientHook(ctx, clientHookParams{})
   550  		if err != nil {
   551  			return nil, err
   552  		}
   553  		clientOpts = append(clientOpts, hookOpts...)
   554  	}
   555  
   556  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   557  	if err != nil {
   558  		return nil, err
   559  	}
   560  	client := ModelClient{CallOptions: defaultModelCallOptions()}
   561  
   562  	c := &modelGRPCClient{
   563  		connPool:         connPool,
   564  		modelClient:      aiplatformpb.NewModelServiceClient(connPool),
   565  		CallOptions:      &client.CallOptions,
   566  		logger:           internaloption.GetLogger(opts),
   567  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   568  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   569  		locationsClient:  locationpb.NewLocationsClient(connPool),
   570  	}
   571  	c.setGoogleClientInfo()
   572  
   573  	client.internalClient = c
   574  
   575  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   576  	if err != nil {
   577  		// This error "should not happen", since we are just reusing old connection pool
   578  		// and never actually need to dial.
   579  		// If this does happen, we could leak connp. However, we cannot close conn:
   580  		// If the user invoked the constructor with option.WithGRPCConn,
   581  		// we would close a connection that's still in use.
   582  		// TODO: investigate error conditions.
   583  		return nil, err
   584  	}
   585  	c.LROClient = &client.LROClient
   586  	return &client, nil
   587  }
   588  
   589  // Connection returns a connection to the API service.
   590  //
   591  // Deprecated: Connections are now pooled so this method does not always
   592  // return the same resource.
   593  func (c *modelGRPCClient) Connection() *grpc.ClientConn {
   594  	return c.connPool.Conn()
   595  }
   596  
   597  // setGoogleClientInfo sets the name and version of the application in
   598  // the `x-goog-api-client` header passed on each request. Intended for
   599  // use by Google-written clients.
   600  func (c *modelGRPCClient) setGoogleClientInfo(keyval ...string) {
   601  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   602  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   603  	c.xGoogHeaders = []string{
   604  		"x-goog-api-client", gax.XGoogHeader(kv...),
   605  	}
   606  }
   607  
   608  // Close closes the connection to the API service. The user should invoke this when
   609  // the client is no longer required.
   610  func (c *modelGRPCClient) Close() error {
   611  	return c.connPool.Close()
   612  }
   613  
   614  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   615  type modelRESTClient struct {
   616  	// The http endpoint to connect to.
   617  	endpoint string
   618  
   619  	// The http client.
   620  	httpClient *http.Client
   621  
   622  	// LROClient is used internally to handle long-running operations.
   623  	// It is exposed so that its CallOptions can be modified if required.
   624  	// Users should not Close this client.
   625  	LROClient **lroauto.OperationsClient
   626  
   627  	// The x-goog-* headers to be sent with each request.
   628  	xGoogHeaders []string
   629  
   630  	// Points back to the CallOptions field of the containing ModelClient
   631  	CallOptions **ModelCallOptions
   632  
   633  	logger *slog.Logger
   634  }
   635  
   636  // NewModelRESTClient creates a new model service rest client.
   637  //
   638  // A service for managing Vertex AI’s machine learning Models.
   639  func NewModelRESTClient(ctx context.Context, opts ...option.ClientOption) (*ModelClient, error) {
   640  	clientOpts := append(defaultModelRESTClientOptions(), opts...)
   641  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   642  	if err != nil {
   643  		return nil, err
   644  	}
   645  
   646  	callOpts := defaultModelRESTCallOptions()
   647  	c := &modelRESTClient{
   648  		endpoint:    endpoint,
   649  		httpClient:  httpClient,
   650  		CallOptions: &callOpts,
   651  		logger:      internaloption.GetLogger(opts),
   652  	}
   653  	c.setGoogleClientInfo()
   654  
   655  	lroOpts := []option.ClientOption{
   656  		option.WithHTTPClient(httpClient),
   657  		option.WithEndpoint(endpoint),
   658  	}
   659  	opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
   660  	if err != nil {
   661  		return nil, err
   662  	}
   663  	c.LROClient = &opClient
   664  
   665  	return &ModelClient{internalClient: c, CallOptions: callOpts}, nil
   666  }
   667  
   668  func defaultModelRESTClientOptions() []option.ClientOption {
   669  	return []option.ClientOption{
   670  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   671  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   672  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   673  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   674  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   675  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   676  		internaloption.EnableNewAuthLibrary(),
   677  	}
   678  }
   679  
   680  // setGoogleClientInfo sets the name and version of the application in
   681  // the `x-goog-api-client` header passed on each request. Intended for
   682  // use by Google-written clients.
   683  func (c *modelRESTClient) setGoogleClientInfo(keyval ...string) {
   684  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   685  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   686  	c.xGoogHeaders = []string{
   687  		"x-goog-api-client", gax.XGoogHeader(kv...),
   688  	}
   689  }
   690  
   691  // Close closes the connection to the API service. The user should invoke this when
   692  // the client is no longer required.
   693  func (c *modelRESTClient) Close() error {
   694  	// Replace httpClient with nil to force cleanup.
   695  	c.httpClient = nil
   696  	return nil
   697  }
   698  
   699  // Connection returns a connection to the API service.
   700  //
   701  // Deprecated: This method always returns nil.
   702  func (c *modelRESTClient) Connection() *grpc.ClientConn {
   703  	return nil
   704  }
   705  func (c *modelGRPCClient) UploadModel(ctx context.Context, req *aiplatformpb.UploadModelRequest, opts ...gax.CallOption) (*UploadModelOperation, error) {
   706  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   707  
   708  	hds = append(c.xGoogHeaders, hds...)
   709  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   710  	opts = append((*c.CallOptions).UploadModel[0:len((*c.CallOptions).UploadModel):len((*c.CallOptions).UploadModel)], opts...)
   711  	var resp *longrunningpb.Operation
   712  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   713  		var err error
   714  		resp, err = executeRPC(ctx, c.modelClient.UploadModel, req, settings.GRPC, c.logger, "UploadModel")
   715  		return err
   716  	}, opts...)
   717  	if err != nil {
   718  		return nil, err
   719  	}
   720  	return &UploadModelOperation{
   721  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   722  	}, nil
   723  }
   724  
   725  func (c *modelGRPCClient) GetModel(ctx context.Context, req *aiplatformpb.GetModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   726  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   727  
   728  	hds = append(c.xGoogHeaders, hds...)
   729  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   730  	opts = append((*c.CallOptions).GetModel[0:len((*c.CallOptions).GetModel):len((*c.CallOptions).GetModel)], opts...)
   731  	var resp *aiplatformpb.Model
   732  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   733  		var err error
   734  		resp, err = executeRPC(ctx, c.modelClient.GetModel, req, settings.GRPC, c.logger, "GetModel")
   735  		return err
   736  	}, opts...)
   737  	if err != nil {
   738  		return nil, err
   739  	}
   740  	return resp, nil
   741  }
   742  
   743  func (c *modelGRPCClient) ListModels(ctx context.Context, req *aiplatformpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
   744  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   745  
   746  	hds = append(c.xGoogHeaders, hds...)
   747  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   748  	opts = append((*c.CallOptions).ListModels[0:len((*c.CallOptions).ListModels):len((*c.CallOptions).ListModels)], opts...)
   749  	it := &ModelIterator{}
   750  	req = proto.Clone(req).(*aiplatformpb.ListModelsRequest)
   751  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Model, string, error) {
   752  		resp := &aiplatformpb.ListModelsResponse{}
   753  		if pageToken != "" {
   754  			req.PageToken = pageToken
   755  		}
   756  		if pageSize > math.MaxInt32 {
   757  			req.PageSize = math.MaxInt32
   758  		} else if pageSize != 0 {
   759  			req.PageSize = int32(pageSize)
   760  		}
   761  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   762  			var err error
   763  			resp, err = executeRPC(ctx, c.modelClient.ListModels, req, settings.GRPC, c.logger, "ListModels")
   764  			return err
   765  		}, opts...)
   766  		if err != nil {
   767  			return nil, "", err
   768  		}
   769  
   770  		it.Response = resp
   771  		return resp.GetModels(), resp.GetNextPageToken(), nil
   772  	}
   773  	fetch := func(pageSize int, pageToken string) (string, error) {
   774  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   775  		if err != nil {
   776  			return "", err
   777  		}
   778  		it.items = append(it.items, items...)
   779  		return nextPageToken, nil
   780  	}
   781  
   782  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   783  	it.pageInfo.MaxSize = int(req.GetPageSize())
   784  	it.pageInfo.Token = req.GetPageToken()
   785  
   786  	return it
   787  }
   788  
   789  func (c *modelGRPCClient) ListModelVersions(ctx context.Context, req *aiplatformpb.ListModelVersionsRequest, opts ...gax.CallOption) *ModelIterator {
   790  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   791  
   792  	hds = append(c.xGoogHeaders, hds...)
   793  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   794  	opts = append((*c.CallOptions).ListModelVersions[0:len((*c.CallOptions).ListModelVersions):len((*c.CallOptions).ListModelVersions)], opts...)
   795  	it := &ModelIterator{}
   796  	req = proto.Clone(req).(*aiplatformpb.ListModelVersionsRequest)
   797  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Model, string, error) {
   798  		resp := &aiplatformpb.ListModelVersionsResponse{}
   799  		if pageToken != "" {
   800  			req.PageToken = pageToken
   801  		}
   802  		if pageSize > math.MaxInt32 {
   803  			req.PageSize = math.MaxInt32
   804  		} else if pageSize != 0 {
   805  			req.PageSize = int32(pageSize)
   806  		}
   807  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   808  			var err error
   809  			resp, err = executeRPC(ctx, c.modelClient.ListModelVersions, req, settings.GRPC, c.logger, "ListModelVersions")
   810  			return err
   811  		}, opts...)
   812  		if err != nil {
   813  			return nil, "", err
   814  		}
   815  
   816  		it.Response = resp
   817  		return resp.GetModels(), resp.GetNextPageToken(), nil
   818  	}
   819  	fetch := func(pageSize int, pageToken string) (string, error) {
   820  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   821  		if err != nil {
   822  			return "", err
   823  		}
   824  		it.items = append(it.items, items...)
   825  		return nextPageToken, nil
   826  	}
   827  
   828  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   829  	it.pageInfo.MaxSize = int(req.GetPageSize())
   830  	it.pageInfo.Token = req.GetPageToken()
   831  
   832  	return it
   833  }
   834  
   835  func (c *modelGRPCClient) ListModelVersionCheckpoints(ctx context.Context, req *aiplatformpb.ListModelVersionCheckpointsRequest, opts ...gax.CallOption) *ModelVersionCheckpointIterator {
   836  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   837  
   838  	hds = append(c.xGoogHeaders, hds...)
   839  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   840  	opts = append((*c.CallOptions).ListModelVersionCheckpoints[0:len((*c.CallOptions).ListModelVersionCheckpoints):len((*c.CallOptions).ListModelVersionCheckpoints)], opts...)
   841  	it := &ModelVersionCheckpointIterator{}
   842  	req = proto.Clone(req).(*aiplatformpb.ListModelVersionCheckpointsRequest)
   843  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelVersionCheckpoint, string, error) {
   844  		resp := &aiplatformpb.ListModelVersionCheckpointsResponse{}
   845  		if pageToken != "" {
   846  			req.PageToken = pageToken
   847  		}
   848  		if pageSize > math.MaxInt32 {
   849  			req.PageSize = math.MaxInt32
   850  		} else if pageSize != 0 {
   851  			req.PageSize = int32(pageSize)
   852  		}
   853  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   854  			var err error
   855  			resp, err = executeRPC(ctx, c.modelClient.ListModelVersionCheckpoints, req, settings.GRPC, c.logger, "ListModelVersionCheckpoints")
   856  			return err
   857  		}, opts...)
   858  		if err != nil {
   859  			return nil, "", err
   860  		}
   861  
   862  		it.Response = resp
   863  		return resp.GetCheckpoints(), resp.GetNextPageToken(), nil
   864  	}
   865  	fetch := func(pageSize int, pageToken string) (string, error) {
   866  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   867  		if err != nil {
   868  			return "", err
   869  		}
   870  		it.items = append(it.items, items...)
   871  		return nextPageToken, nil
   872  	}
   873  
   874  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   875  	it.pageInfo.MaxSize = int(req.GetPageSize())
   876  	it.pageInfo.Token = req.GetPageToken()
   877  
   878  	return it
   879  }
   880  
   881  func (c *modelGRPCClient) UpdateModel(ctx context.Context, req *aiplatformpb.UpdateModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   882  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model.name", url.QueryEscape(req.GetModel().GetName()))}
   883  
   884  	hds = append(c.xGoogHeaders, hds...)
   885  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   886  	opts = append((*c.CallOptions).UpdateModel[0:len((*c.CallOptions).UpdateModel):len((*c.CallOptions).UpdateModel)], opts...)
   887  	var resp *aiplatformpb.Model
   888  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   889  		var err error
   890  		resp, err = executeRPC(ctx, c.modelClient.UpdateModel, req, settings.GRPC, c.logger, "UpdateModel")
   891  		return err
   892  	}, opts...)
   893  	if err != nil {
   894  		return nil, err
   895  	}
   896  	return resp, nil
   897  }
   898  
   899  func (c *modelGRPCClient) UpdateExplanationDataset(ctx context.Context, req *aiplatformpb.UpdateExplanationDatasetRequest, opts ...gax.CallOption) (*UpdateExplanationDatasetOperation, error) {
   900  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model", url.QueryEscape(req.GetModel()))}
   901  
   902  	hds = append(c.xGoogHeaders, hds...)
   903  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   904  	opts = append((*c.CallOptions).UpdateExplanationDataset[0:len((*c.CallOptions).UpdateExplanationDataset):len((*c.CallOptions).UpdateExplanationDataset)], opts...)
   905  	var resp *longrunningpb.Operation
   906  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   907  		var err error
   908  		resp, err = executeRPC(ctx, c.modelClient.UpdateExplanationDataset, req, settings.GRPC, c.logger, "UpdateExplanationDataset")
   909  		return err
   910  	}, opts...)
   911  	if err != nil {
   912  		return nil, err
   913  	}
   914  	return &UpdateExplanationDatasetOperation{
   915  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   916  	}, nil
   917  }
   918  
   919  func (c *modelGRPCClient) DeleteModel(ctx context.Context, req *aiplatformpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
   920  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   921  
   922  	hds = append(c.xGoogHeaders, hds...)
   923  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   924  	opts = append((*c.CallOptions).DeleteModel[0:len((*c.CallOptions).DeleteModel):len((*c.CallOptions).DeleteModel)], opts...)
   925  	var resp *longrunningpb.Operation
   926  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   927  		var err error
   928  		resp, err = executeRPC(ctx, c.modelClient.DeleteModel, req, settings.GRPC, c.logger, "DeleteModel")
   929  		return err
   930  	}, opts...)
   931  	if err != nil {
   932  		return nil, err
   933  	}
   934  	return &DeleteModelOperation{
   935  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   936  	}, nil
   937  }
   938  
   939  func (c *modelGRPCClient) DeleteModelVersion(ctx context.Context, req *aiplatformpb.DeleteModelVersionRequest, opts ...gax.CallOption) (*DeleteModelVersionOperation, error) {
   940  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   941  
   942  	hds = append(c.xGoogHeaders, hds...)
   943  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   944  	opts = append((*c.CallOptions).DeleteModelVersion[0:len((*c.CallOptions).DeleteModelVersion):len((*c.CallOptions).DeleteModelVersion)], opts...)
   945  	var resp *longrunningpb.Operation
   946  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   947  		var err error
   948  		resp, err = executeRPC(ctx, c.modelClient.DeleteModelVersion, req, settings.GRPC, c.logger, "DeleteModelVersion")
   949  		return err
   950  	}, opts...)
   951  	if err != nil {
   952  		return nil, err
   953  	}
   954  	return &DeleteModelVersionOperation{
   955  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   956  	}, nil
   957  }
   958  
   959  func (c *modelGRPCClient) MergeVersionAliases(ctx context.Context, req *aiplatformpb.MergeVersionAliasesRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
   960  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   961  
   962  	hds = append(c.xGoogHeaders, hds...)
   963  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   964  	opts = append((*c.CallOptions).MergeVersionAliases[0:len((*c.CallOptions).MergeVersionAliases):len((*c.CallOptions).MergeVersionAliases)], opts...)
   965  	var resp *aiplatformpb.Model
   966  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   967  		var err error
   968  		resp, err = executeRPC(ctx, c.modelClient.MergeVersionAliases, req, settings.GRPC, c.logger, "MergeVersionAliases")
   969  		return err
   970  	}, opts...)
   971  	if err != nil {
   972  		return nil, err
   973  	}
   974  	return resp, nil
   975  }
   976  
   977  func (c *modelGRPCClient) ExportModel(ctx context.Context, req *aiplatformpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
   978  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   979  
   980  	hds = append(c.xGoogHeaders, hds...)
   981  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   982  	opts = append((*c.CallOptions).ExportModel[0:len((*c.CallOptions).ExportModel):len((*c.CallOptions).ExportModel)], opts...)
   983  	var resp *longrunningpb.Operation
   984  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   985  		var err error
   986  		resp, err = executeRPC(ctx, c.modelClient.ExportModel, req, settings.GRPC, c.logger, "ExportModel")
   987  		return err
   988  	}, opts...)
   989  	if err != nil {
   990  		return nil, err
   991  	}
   992  	return &ExportModelOperation{
   993  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   994  	}, nil
   995  }
   996  
   997  func (c *modelGRPCClient) CopyModel(ctx context.Context, req *aiplatformpb.CopyModelRequest, opts ...gax.CallOption) (*CopyModelOperation, error) {
   998  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   999  
  1000  	hds = append(c.xGoogHeaders, hds...)
  1001  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1002  	opts = append((*c.CallOptions).CopyModel[0:len((*c.CallOptions).CopyModel):len((*c.CallOptions).CopyModel)], opts...)
  1003  	var resp *longrunningpb.Operation
  1004  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1005  		var err error
  1006  		resp, err = executeRPC(ctx, c.modelClient.CopyModel, req, settings.GRPC, c.logger, "CopyModel")
  1007  		return err
  1008  	}, opts...)
  1009  	if err != nil {
  1010  		return nil, err
  1011  	}
  1012  	return &CopyModelOperation{
  1013  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1014  	}, nil
  1015  }
  1016  
  1017  func (c *modelGRPCClient) ImportModelEvaluation(ctx context.Context, req *aiplatformpb.ImportModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
  1018  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1019  
  1020  	hds = append(c.xGoogHeaders, hds...)
  1021  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1022  	opts = append((*c.CallOptions).ImportModelEvaluation[0:len((*c.CallOptions).ImportModelEvaluation):len((*c.CallOptions).ImportModelEvaluation)], opts...)
  1023  	var resp *aiplatformpb.ModelEvaluation
  1024  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1025  		var err error
  1026  		resp, err = executeRPC(ctx, c.modelClient.ImportModelEvaluation, req, settings.GRPC, c.logger, "ImportModelEvaluation")
  1027  		return err
  1028  	}, opts...)
  1029  	if err != nil {
  1030  		return nil, err
  1031  	}
  1032  	return resp, nil
  1033  }
  1034  
  1035  func (c *modelGRPCClient) BatchImportModelEvaluationSlices(ctx context.Context, req *aiplatformpb.BatchImportModelEvaluationSlicesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error) {
  1036  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1037  
  1038  	hds = append(c.xGoogHeaders, hds...)
  1039  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1040  	opts = append((*c.CallOptions).BatchImportModelEvaluationSlices[0:len((*c.CallOptions).BatchImportModelEvaluationSlices):len((*c.CallOptions).BatchImportModelEvaluationSlices)], opts...)
  1041  	var resp *aiplatformpb.BatchImportModelEvaluationSlicesResponse
  1042  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1043  		var err error
  1044  		resp, err = executeRPC(ctx, c.modelClient.BatchImportModelEvaluationSlices, req, settings.GRPC, c.logger, "BatchImportModelEvaluationSlices")
  1045  		return err
  1046  	}, opts...)
  1047  	if err != nil {
  1048  		return nil, err
  1049  	}
  1050  	return resp, nil
  1051  }
  1052  
  1053  func (c *modelGRPCClient) BatchImportEvaluatedAnnotations(ctx context.Context, req *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error) {
  1054  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1055  
  1056  	hds = append(c.xGoogHeaders, hds...)
  1057  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1058  	opts = append((*c.CallOptions).BatchImportEvaluatedAnnotations[0:len((*c.CallOptions).BatchImportEvaluatedAnnotations):len((*c.CallOptions).BatchImportEvaluatedAnnotations)], opts...)
  1059  	var resp *aiplatformpb.BatchImportEvaluatedAnnotationsResponse
  1060  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1061  		var err error
  1062  		resp, err = executeRPC(ctx, c.modelClient.BatchImportEvaluatedAnnotations, req, settings.GRPC, c.logger, "BatchImportEvaluatedAnnotations")
  1063  		return err
  1064  	}, opts...)
  1065  	if err != nil {
  1066  		return nil, err
  1067  	}
  1068  	return resp, nil
  1069  }
  1070  
  1071  func (c *modelGRPCClient) GetModelEvaluation(ctx context.Context, req *aiplatformpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
  1072  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1073  
  1074  	hds = append(c.xGoogHeaders, hds...)
  1075  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1076  	opts = append((*c.CallOptions).GetModelEvaluation[0:len((*c.CallOptions).GetModelEvaluation):len((*c.CallOptions).GetModelEvaluation)], opts...)
  1077  	var resp *aiplatformpb.ModelEvaluation
  1078  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1079  		var err error
  1080  		resp, err = executeRPC(ctx, c.modelClient.GetModelEvaluation, req, settings.GRPC, c.logger, "GetModelEvaluation")
  1081  		return err
  1082  	}, opts...)
  1083  	if err != nil {
  1084  		return nil, err
  1085  	}
  1086  	return resp, nil
  1087  }
  1088  
  1089  func (c *modelGRPCClient) ListModelEvaluations(ctx context.Context, req *aiplatformpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
  1090  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1091  
  1092  	hds = append(c.xGoogHeaders, hds...)
  1093  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1094  	opts = append((*c.CallOptions).ListModelEvaluations[0:len((*c.CallOptions).ListModelEvaluations):len((*c.CallOptions).ListModelEvaluations)], opts...)
  1095  	it := &ModelEvaluationIterator{}
  1096  	req = proto.Clone(req).(*aiplatformpb.ListModelEvaluationsRequest)
  1097  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelEvaluation, string, error) {
  1098  		resp := &aiplatformpb.ListModelEvaluationsResponse{}
  1099  		if pageToken != "" {
  1100  			req.PageToken = pageToken
  1101  		}
  1102  		if pageSize > math.MaxInt32 {
  1103  			req.PageSize = math.MaxInt32
  1104  		} else if pageSize != 0 {
  1105  			req.PageSize = int32(pageSize)
  1106  		}
  1107  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1108  			var err error
  1109  			resp, err = executeRPC(ctx, c.modelClient.ListModelEvaluations, req, settings.GRPC, c.logger, "ListModelEvaluations")
  1110  			return err
  1111  		}, opts...)
  1112  		if err != nil {
  1113  			return nil, "", err
  1114  		}
  1115  
  1116  		it.Response = resp
  1117  		return resp.GetModelEvaluations(), resp.GetNextPageToken(), nil
  1118  	}
  1119  	fetch := func(pageSize int, pageToken string) (string, error) {
  1120  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1121  		if err != nil {
  1122  			return "", err
  1123  		}
  1124  		it.items = append(it.items, items...)
  1125  		return nextPageToken, nil
  1126  	}
  1127  
  1128  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1129  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1130  	it.pageInfo.Token = req.GetPageToken()
  1131  
  1132  	return it
  1133  }
  1134  
  1135  func (c *modelGRPCClient) GetModelEvaluationSlice(ctx context.Context, req *aiplatformpb.GetModelEvaluationSliceRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error) {
  1136  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1137  
  1138  	hds = append(c.xGoogHeaders, hds...)
  1139  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1140  	opts = append((*c.CallOptions).GetModelEvaluationSlice[0:len((*c.CallOptions).GetModelEvaluationSlice):len((*c.CallOptions).GetModelEvaluationSlice)], opts...)
  1141  	var resp *aiplatformpb.ModelEvaluationSlice
  1142  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1143  		var err error
  1144  		resp, err = executeRPC(ctx, c.modelClient.GetModelEvaluationSlice, req, settings.GRPC, c.logger, "GetModelEvaluationSlice")
  1145  		return err
  1146  	}, opts...)
  1147  	if err != nil {
  1148  		return nil, err
  1149  	}
  1150  	return resp, nil
  1151  }
  1152  
  1153  func (c *modelGRPCClient) ListModelEvaluationSlices(ctx context.Context, req *aiplatformpb.ListModelEvaluationSlicesRequest, opts ...gax.CallOption) *ModelEvaluationSliceIterator {
  1154  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1155  
  1156  	hds = append(c.xGoogHeaders, hds...)
  1157  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1158  	opts = append((*c.CallOptions).ListModelEvaluationSlices[0:len((*c.CallOptions).ListModelEvaluationSlices):len((*c.CallOptions).ListModelEvaluationSlices)], opts...)
  1159  	it := &ModelEvaluationSliceIterator{}
  1160  	req = proto.Clone(req).(*aiplatformpb.ListModelEvaluationSlicesRequest)
  1161  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelEvaluationSlice, string, error) {
  1162  		resp := &aiplatformpb.ListModelEvaluationSlicesResponse{}
  1163  		if pageToken != "" {
  1164  			req.PageToken = pageToken
  1165  		}
  1166  		if pageSize > math.MaxInt32 {
  1167  			req.PageSize = math.MaxInt32
  1168  		} else if pageSize != 0 {
  1169  			req.PageSize = int32(pageSize)
  1170  		}
  1171  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1172  			var err error
  1173  			resp, err = executeRPC(ctx, c.modelClient.ListModelEvaluationSlices, req, settings.GRPC, c.logger, "ListModelEvaluationSlices")
  1174  			return err
  1175  		}, opts...)
  1176  		if err != nil {
  1177  			return nil, "", err
  1178  		}
  1179  
  1180  		it.Response = resp
  1181  		return resp.GetModelEvaluationSlices(), resp.GetNextPageToken(), nil
  1182  	}
  1183  	fetch := func(pageSize int, pageToken string) (string, error) {
  1184  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1185  		if err != nil {
  1186  			return "", err
  1187  		}
  1188  		it.items = append(it.items, items...)
  1189  		return nextPageToken, nil
  1190  	}
  1191  
  1192  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1193  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1194  	it.pageInfo.Token = req.GetPageToken()
  1195  
  1196  	return it
  1197  }
  1198  
  1199  func (c *modelGRPCClient) RecommendSpec(ctx context.Context, req *aiplatformpb.RecommendSpecRequest, opts ...gax.CallOption) (*aiplatformpb.RecommendSpecResponse, error) {
  1200  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1201  
  1202  	hds = append(c.xGoogHeaders, hds...)
  1203  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1204  	opts = append((*c.CallOptions).RecommendSpec[0:len((*c.CallOptions).RecommendSpec):len((*c.CallOptions).RecommendSpec)], opts...)
  1205  	var resp *aiplatformpb.RecommendSpecResponse
  1206  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1207  		var err error
  1208  		resp, err = executeRPC(ctx, c.modelClient.RecommendSpec, req, settings.GRPC, c.logger, "RecommendSpec")
  1209  		return err
  1210  	}, opts...)
  1211  	if err != nil {
  1212  		return nil, err
  1213  	}
  1214  	return resp, nil
  1215  }
  1216  
  1217  func (c *modelGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1218  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1219  
  1220  	hds = append(c.xGoogHeaders, hds...)
  1221  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1222  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1223  	var resp *locationpb.Location
  1224  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1225  		var err error
  1226  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
  1227  		return err
  1228  	}, opts...)
  1229  	if err != nil {
  1230  		return nil, err
  1231  	}
  1232  	return resp, nil
  1233  }
  1234  
  1235  func (c *modelGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1236  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1237  
  1238  	hds = append(c.xGoogHeaders, hds...)
  1239  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1240  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
  1241  	it := &LocationIterator{}
  1242  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1243  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1244  		resp := &locationpb.ListLocationsResponse{}
  1245  		if pageToken != "" {
  1246  			req.PageToken = pageToken
  1247  		}
  1248  		if pageSize > math.MaxInt32 {
  1249  			req.PageSize = math.MaxInt32
  1250  		} else if pageSize != 0 {
  1251  			req.PageSize = int32(pageSize)
  1252  		}
  1253  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1254  			var err error
  1255  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
  1256  			return err
  1257  		}, opts...)
  1258  		if err != nil {
  1259  			return nil, "", err
  1260  		}
  1261  
  1262  		it.Response = resp
  1263  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1264  	}
  1265  	fetch := func(pageSize int, pageToken string) (string, error) {
  1266  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1267  		if err != nil {
  1268  			return "", err
  1269  		}
  1270  		it.items = append(it.items, items...)
  1271  		return nextPageToken, nil
  1272  	}
  1273  
  1274  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1275  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1276  	it.pageInfo.Token = req.GetPageToken()
  1277  
  1278  	return it
  1279  }
  1280  
  1281  func (c *modelGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1282  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1283  
  1284  	hds = append(c.xGoogHeaders, hds...)
  1285  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1286  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1287  	var resp *iampb.Policy
  1288  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1289  		var err error
  1290  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
  1291  		return err
  1292  	}, opts...)
  1293  	if err != nil {
  1294  		return nil, err
  1295  	}
  1296  	return resp, nil
  1297  }
  1298  
  1299  func (c *modelGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1300  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1301  
  1302  	hds = append(c.xGoogHeaders, hds...)
  1303  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1304  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1305  	var resp *iampb.Policy
  1306  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1307  		var err error
  1308  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
  1309  		return err
  1310  	}, opts...)
  1311  	if err != nil {
  1312  		return nil, err
  1313  	}
  1314  	return resp, nil
  1315  }
  1316  
  1317  func (c *modelGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1318  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1319  
  1320  	hds = append(c.xGoogHeaders, hds...)
  1321  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1322  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1323  	var resp *iampb.TestIamPermissionsResponse
  1324  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1325  		var err error
  1326  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
  1327  		return err
  1328  	}, opts...)
  1329  	if err != nil {
  1330  		return nil, err
  1331  	}
  1332  	return resp, nil
  1333  }
  1334  
  1335  func (c *modelGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1336  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1337  
  1338  	hds = append(c.xGoogHeaders, hds...)
  1339  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1340  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
  1341  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1342  		var err error
  1343  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
  1344  		return err
  1345  	}, opts...)
  1346  	return err
  1347  }
  1348  
  1349  func (c *modelGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1350  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1351  
  1352  	hds = append(c.xGoogHeaders, hds...)
  1353  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1354  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
  1355  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1356  		var err error
  1357  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
  1358  		return err
  1359  	}, opts...)
  1360  	return err
  1361  }
  1362  
  1363  func (c *modelGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1364  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1365  
  1366  	hds = append(c.xGoogHeaders, hds...)
  1367  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1368  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1369  	var resp *longrunningpb.Operation
  1370  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1371  		var err error
  1372  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
  1373  		return err
  1374  	}, opts...)
  1375  	if err != nil {
  1376  		return nil, err
  1377  	}
  1378  	return resp, nil
  1379  }
  1380  
  1381  func (c *modelGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1382  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1383  
  1384  	hds = append(c.xGoogHeaders, hds...)
  1385  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1386  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
  1387  	it := &OperationIterator{}
  1388  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1389  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1390  		resp := &longrunningpb.ListOperationsResponse{}
  1391  		if pageToken != "" {
  1392  			req.PageToken = pageToken
  1393  		}
  1394  		if pageSize > math.MaxInt32 {
  1395  			req.PageSize = math.MaxInt32
  1396  		} else if pageSize != 0 {
  1397  			req.PageSize = int32(pageSize)
  1398  		}
  1399  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1400  			var err error
  1401  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
  1402  			return err
  1403  		}, opts...)
  1404  		if err != nil {
  1405  			return nil, "", err
  1406  		}
  1407  
  1408  		it.Response = resp
  1409  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1410  	}
  1411  	fetch := func(pageSize int, pageToken string) (string, error) {
  1412  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1413  		if err != nil {
  1414  			return "", err
  1415  		}
  1416  		it.items = append(it.items, items...)
  1417  		return nextPageToken, nil
  1418  	}
  1419  
  1420  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1421  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1422  	it.pageInfo.Token = req.GetPageToken()
  1423  
  1424  	return it
  1425  }
  1426  
  1427  func (c *modelGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1428  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1429  
  1430  	hds = append(c.xGoogHeaders, hds...)
  1431  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1432  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1433  	var resp *longrunningpb.Operation
  1434  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1435  		var err error
  1436  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
  1437  		return err
  1438  	}, opts...)
  1439  	if err != nil {
  1440  		return nil, err
  1441  	}
  1442  	return resp, nil
  1443  }
  1444  
  1445  // UploadModel uploads a Model artifact into Vertex AI.
  1446  func (c *modelRESTClient) UploadModel(ctx context.Context, req *aiplatformpb.UploadModelRequest, opts ...gax.CallOption) (*UploadModelOperation, error) {
  1447  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1448  	jsonReq, err := m.Marshal(req)
  1449  	if err != nil {
  1450  		return nil, err
  1451  	}
  1452  
  1453  	baseUrl, err := url.Parse(c.endpoint)
  1454  	if err != nil {
  1455  		return nil, err
  1456  	}
  1457  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/models:upload", req.GetParent())
  1458  
  1459  	params := url.Values{}
  1460  	params.Add("$alt", "json;enum-encoding=int")
  1461  
  1462  	baseUrl.RawQuery = params.Encode()
  1463  
  1464  	// Build HTTP headers from client and context metadata.
  1465  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1466  
  1467  	hds = append(c.xGoogHeaders, hds...)
  1468  	hds = append(hds, "Content-Type", "application/json")
  1469  	headers := gax.BuildHeaders(ctx, hds...)
  1470  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1471  	resp := &longrunningpb.Operation{}
  1472  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1473  		if settings.Path != "" {
  1474  			baseUrl.Path = settings.Path
  1475  		}
  1476  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1477  		if err != nil {
  1478  			return err
  1479  		}
  1480  		httpReq = httpReq.WithContext(ctx)
  1481  		httpReq.Header = headers
  1482  
  1483  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UploadModel")
  1484  		if err != nil {
  1485  			return err
  1486  		}
  1487  		if err := unm.Unmarshal(buf, resp); err != nil {
  1488  			return err
  1489  		}
  1490  
  1491  		return nil
  1492  	}, opts...)
  1493  	if e != nil {
  1494  		return nil, e
  1495  	}
  1496  
  1497  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1498  	return &UploadModelOperation{
  1499  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1500  		pollPath: override,
  1501  	}, nil
  1502  }
  1503  
  1504  // GetModel gets a Model.
  1505  func (c *modelRESTClient) GetModel(ctx context.Context, req *aiplatformpb.GetModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
  1506  	baseUrl, err := url.Parse(c.endpoint)
  1507  	if err != nil {
  1508  		return nil, err
  1509  	}
  1510  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1511  
  1512  	params := url.Values{}
  1513  	params.Add("$alt", "json;enum-encoding=int")
  1514  
  1515  	baseUrl.RawQuery = params.Encode()
  1516  
  1517  	// Build HTTP headers from client and context metadata.
  1518  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1519  
  1520  	hds = append(c.xGoogHeaders, hds...)
  1521  	hds = append(hds, "Content-Type", "application/json")
  1522  	headers := gax.BuildHeaders(ctx, hds...)
  1523  	opts = append((*c.CallOptions).GetModel[0:len((*c.CallOptions).GetModel):len((*c.CallOptions).GetModel)], opts...)
  1524  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1525  	resp := &aiplatformpb.Model{}
  1526  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1527  		if settings.Path != "" {
  1528  			baseUrl.Path = settings.Path
  1529  		}
  1530  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1531  		if err != nil {
  1532  			return err
  1533  		}
  1534  		httpReq = httpReq.WithContext(ctx)
  1535  		httpReq.Header = headers
  1536  
  1537  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetModel")
  1538  		if err != nil {
  1539  			return err
  1540  		}
  1541  
  1542  		if err := unm.Unmarshal(buf, resp); err != nil {
  1543  			return err
  1544  		}
  1545  
  1546  		return nil
  1547  	}, opts...)
  1548  	if e != nil {
  1549  		return nil, e
  1550  	}
  1551  	return resp, nil
  1552  }
  1553  
  1554  // ListModels lists Models in a Location.
  1555  func (c *modelRESTClient) ListModels(ctx context.Context, req *aiplatformpb.ListModelsRequest, opts ...gax.CallOption) *ModelIterator {
  1556  	it := &ModelIterator{}
  1557  	req = proto.Clone(req).(*aiplatformpb.ListModelsRequest)
  1558  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1559  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Model, string, error) {
  1560  		resp := &aiplatformpb.ListModelsResponse{}
  1561  		if pageToken != "" {
  1562  			req.PageToken = pageToken
  1563  		}
  1564  		if pageSize > math.MaxInt32 {
  1565  			req.PageSize = math.MaxInt32
  1566  		} else if pageSize != 0 {
  1567  			req.PageSize = int32(pageSize)
  1568  		}
  1569  		baseUrl, err := url.Parse(c.endpoint)
  1570  		if err != nil {
  1571  			return nil, "", err
  1572  		}
  1573  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/models", req.GetParent())
  1574  
  1575  		params := url.Values{}
  1576  		params.Add("$alt", "json;enum-encoding=int")
  1577  		if req.GetFilter() != "" {
  1578  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1579  		}
  1580  		if req.GetPageSize() != 0 {
  1581  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1582  		}
  1583  		if req.GetPageToken() != "" {
  1584  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1585  		}
  1586  		if req.GetReadMask() != nil {
  1587  			field, err := protojson.Marshal(req.GetReadMask())
  1588  			if err != nil {
  1589  				return nil, "", err
  1590  			}
  1591  			params.Add("readMask", string(field[1:len(field)-1]))
  1592  		}
  1593  
  1594  		baseUrl.RawQuery = params.Encode()
  1595  
  1596  		// Build HTTP headers from client and context metadata.
  1597  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1598  		headers := gax.BuildHeaders(ctx, hds...)
  1599  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1600  			if settings.Path != "" {
  1601  				baseUrl.Path = settings.Path
  1602  			}
  1603  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1604  			if err != nil {
  1605  				return err
  1606  			}
  1607  			httpReq.Header = headers
  1608  
  1609  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModels")
  1610  			if err != nil {
  1611  				return err
  1612  			}
  1613  			if err := unm.Unmarshal(buf, resp); err != nil {
  1614  				return err
  1615  			}
  1616  
  1617  			return nil
  1618  		}, opts...)
  1619  		if e != nil {
  1620  			return nil, "", e
  1621  		}
  1622  		it.Response = resp
  1623  		return resp.GetModels(), resp.GetNextPageToken(), nil
  1624  	}
  1625  
  1626  	fetch := func(pageSize int, pageToken string) (string, error) {
  1627  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1628  		if err != nil {
  1629  			return "", err
  1630  		}
  1631  		it.items = append(it.items, items...)
  1632  		return nextPageToken, nil
  1633  	}
  1634  
  1635  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1636  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1637  	it.pageInfo.Token = req.GetPageToken()
  1638  
  1639  	return it
  1640  }
  1641  
  1642  // ListModelVersions lists versions of the specified model.
  1643  func (c *modelRESTClient) ListModelVersions(ctx context.Context, req *aiplatformpb.ListModelVersionsRequest, opts ...gax.CallOption) *ModelIterator {
  1644  	it := &ModelIterator{}
  1645  	req = proto.Clone(req).(*aiplatformpb.ListModelVersionsRequest)
  1646  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1647  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Model, string, error) {
  1648  		resp := &aiplatformpb.ListModelVersionsResponse{}
  1649  		if pageToken != "" {
  1650  			req.PageToken = pageToken
  1651  		}
  1652  		if pageSize > math.MaxInt32 {
  1653  			req.PageSize = math.MaxInt32
  1654  		} else if pageSize != 0 {
  1655  			req.PageSize = int32(pageSize)
  1656  		}
  1657  		baseUrl, err := url.Parse(c.endpoint)
  1658  		if err != nil {
  1659  			return nil, "", err
  1660  		}
  1661  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v:listVersions", req.GetName())
  1662  
  1663  		params := url.Values{}
  1664  		params.Add("$alt", "json;enum-encoding=int")
  1665  		if req.GetFilter() != "" {
  1666  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1667  		}
  1668  		if req.GetOrderBy() != "" {
  1669  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  1670  		}
  1671  		if req.GetPageSize() != 0 {
  1672  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1673  		}
  1674  		if req.GetPageToken() != "" {
  1675  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1676  		}
  1677  		if req.GetReadMask() != nil {
  1678  			field, err := protojson.Marshal(req.GetReadMask())
  1679  			if err != nil {
  1680  				return nil, "", err
  1681  			}
  1682  			params.Add("readMask", string(field[1:len(field)-1]))
  1683  		}
  1684  
  1685  		baseUrl.RawQuery = params.Encode()
  1686  
  1687  		// Build HTTP headers from client and context metadata.
  1688  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1689  		headers := gax.BuildHeaders(ctx, hds...)
  1690  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1691  			if settings.Path != "" {
  1692  				baseUrl.Path = settings.Path
  1693  			}
  1694  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1695  			if err != nil {
  1696  				return err
  1697  			}
  1698  			httpReq.Header = headers
  1699  
  1700  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModelVersions")
  1701  			if err != nil {
  1702  				return err
  1703  			}
  1704  			if err := unm.Unmarshal(buf, resp); err != nil {
  1705  				return err
  1706  			}
  1707  
  1708  			return nil
  1709  		}, opts...)
  1710  		if e != nil {
  1711  			return nil, "", e
  1712  		}
  1713  		it.Response = resp
  1714  		return resp.GetModels(), resp.GetNextPageToken(), nil
  1715  	}
  1716  
  1717  	fetch := func(pageSize int, pageToken string) (string, error) {
  1718  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1719  		if err != nil {
  1720  			return "", err
  1721  		}
  1722  		it.items = append(it.items, items...)
  1723  		return nextPageToken, nil
  1724  	}
  1725  
  1726  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1727  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1728  	it.pageInfo.Token = req.GetPageToken()
  1729  
  1730  	return it
  1731  }
  1732  
  1733  // ListModelVersionCheckpoints lists checkpoints of the specified model version.
  1734  func (c *modelRESTClient) ListModelVersionCheckpoints(ctx context.Context, req *aiplatformpb.ListModelVersionCheckpointsRequest, opts ...gax.CallOption) *ModelVersionCheckpointIterator {
  1735  	it := &ModelVersionCheckpointIterator{}
  1736  	req = proto.Clone(req).(*aiplatformpb.ListModelVersionCheckpointsRequest)
  1737  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1738  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelVersionCheckpoint, string, error) {
  1739  		resp := &aiplatformpb.ListModelVersionCheckpointsResponse{}
  1740  		if pageToken != "" {
  1741  			req.PageToken = pageToken
  1742  		}
  1743  		if pageSize > math.MaxInt32 {
  1744  			req.PageSize = math.MaxInt32
  1745  		} else if pageSize != 0 {
  1746  			req.PageSize = int32(pageSize)
  1747  		}
  1748  		baseUrl, err := url.Parse(c.endpoint)
  1749  		if err != nil {
  1750  			return nil, "", err
  1751  		}
  1752  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v:listCheckpoints", req.GetName())
  1753  
  1754  		params := url.Values{}
  1755  		params.Add("$alt", "json;enum-encoding=int")
  1756  		if req.GetPageSize() != 0 {
  1757  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1758  		}
  1759  		if req.GetPageToken() != "" {
  1760  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1761  		}
  1762  
  1763  		baseUrl.RawQuery = params.Encode()
  1764  
  1765  		// Build HTTP headers from client and context metadata.
  1766  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1767  		headers := gax.BuildHeaders(ctx, hds...)
  1768  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1769  			if settings.Path != "" {
  1770  				baseUrl.Path = settings.Path
  1771  			}
  1772  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1773  			if err != nil {
  1774  				return err
  1775  			}
  1776  			httpReq.Header = headers
  1777  
  1778  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModelVersionCheckpoints")
  1779  			if err != nil {
  1780  				return err
  1781  			}
  1782  			if err := unm.Unmarshal(buf, resp); err != nil {
  1783  				return err
  1784  			}
  1785  
  1786  			return nil
  1787  		}, opts...)
  1788  		if e != nil {
  1789  			return nil, "", e
  1790  		}
  1791  		it.Response = resp
  1792  		return resp.GetCheckpoints(), resp.GetNextPageToken(), nil
  1793  	}
  1794  
  1795  	fetch := func(pageSize int, pageToken string) (string, error) {
  1796  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1797  		if err != nil {
  1798  			return "", err
  1799  		}
  1800  		it.items = append(it.items, items...)
  1801  		return nextPageToken, nil
  1802  	}
  1803  
  1804  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1805  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1806  	it.pageInfo.Token = req.GetPageToken()
  1807  
  1808  	return it
  1809  }
  1810  
  1811  // UpdateModel updates a Model.
  1812  func (c *modelRESTClient) UpdateModel(ctx context.Context, req *aiplatformpb.UpdateModelRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
  1813  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1814  	body := req.GetModel()
  1815  	jsonReq, err := m.Marshal(body)
  1816  	if err != nil {
  1817  		return nil, err
  1818  	}
  1819  
  1820  	baseUrl, err := url.Parse(c.endpoint)
  1821  	if err != nil {
  1822  		return nil, err
  1823  	}
  1824  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetModel().GetName())
  1825  
  1826  	params := url.Values{}
  1827  	params.Add("$alt", "json;enum-encoding=int")
  1828  	if req.GetUpdateMask() != nil {
  1829  		field, err := protojson.Marshal(req.GetUpdateMask())
  1830  		if err != nil {
  1831  			return nil, err
  1832  		}
  1833  		params.Add("updateMask", string(field[1:len(field)-1]))
  1834  	}
  1835  
  1836  	baseUrl.RawQuery = params.Encode()
  1837  
  1838  	// Build HTTP headers from client and context metadata.
  1839  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model.name", url.QueryEscape(req.GetModel().GetName()))}
  1840  
  1841  	hds = append(c.xGoogHeaders, hds...)
  1842  	hds = append(hds, "Content-Type", "application/json")
  1843  	headers := gax.BuildHeaders(ctx, hds...)
  1844  	opts = append((*c.CallOptions).UpdateModel[0:len((*c.CallOptions).UpdateModel):len((*c.CallOptions).UpdateModel)], opts...)
  1845  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1846  	resp := &aiplatformpb.Model{}
  1847  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1848  		if settings.Path != "" {
  1849  			baseUrl.Path = settings.Path
  1850  		}
  1851  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  1852  		if err != nil {
  1853  			return err
  1854  		}
  1855  		httpReq = httpReq.WithContext(ctx)
  1856  		httpReq.Header = headers
  1857  
  1858  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateModel")
  1859  		if err != nil {
  1860  			return err
  1861  		}
  1862  
  1863  		if err := unm.Unmarshal(buf, resp); err != nil {
  1864  			return err
  1865  		}
  1866  
  1867  		return nil
  1868  	}, opts...)
  1869  	if e != nil {
  1870  		return nil, e
  1871  	}
  1872  	return resp, nil
  1873  }
  1874  
  1875  // UpdateExplanationDataset incrementally update the dataset used for an examples model.
  1876  func (c *modelRESTClient) UpdateExplanationDataset(ctx context.Context, req *aiplatformpb.UpdateExplanationDatasetRequest, opts ...gax.CallOption) (*UpdateExplanationDatasetOperation, error) {
  1877  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1878  	jsonReq, err := m.Marshal(req)
  1879  	if err != nil {
  1880  		return nil, err
  1881  	}
  1882  
  1883  	baseUrl, err := url.Parse(c.endpoint)
  1884  	if err != nil {
  1885  		return nil, err
  1886  	}
  1887  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:updateExplanationDataset", req.GetModel())
  1888  
  1889  	params := url.Values{}
  1890  	params.Add("$alt", "json;enum-encoding=int")
  1891  
  1892  	baseUrl.RawQuery = params.Encode()
  1893  
  1894  	// Build HTTP headers from client and context metadata.
  1895  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "model", url.QueryEscape(req.GetModel()))}
  1896  
  1897  	hds = append(c.xGoogHeaders, hds...)
  1898  	hds = append(hds, "Content-Type", "application/json")
  1899  	headers := gax.BuildHeaders(ctx, hds...)
  1900  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1901  	resp := &longrunningpb.Operation{}
  1902  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1903  		if settings.Path != "" {
  1904  			baseUrl.Path = settings.Path
  1905  		}
  1906  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1907  		if err != nil {
  1908  			return err
  1909  		}
  1910  		httpReq = httpReq.WithContext(ctx)
  1911  		httpReq.Header = headers
  1912  
  1913  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateExplanationDataset")
  1914  		if err != nil {
  1915  			return err
  1916  		}
  1917  		if err := unm.Unmarshal(buf, resp); err != nil {
  1918  			return err
  1919  		}
  1920  
  1921  		return nil
  1922  	}, opts...)
  1923  	if e != nil {
  1924  		return nil, e
  1925  	}
  1926  
  1927  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1928  	return &UpdateExplanationDatasetOperation{
  1929  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1930  		pollPath: override,
  1931  	}, nil
  1932  }
  1933  
  1934  // DeleteModel deletes a Model.
  1935  //
  1936  // A model cannot be deleted if any
  1937  // Endpoint resource has a
  1938  // DeployedModel based on the
  1939  // model in its
  1940  // deployed_models
  1941  // field.
  1942  func (c *modelRESTClient) DeleteModel(ctx context.Context, req *aiplatformpb.DeleteModelRequest, opts ...gax.CallOption) (*DeleteModelOperation, error) {
  1943  	baseUrl, err := url.Parse(c.endpoint)
  1944  	if err != nil {
  1945  		return nil, err
  1946  	}
  1947  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1948  
  1949  	params := url.Values{}
  1950  	params.Add("$alt", "json;enum-encoding=int")
  1951  
  1952  	baseUrl.RawQuery = params.Encode()
  1953  
  1954  	// Build HTTP headers from client and context metadata.
  1955  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1956  
  1957  	hds = append(c.xGoogHeaders, hds...)
  1958  	hds = append(hds, "Content-Type", "application/json")
  1959  	headers := gax.BuildHeaders(ctx, hds...)
  1960  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1961  	resp := &longrunningpb.Operation{}
  1962  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1963  		if settings.Path != "" {
  1964  			baseUrl.Path = settings.Path
  1965  		}
  1966  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1967  		if err != nil {
  1968  			return err
  1969  		}
  1970  		httpReq = httpReq.WithContext(ctx)
  1971  		httpReq.Header = headers
  1972  
  1973  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteModel")
  1974  		if err != nil {
  1975  			return err
  1976  		}
  1977  		if err := unm.Unmarshal(buf, resp); err != nil {
  1978  			return err
  1979  		}
  1980  
  1981  		return nil
  1982  	}, opts...)
  1983  	if e != nil {
  1984  		return nil, e
  1985  	}
  1986  
  1987  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1988  	return &DeleteModelOperation{
  1989  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1990  		pollPath: override,
  1991  	}, nil
  1992  }
  1993  
  1994  // DeleteModelVersion deletes a Model version.
  1995  //
  1996  // Model version can only be deleted if there are no
  1997  // DeployedModels created
  1998  // from it. Deleting the only version in the Model is not allowed. Use
  1999  // DeleteModel for
  2000  // deleting the Model instead.
  2001  func (c *modelRESTClient) DeleteModelVersion(ctx context.Context, req *aiplatformpb.DeleteModelVersionRequest, opts ...gax.CallOption) (*DeleteModelVersionOperation, error) {
  2002  	baseUrl, err := url.Parse(c.endpoint)
  2003  	if err != nil {
  2004  		return nil, err
  2005  	}
  2006  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:deleteVersion", req.GetName())
  2007  
  2008  	params := url.Values{}
  2009  	params.Add("$alt", "json;enum-encoding=int")
  2010  
  2011  	baseUrl.RawQuery = params.Encode()
  2012  
  2013  	// Build HTTP headers from client and context metadata.
  2014  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2015  
  2016  	hds = append(c.xGoogHeaders, hds...)
  2017  	hds = append(hds, "Content-Type", "application/json")
  2018  	headers := gax.BuildHeaders(ctx, hds...)
  2019  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2020  	resp := &longrunningpb.Operation{}
  2021  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2022  		if settings.Path != "" {
  2023  			baseUrl.Path = settings.Path
  2024  		}
  2025  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2026  		if err != nil {
  2027  			return err
  2028  		}
  2029  		httpReq = httpReq.WithContext(ctx)
  2030  		httpReq.Header = headers
  2031  
  2032  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteModelVersion")
  2033  		if err != nil {
  2034  			return err
  2035  		}
  2036  		if err := unm.Unmarshal(buf, resp); err != nil {
  2037  			return err
  2038  		}
  2039  
  2040  		return nil
  2041  	}, opts...)
  2042  	if e != nil {
  2043  		return nil, e
  2044  	}
  2045  
  2046  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2047  	return &DeleteModelVersionOperation{
  2048  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2049  		pollPath: override,
  2050  	}, nil
  2051  }
  2052  
  2053  // MergeVersionAliases merges a set of aliases for a Model version.
  2054  func (c *modelRESTClient) MergeVersionAliases(ctx context.Context, req *aiplatformpb.MergeVersionAliasesRequest, opts ...gax.CallOption) (*aiplatformpb.Model, error) {
  2055  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2056  	jsonReq, err := m.Marshal(req)
  2057  	if err != nil {
  2058  		return nil, err
  2059  	}
  2060  
  2061  	baseUrl, err := url.Parse(c.endpoint)
  2062  	if err != nil {
  2063  		return nil, err
  2064  	}
  2065  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:mergeVersionAliases", req.GetName())
  2066  
  2067  	params := url.Values{}
  2068  	params.Add("$alt", "json;enum-encoding=int")
  2069  
  2070  	baseUrl.RawQuery = params.Encode()
  2071  
  2072  	// Build HTTP headers from client and context metadata.
  2073  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2074  
  2075  	hds = append(c.xGoogHeaders, hds...)
  2076  	hds = append(hds, "Content-Type", "application/json")
  2077  	headers := gax.BuildHeaders(ctx, hds...)
  2078  	opts = append((*c.CallOptions).MergeVersionAliases[0:len((*c.CallOptions).MergeVersionAliases):len((*c.CallOptions).MergeVersionAliases)], opts...)
  2079  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2080  	resp := &aiplatformpb.Model{}
  2081  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2082  		if settings.Path != "" {
  2083  			baseUrl.Path = settings.Path
  2084  		}
  2085  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2086  		if err != nil {
  2087  			return err
  2088  		}
  2089  		httpReq = httpReq.WithContext(ctx)
  2090  		httpReq.Header = headers
  2091  
  2092  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "MergeVersionAliases")
  2093  		if err != nil {
  2094  			return err
  2095  		}
  2096  
  2097  		if err := unm.Unmarshal(buf, resp); err != nil {
  2098  			return err
  2099  		}
  2100  
  2101  		return nil
  2102  	}, opts...)
  2103  	if e != nil {
  2104  		return nil, e
  2105  	}
  2106  	return resp, nil
  2107  }
  2108  
  2109  // ExportModel exports a trained, exportable Model to a location specified by the
  2110  // user. A Model is considered to be exportable if it has at least one
  2111  // [supported export
  2112  // format][google.cloud.aiplatform.v1beta1.Model.supported_export_formats].
  2113  func (c *modelRESTClient) ExportModel(ctx context.Context, req *aiplatformpb.ExportModelRequest, opts ...gax.CallOption) (*ExportModelOperation, error) {
  2114  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2115  	jsonReq, err := m.Marshal(req)
  2116  	if err != nil {
  2117  		return nil, err
  2118  	}
  2119  
  2120  	baseUrl, err := url.Parse(c.endpoint)
  2121  	if err != nil {
  2122  		return nil, err
  2123  	}
  2124  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:export", req.GetName())
  2125  
  2126  	params := url.Values{}
  2127  	params.Add("$alt", "json;enum-encoding=int")
  2128  
  2129  	baseUrl.RawQuery = params.Encode()
  2130  
  2131  	// Build HTTP headers from client and context metadata.
  2132  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2133  
  2134  	hds = append(c.xGoogHeaders, hds...)
  2135  	hds = append(hds, "Content-Type", "application/json")
  2136  	headers := gax.BuildHeaders(ctx, hds...)
  2137  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2138  	resp := &longrunningpb.Operation{}
  2139  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2140  		if settings.Path != "" {
  2141  			baseUrl.Path = settings.Path
  2142  		}
  2143  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2144  		if err != nil {
  2145  			return err
  2146  		}
  2147  		httpReq = httpReq.WithContext(ctx)
  2148  		httpReq.Header = headers
  2149  
  2150  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ExportModel")
  2151  		if err != nil {
  2152  			return err
  2153  		}
  2154  		if err := unm.Unmarshal(buf, resp); err != nil {
  2155  			return err
  2156  		}
  2157  
  2158  		return nil
  2159  	}, opts...)
  2160  	if e != nil {
  2161  		return nil, e
  2162  	}
  2163  
  2164  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2165  	return &ExportModelOperation{
  2166  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2167  		pollPath: override,
  2168  	}, nil
  2169  }
  2170  
  2171  // CopyModel copies an already existing Vertex AI Model into the specified Location.
  2172  // The source Model must exist in the same Project.
  2173  // When copying custom Models, the users themselves are responsible for
  2174  // Model.metadata content to
  2175  // be region-agnostic, as well as making sure that any resources (e.g. files)
  2176  // it depends on remain accessible.
  2177  func (c *modelRESTClient) CopyModel(ctx context.Context, req *aiplatformpb.CopyModelRequest, opts ...gax.CallOption) (*CopyModelOperation, error) {
  2178  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2179  	jsonReq, err := m.Marshal(req)
  2180  	if err != nil {
  2181  		return nil, err
  2182  	}
  2183  
  2184  	baseUrl, err := url.Parse(c.endpoint)
  2185  	if err != nil {
  2186  		return nil, err
  2187  	}
  2188  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/models:copy", req.GetParent())
  2189  
  2190  	params := url.Values{}
  2191  	params.Add("$alt", "json;enum-encoding=int")
  2192  
  2193  	baseUrl.RawQuery = params.Encode()
  2194  
  2195  	// Build HTTP headers from client and context metadata.
  2196  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2197  
  2198  	hds = append(c.xGoogHeaders, hds...)
  2199  	hds = append(hds, "Content-Type", "application/json")
  2200  	headers := gax.BuildHeaders(ctx, hds...)
  2201  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2202  	resp := &longrunningpb.Operation{}
  2203  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2204  		if settings.Path != "" {
  2205  			baseUrl.Path = settings.Path
  2206  		}
  2207  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2208  		if err != nil {
  2209  			return err
  2210  		}
  2211  		httpReq = httpReq.WithContext(ctx)
  2212  		httpReq.Header = headers
  2213  
  2214  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CopyModel")
  2215  		if err != nil {
  2216  			return err
  2217  		}
  2218  		if err := unm.Unmarshal(buf, resp); err != nil {
  2219  			return err
  2220  		}
  2221  
  2222  		return nil
  2223  	}, opts...)
  2224  	if e != nil {
  2225  		return nil, e
  2226  	}
  2227  
  2228  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2229  	return &CopyModelOperation{
  2230  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2231  		pollPath: override,
  2232  	}, nil
  2233  }
  2234  
  2235  // ImportModelEvaluation imports an externally generated ModelEvaluation.
  2236  func (c *modelRESTClient) ImportModelEvaluation(ctx context.Context, req *aiplatformpb.ImportModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
  2237  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2238  	jsonReq, err := m.Marshal(req)
  2239  	if err != nil {
  2240  		return nil, err
  2241  	}
  2242  
  2243  	baseUrl, err := url.Parse(c.endpoint)
  2244  	if err != nil {
  2245  		return nil, err
  2246  	}
  2247  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/evaluations:import", req.GetParent())
  2248  
  2249  	params := url.Values{}
  2250  	params.Add("$alt", "json;enum-encoding=int")
  2251  
  2252  	baseUrl.RawQuery = params.Encode()
  2253  
  2254  	// Build HTTP headers from client and context metadata.
  2255  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2256  
  2257  	hds = append(c.xGoogHeaders, hds...)
  2258  	hds = append(hds, "Content-Type", "application/json")
  2259  	headers := gax.BuildHeaders(ctx, hds...)
  2260  	opts = append((*c.CallOptions).ImportModelEvaluation[0:len((*c.CallOptions).ImportModelEvaluation):len((*c.CallOptions).ImportModelEvaluation)], opts...)
  2261  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2262  	resp := &aiplatformpb.ModelEvaluation{}
  2263  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2264  		if settings.Path != "" {
  2265  			baseUrl.Path = settings.Path
  2266  		}
  2267  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2268  		if err != nil {
  2269  			return err
  2270  		}
  2271  		httpReq = httpReq.WithContext(ctx)
  2272  		httpReq.Header = headers
  2273  
  2274  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ImportModelEvaluation")
  2275  		if err != nil {
  2276  			return err
  2277  		}
  2278  
  2279  		if err := unm.Unmarshal(buf, resp); err != nil {
  2280  			return err
  2281  		}
  2282  
  2283  		return nil
  2284  	}, opts...)
  2285  	if e != nil {
  2286  		return nil, e
  2287  	}
  2288  	return resp, nil
  2289  }
  2290  
  2291  // BatchImportModelEvaluationSlices imports a list of externally generated ModelEvaluationSlice.
  2292  func (c *modelRESTClient) BatchImportModelEvaluationSlices(ctx context.Context, req *aiplatformpb.BatchImportModelEvaluationSlicesRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportModelEvaluationSlicesResponse, error) {
  2293  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2294  	jsonReq, err := m.Marshal(req)
  2295  	if err != nil {
  2296  		return nil, err
  2297  	}
  2298  
  2299  	baseUrl, err := url.Parse(c.endpoint)
  2300  	if err != nil {
  2301  		return nil, err
  2302  	}
  2303  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/slices:batchImport", req.GetParent())
  2304  
  2305  	params := url.Values{}
  2306  	params.Add("$alt", "json;enum-encoding=int")
  2307  
  2308  	baseUrl.RawQuery = params.Encode()
  2309  
  2310  	// Build HTTP headers from client and context metadata.
  2311  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2312  
  2313  	hds = append(c.xGoogHeaders, hds...)
  2314  	hds = append(hds, "Content-Type", "application/json")
  2315  	headers := gax.BuildHeaders(ctx, hds...)
  2316  	opts = append((*c.CallOptions).BatchImportModelEvaluationSlices[0:len((*c.CallOptions).BatchImportModelEvaluationSlices):len((*c.CallOptions).BatchImportModelEvaluationSlices)], opts...)
  2317  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2318  	resp := &aiplatformpb.BatchImportModelEvaluationSlicesResponse{}
  2319  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2320  		if settings.Path != "" {
  2321  			baseUrl.Path = settings.Path
  2322  		}
  2323  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2324  		if err != nil {
  2325  			return err
  2326  		}
  2327  		httpReq = httpReq.WithContext(ctx)
  2328  		httpReq.Header = headers
  2329  
  2330  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchImportModelEvaluationSlices")
  2331  		if err != nil {
  2332  			return err
  2333  		}
  2334  
  2335  		if err := unm.Unmarshal(buf, resp); err != nil {
  2336  			return err
  2337  		}
  2338  
  2339  		return nil
  2340  	}, opts...)
  2341  	if e != nil {
  2342  		return nil, e
  2343  	}
  2344  	return resp, nil
  2345  }
  2346  
  2347  // BatchImportEvaluatedAnnotations imports a list of externally generated EvaluatedAnnotations.
  2348  func (c *modelRESTClient) BatchImportEvaluatedAnnotations(ctx context.Context, req *aiplatformpb.BatchImportEvaluatedAnnotationsRequest, opts ...gax.CallOption) (*aiplatformpb.BatchImportEvaluatedAnnotationsResponse, error) {
  2349  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2350  	jsonReq, err := m.Marshal(req)
  2351  	if err != nil {
  2352  		return nil, err
  2353  	}
  2354  
  2355  	baseUrl, err := url.Parse(c.endpoint)
  2356  	if err != nil {
  2357  		return nil, err
  2358  	}
  2359  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:batchImport", req.GetParent())
  2360  
  2361  	params := url.Values{}
  2362  	params.Add("$alt", "json;enum-encoding=int")
  2363  
  2364  	baseUrl.RawQuery = params.Encode()
  2365  
  2366  	// Build HTTP headers from client and context metadata.
  2367  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2368  
  2369  	hds = append(c.xGoogHeaders, hds...)
  2370  	hds = append(hds, "Content-Type", "application/json")
  2371  	headers := gax.BuildHeaders(ctx, hds...)
  2372  	opts = append((*c.CallOptions).BatchImportEvaluatedAnnotations[0:len((*c.CallOptions).BatchImportEvaluatedAnnotations):len((*c.CallOptions).BatchImportEvaluatedAnnotations)], opts...)
  2373  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2374  	resp := &aiplatformpb.BatchImportEvaluatedAnnotationsResponse{}
  2375  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2376  		if settings.Path != "" {
  2377  			baseUrl.Path = settings.Path
  2378  		}
  2379  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2380  		if err != nil {
  2381  			return err
  2382  		}
  2383  		httpReq = httpReq.WithContext(ctx)
  2384  		httpReq.Header = headers
  2385  
  2386  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "BatchImportEvaluatedAnnotations")
  2387  		if err != nil {
  2388  			return err
  2389  		}
  2390  
  2391  		if err := unm.Unmarshal(buf, resp); err != nil {
  2392  			return err
  2393  		}
  2394  
  2395  		return nil
  2396  	}, opts...)
  2397  	if e != nil {
  2398  		return nil, e
  2399  	}
  2400  	return resp, nil
  2401  }
  2402  
  2403  // GetModelEvaluation gets a ModelEvaluation.
  2404  func (c *modelRESTClient) GetModelEvaluation(ctx context.Context, req *aiplatformpb.GetModelEvaluationRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluation, error) {
  2405  	baseUrl, err := url.Parse(c.endpoint)
  2406  	if err != nil {
  2407  		return nil, err
  2408  	}
  2409  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2410  
  2411  	params := url.Values{}
  2412  	params.Add("$alt", "json;enum-encoding=int")
  2413  
  2414  	baseUrl.RawQuery = params.Encode()
  2415  
  2416  	// Build HTTP headers from client and context metadata.
  2417  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2418  
  2419  	hds = append(c.xGoogHeaders, hds...)
  2420  	hds = append(hds, "Content-Type", "application/json")
  2421  	headers := gax.BuildHeaders(ctx, hds...)
  2422  	opts = append((*c.CallOptions).GetModelEvaluation[0:len((*c.CallOptions).GetModelEvaluation):len((*c.CallOptions).GetModelEvaluation)], opts...)
  2423  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2424  	resp := &aiplatformpb.ModelEvaluation{}
  2425  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2426  		if settings.Path != "" {
  2427  			baseUrl.Path = settings.Path
  2428  		}
  2429  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2430  		if err != nil {
  2431  			return err
  2432  		}
  2433  		httpReq = httpReq.WithContext(ctx)
  2434  		httpReq.Header = headers
  2435  
  2436  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetModelEvaluation")
  2437  		if err != nil {
  2438  			return err
  2439  		}
  2440  
  2441  		if err := unm.Unmarshal(buf, resp); err != nil {
  2442  			return err
  2443  		}
  2444  
  2445  		return nil
  2446  	}, opts...)
  2447  	if e != nil {
  2448  		return nil, e
  2449  	}
  2450  	return resp, nil
  2451  }
  2452  
  2453  // ListModelEvaluations lists ModelEvaluations in a Model.
  2454  func (c *modelRESTClient) ListModelEvaluations(ctx context.Context, req *aiplatformpb.ListModelEvaluationsRequest, opts ...gax.CallOption) *ModelEvaluationIterator {
  2455  	it := &ModelEvaluationIterator{}
  2456  	req = proto.Clone(req).(*aiplatformpb.ListModelEvaluationsRequest)
  2457  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2458  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelEvaluation, string, error) {
  2459  		resp := &aiplatformpb.ListModelEvaluationsResponse{}
  2460  		if pageToken != "" {
  2461  			req.PageToken = pageToken
  2462  		}
  2463  		if pageSize > math.MaxInt32 {
  2464  			req.PageSize = math.MaxInt32
  2465  		} else if pageSize != 0 {
  2466  			req.PageSize = int32(pageSize)
  2467  		}
  2468  		baseUrl, err := url.Parse(c.endpoint)
  2469  		if err != nil {
  2470  			return nil, "", err
  2471  		}
  2472  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/evaluations", req.GetParent())
  2473  
  2474  		params := url.Values{}
  2475  		params.Add("$alt", "json;enum-encoding=int")
  2476  		if req.GetFilter() != "" {
  2477  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2478  		}
  2479  		if req.GetPageSize() != 0 {
  2480  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2481  		}
  2482  		if req.GetPageToken() != "" {
  2483  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2484  		}
  2485  		if req.GetReadMask() != nil {
  2486  			field, err := protojson.Marshal(req.GetReadMask())
  2487  			if err != nil {
  2488  				return nil, "", err
  2489  			}
  2490  			params.Add("readMask", string(field[1:len(field)-1]))
  2491  		}
  2492  
  2493  		baseUrl.RawQuery = params.Encode()
  2494  
  2495  		// Build HTTP headers from client and context metadata.
  2496  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2497  		headers := gax.BuildHeaders(ctx, hds...)
  2498  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2499  			if settings.Path != "" {
  2500  				baseUrl.Path = settings.Path
  2501  			}
  2502  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2503  			if err != nil {
  2504  				return err
  2505  			}
  2506  			httpReq.Header = headers
  2507  
  2508  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModelEvaluations")
  2509  			if err != nil {
  2510  				return err
  2511  			}
  2512  			if err := unm.Unmarshal(buf, resp); err != nil {
  2513  				return err
  2514  			}
  2515  
  2516  			return nil
  2517  		}, opts...)
  2518  		if e != nil {
  2519  			return nil, "", e
  2520  		}
  2521  		it.Response = resp
  2522  		return resp.GetModelEvaluations(), resp.GetNextPageToken(), nil
  2523  	}
  2524  
  2525  	fetch := func(pageSize int, pageToken string) (string, error) {
  2526  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2527  		if err != nil {
  2528  			return "", err
  2529  		}
  2530  		it.items = append(it.items, items...)
  2531  		return nextPageToken, nil
  2532  	}
  2533  
  2534  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2535  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2536  	it.pageInfo.Token = req.GetPageToken()
  2537  
  2538  	return it
  2539  }
  2540  
  2541  // GetModelEvaluationSlice gets a ModelEvaluationSlice.
  2542  func (c *modelRESTClient) GetModelEvaluationSlice(ctx context.Context, req *aiplatformpb.GetModelEvaluationSliceRequest, opts ...gax.CallOption) (*aiplatformpb.ModelEvaluationSlice, error) {
  2543  	baseUrl, err := url.Parse(c.endpoint)
  2544  	if err != nil {
  2545  		return nil, err
  2546  	}
  2547  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2548  
  2549  	params := url.Values{}
  2550  	params.Add("$alt", "json;enum-encoding=int")
  2551  
  2552  	baseUrl.RawQuery = params.Encode()
  2553  
  2554  	// Build HTTP headers from client and context metadata.
  2555  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2556  
  2557  	hds = append(c.xGoogHeaders, hds...)
  2558  	hds = append(hds, "Content-Type", "application/json")
  2559  	headers := gax.BuildHeaders(ctx, hds...)
  2560  	opts = append((*c.CallOptions).GetModelEvaluationSlice[0:len((*c.CallOptions).GetModelEvaluationSlice):len((*c.CallOptions).GetModelEvaluationSlice)], opts...)
  2561  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2562  	resp := &aiplatformpb.ModelEvaluationSlice{}
  2563  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2564  		if settings.Path != "" {
  2565  			baseUrl.Path = settings.Path
  2566  		}
  2567  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2568  		if err != nil {
  2569  			return err
  2570  		}
  2571  		httpReq = httpReq.WithContext(ctx)
  2572  		httpReq.Header = headers
  2573  
  2574  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetModelEvaluationSlice")
  2575  		if err != nil {
  2576  			return err
  2577  		}
  2578  
  2579  		if err := unm.Unmarshal(buf, resp); err != nil {
  2580  			return err
  2581  		}
  2582  
  2583  		return nil
  2584  	}, opts...)
  2585  	if e != nil {
  2586  		return nil, e
  2587  	}
  2588  	return resp, nil
  2589  }
  2590  
  2591  // ListModelEvaluationSlices lists ModelEvaluationSlices in a ModelEvaluation.
  2592  func (c *modelRESTClient) ListModelEvaluationSlices(ctx context.Context, req *aiplatformpb.ListModelEvaluationSlicesRequest, opts ...gax.CallOption) *ModelEvaluationSliceIterator {
  2593  	it := &ModelEvaluationSliceIterator{}
  2594  	req = proto.Clone(req).(*aiplatformpb.ListModelEvaluationSlicesRequest)
  2595  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2596  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ModelEvaluationSlice, string, error) {
  2597  		resp := &aiplatformpb.ListModelEvaluationSlicesResponse{}
  2598  		if pageToken != "" {
  2599  			req.PageToken = pageToken
  2600  		}
  2601  		if pageSize > math.MaxInt32 {
  2602  			req.PageSize = math.MaxInt32
  2603  		} else if pageSize != 0 {
  2604  			req.PageSize = int32(pageSize)
  2605  		}
  2606  		baseUrl, err := url.Parse(c.endpoint)
  2607  		if err != nil {
  2608  			return nil, "", err
  2609  		}
  2610  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/slices", req.GetParent())
  2611  
  2612  		params := url.Values{}
  2613  		params.Add("$alt", "json;enum-encoding=int")
  2614  		if req.GetFilter() != "" {
  2615  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2616  		}
  2617  		if req.GetPageSize() != 0 {
  2618  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2619  		}
  2620  		if req.GetPageToken() != "" {
  2621  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2622  		}
  2623  		if req.GetReadMask() != nil {
  2624  			field, err := protojson.Marshal(req.GetReadMask())
  2625  			if err != nil {
  2626  				return nil, "", err
  2627  			}
  2628  			params.Add("readMask", string(field[1:len(field)-1]))
  2629  		}
  2630  
  2631  		baseUrl.RawQuery = params.Encode()
  2632  
  2633  		// Build HTTP headers from client and context metadata.
  2634  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2635  		headers := gax.BuildHeaders(ctx, hds...)
  2636  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2637  			if settings.Path != "" {
  2638  				baseUrl.Path = settings.Path
  2639  			}
  2640  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2641  			if err != nil {
  2642  				return err
  2643  			}
  2644  			httpReq.Header = headers
  2645  
  2646  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListModelEvaluationSlices")
  2647  			if err != nil {
  2648  				return err
  2649  			}
  2650  			if err := unm.Unmarshal(buf, resp); err != nil {
  2651  				return err
  2652  			}
  2653  
  2654  			return nil
  2655  		}, opts...)
  2656  		if e != nil {
  2657  			return nil, "", e
  2658  		}
  2659  		it.Response = resp
  2660  		return resp.GetModelEvaluationSlices(), resp.GetNextPageToken(), nil
  2661  	}
  2662  
  2663  	fetch := func(pageSize int, pageToken string) (string, error) {
  2664  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2665  		if err != nil {
  2666  			return "", err
  2667  		}
  2668  		it.items = append(it.items, items...)
  2669  		return nextPageToken, nil
  2670  	}
  2671  
  2672  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2673  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2674  	it.pageInfo.Token = req.GetPageToken()
  2675  
  2676  	return it
  2677  }
  2678  
  2679  // RecommendSpec gets a Model’s spec recommendations.
  2680  func (c *modelRESTClient) RecommendSpec(ctx context.Context, req *aiplatformpb.RecommendSpecRequest, opts ...gax.CallOption) (*aiplatformpb.RecommendSpecResponse, error) {
  2681  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2682  	jsonReq, err := m.Marshal(req)
  2683  	if err != nil {
  2684  		return nil, err
  2685  	}
  2686  
  2687  	baseUrl, err := url.Parse(c.endpoint)
  2688  	if err != nil {
  2689  		return nil, err
  2690  	}
  2691  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:recommendSpec", req.GetParent())
  2692  
  2693  	params := url.Values{}
  2694  	params.Add("$alt", "json;enum-encoding=int")
  2695  
  2696  	baseUrl.RawQuery = params.Encode()
  2697  
  2698  	// Build HTTP headers from client and context metadata.
  2699  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2700  
  2701  	hds = append(c.xGoogHeaders, hds...)
  2702  	hds = append(hds, "Content-Type", "application/json")
  2703  	headers := gax.BuildHeaders(ctx, hds...)
  2704  	opts = append((*c.CallOptions).RecommendSpec[0:len((*c.CallOptions).RecommendSpec):len((*c.CallOptions).RecommendSpec)], opts...)
  2705  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2706  	resp := &aiplatformpb.RecommendSpecResponse{}
  2707  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2708  		if settings.Path != "" {
  2709  			baseUrl.Path = settings.Path
  2710  		}
  2711  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2712  		if err != nil {
  2713  			return err
  2714  		}
  2715  		httpReq = httpReq.WithContext(ctx)
  2716  		httpReq.Header = headers
  2717  
  2718  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RecommendSpec")
  2719  		if err != nil {
  2720  			return err
  2721  		}
  2722  
  2723  		if err := unm.Unmarshal(buf, resp); err != nil {
  2724  			return err
  2725  		}
  2726  
  2727  		return nil
  2728  	}, opts...)
  2729  	if e != nil {
  2730  		return nil, e
  2731  	}
  2732  	return resp, nil
  2733  }
  2734  
  2735  // GetLocation gets information about a location.
  2736  func (c *modelRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  2737  	baseUrl, err := url.Parse(c.endpoint)
  2738  	if err != nil {
  2739  		return nil, err
  2740  	}
  2741  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  2742  
  2743  	params := url.Values{}
  2744  	params.Add("$alt", "json;enum-encoding=int")
  2745  
  2746  	baseUrl.RawQuery = params.Encode()
  2747  
  2748  	// Build HTTP headers from client and context metadata.
  2749  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2750  
  2751  	hds = append(c.xGoogHeaders, hds...)
  2752  	hds = append(hds, "Content-Type", "application/json")
  2753  	headers := gax.BuildHeaders(ctx, hds...)
  2754  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  2755  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2756  	resp := &locationpb.Location{}
  2757  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2758  		if settings.Path != "" {
  2759  			baseUrl.Path = settings.Path
  2760  		}
  2761  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2762  		if err != nil {
  2763  			return err
  2764  		}
  2765  		httpReq = httpReq.WithContext(ctx)
  2766  		httpReq.Header = headers
  2767  
  2768  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
  2769  		if err != nil {
  2770  			return err
  2771  		}
  2772  
  2773  		if err := unm.Unmarshal(buf, resp); err != nil {
  2774  			return err
  2775  		}
  2776  
  2777  		return nil
  2778  	}, opts...)
  2779  	if e != nil {
  2780  		return nil, e
  2781  	}
  2782  	return resp, nil
  2783  }
  2784  
  2785  // ListLocations lists information about the supported locations for this service.
  2786  func (c *modelRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  2787  	it := &LocationIterator{}
  2788  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  2789  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2790  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  2791  		resp := &locationpb.ListLocationsResponse{}
  2792  		if pageToken != "" {
  2793  			req.PageToken = pageToken
  2794  		}
  2795  		if pageSize > math.MaxInt32 {
  2796  			req.PageSize = math.MaxInt32
  2797  		} else if pageSize != 0 {
  2798  			req.PageSize = int32(pageSize)
  2799  		}
  2800  		baseUrl, err := url.Parse(c.endpoint)
  2801  		if err != nil {
  2802  			return nil, "", err
  2803  		}
  2804  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  2805  
  2806  		params := url.Values{}
  2807  		params.Add("$alt", "json;enum-encoding=int")
  2808  		if req.GetFilter() != "" {
  2809  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2810  		}
  2811  		if req.GetPageSize() != 0 {
  2812  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2813  		}
  2814  		if req.GetPageToken() != "" {
  2815  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2816  		}
  2817  
  2818  		baseUrl.RawQuery = params.Encode()
  2819  
  2820  		// Build HTTP headers from client and context metadata.
  2821  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2822  		headers := gax.BuildHeaders(ctx, hds...)
  2823  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2824  			if settings.Path != "" {
  2825  				baseUrl.Path = settings.Path
  2826  			}
  2827  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2828  			if err != nil {
  2829  				return err
  2830  			}
  2831  			httpReq.Header = headers
  2832  
  2833  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  2834  			if err != nil {
  2835  				return err
  2836  			}
  2837  			if err := unm.Unmarshal(buf, resp); err != nil {
  2838  				return err
  2839  			}
  2840  
  2841  			return nil
  2842  		}, opts...)
  2843  		if e != nil {
  2844  			return nil, "", e
  2845  		}
  2846  		it.Response = resp
  2847  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  2848  	}
  2849  
  2850  	fetch := func(pageSize int, pageToken string) (string, error) {
  2851  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2852  		if err != nil {
  2853  			return "", err
  2854  		}
  2855  		it.items = append(it.items, items...)
  2856  		return nextPageToken, nil
  2857  	}
  2858  
  2859  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2860  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2861  	it.pageInfo.Token = req.GetPageToken()
  2862  
  2863  	return it
  2864  }
  2865  
  2866  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  2867  // if the resource exists and does not have a policy set.
  2868  func (c *modelRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  2869  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2870  	jsonReq, err := m.Marshal(req)
  2871  	if err != nil {
  2872  		return nil, err
  2873  	}
  2874  
  2875  	baseUrl, err := url.Parse(c.endpoint)
  2876  	if err != nil {
  2877  		return nil, err
  2878  	}
  2879  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  2880  
  2881  	params := url.Values{}
  2882  	params.Add("$alt", "json;enum-encoding=int")
  2883  
  2884  	baseUrl.RawQuery = params.Encode()
  2885  
  2886  	// Build HTTP headers from client and context metadata.
  2887  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  2888  
  2889  	hds = append(c.xGoogHeaders, hds...)
  2890  	hds = append(hds, "Content-Type", "application/json")
  2891  	headers := gax.BuildHeaders(ctx, hds...)
  2892  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  2893  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2894  	resp := &iampb.Policy{}
  2895  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2896  		if settings.Path != "" {
  2897  			baseUrl.Path = settings.Path
  2898  		}
  2899  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2900  		if err != nil {
  2901  			return err
  2902  		}
  2903  		httpReq = httpReq.WithContext(ctx)
  2904  		httpReq.Header = headers
  2905  
  2906  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  2907  		if err != nil {
  2908  			return err
  2909  		}
  2910  
  2911  		if err := unm.Unmarshal(buf, resp); err != nil {
  2912  			return err
  2913  		}
  2914  
  2915  		return nil
  2916  	}, opts...)
  2917  	if e != nil {
  2918  		return nil, e
  2919  	}
  2920  	return resp, nil
  2921  }
  2922  
  2923  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  2924  // any existing policy.
  2925  //
  2926  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  2927  // errors.
  2928  func (c *modelRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  2929  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2930  	jsonReq, err := m.Marshal(req)
  2931  	if err != nil {
  2932  		return nil, err
  2933  	}
  2934  
  2935  	baseUrl, err := url.Parse(c.endpoint)
  2936  	if err != nil {
  2937  		return nil, err
  2938  	}
  2939  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  2940  
  2941  	params := url.Values{}
  2942  	params.Add("$alt", "json;enum-encoding=int")
  2943  
  2944  	baseUrl.RawQuery = params.Encode()
  2945  
  2946  	// Build HTTP headers from client and context metadata.
  2947  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  2948  
  2949  	hds = append(c.xGoogHeaders, hds...)
  2950  	hds = append(hds, "Content-Type", "application/json")
  2951  	headers := gax.BuildHeaders(ctx, hds...)
  2952  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  2953  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2954  	resp := &iampb.Policy{}
  2955  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2956  		if settings.Path != "" {
  2957  			baseUrl.Path = settings.Path
  2958  		}
  2959  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2960  		if err != nil {
  2961  			return err
  2962  		}
  2963  		httpReq = httpReq.WithContext(ctx)
  2964  		httpReq.Header = headers
  2965  
  2966  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  2967  		if err != nil {
  2968  			return err
  2969  		}
  2970  
  2971  		if err := unm.Unmarshal(buf, resp); err != nil {
  2972  			return err
  2973  		}
  2974  
  2975  		return nil
  2976  	}, opts...)
  2977  	if e != nil {
  2978  		return nil, e
  2979  	}
  2980  	return resp, nil
  2981  }
  2982  
  2983  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  2984  // resource does not exist, this will return an empty set of
  2985  // permissions, not a NOT_FOUND error.
  2986  //
  2987  // Note: This operation is designed to be used for building
  2988  // permission-aware UIs and command-line tools, not for authorization
  2989  // checking. This operation may “fail open” without warning.
  2990  func (c *modelRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  2991  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2992  	jsonReq, err := m.Marshal(req)
  2993  	if err != nil {
  2994  		return nil, err
  2995  	}
  2996  
  2997  	baseUrl, err := url.Parse(c.endpoint)
  2998  	if err != nil {
  2999  		return nil, err
  3000  	}
  3001  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  3002  
  3003  	params := url.Values{}
  3004  	params.Add("$alt", "json;enum-encoding=int")
  3005  
  3006  	baseUrl.RawQuery = params.Encode()
  3007  
  3008  	// Build HTTP headers from client and context metadata.
  3009  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  3010  
  3011  	hds = append(c.xGoogHeaders, hds...)
  3012  	hds = append(hds, "Content-Type", "application/json")
  3013  	headers := gax.BuildHeaders(ctx, hds...)
  3014  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  3015  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3016  	resp := &iampb.TestIamPermissionsResponse{}
  3017  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3018  		if settings.Path != "" {
  3019  			baseUrl.Path = settings.Path
  3020  		}
  3021  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3022  		if err != nil {
  3023  			return err
  3024  		}
  3025  		httpReq = httpReq.WithContext(ctx)
  3026  		httpReq.Header = headers
  3027  
  3028  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  3029  		if err != nil {
  3030  			return err
  3031  		}
  3032  
  3033  		if err := unm.Unmarshal(buf, resp); err != nil {
  3034  			return err
  3035  		}
  3036  
  3037  		return nil
  3038  	}, opts...)
  3039  	if e != nil {
  3040  		return nil, e
  3041  	}
  3042  	return resp, nil
  3043  }
  3044  
  3045  // CancelOperation is a utility method from google.longrunning.Operations.
  3046  func (c *modelRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  3047  	baseUrl, err := url.Parse(c.endpoint)
  3048  	if err != nil {
  3049  		return err
  3050  	}
  3051  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  3052  
  3053  	params := url.Values{}
  3054  	params.Add("$alt", "json;enum-encoding=int")
  3055  
  3056  	baseUrl.RawQuery = params.Encode()
  3057  
  3058  	// Build HTTP headers from client and context metadata.
  3059  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3060  
  3061  	hds = append(c.xGoogHeaders, hds...)
  3062  	hds = append(hds, "Content-Type", "application/json")
  3063  	headers := gax.BuildHeaders(ctx, hds...)
  3064  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3065  		if settings.Path != "" {
  3066  			baseUrl.Path = settings.Path
  3067  		}
  3068  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  3069  		if err != nil {
  3070  			return err
  3071  		}
  3072  		httpReq = httpReq.WithContext(ctx)
  3073  		httpReq.Header = headers
  3074  
  3075  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  3076  		return err
  3077  	}, opts...)
  3078  }
  3079  
  3080  // DeleteOperation is a utility method from google.longrunning.Operations.
  3081  func (c *modelRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  3082  	baseUrl, err := url.Parse(c.endpoint)
  3083  	if err != nil {
  3084  		return err
  3085  	}
  3086  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  3087  
  3088  	params := url.Values{}
  3089  	params.Add("$alt", "json;enum-encoding=int")
  3090  
  3091  	baseUrl.RawQuery = params.Encode()
  3092  
  3093  	// Build HTTP headers from client and context metadata.
  3094  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3095  
  3096  	hds = append(c.xGoogHeaders, hds...)
  3097  	hds = append(hds, "Content-Type", "application/json")
  3098  	headers := gax.BuildHeaders(ctx, hds...)
  3099  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3100  		if settings.Path != "" {
  3101  			baseUrl.Path = settings.Path
  3102  		}
  3103  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  3104  		if err != nil {
  3105  			return err
  3106  		}
  3107  		httpReq = httpReq.WithContext(ctx)
  3108  		httpReq.Header = headers
  3109  
  3110  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  3111  		return err
  3112  	}, opts...)
  3113  }
  3114  
  3115  // GetOperation is a utility method from google.longrunning.Operations.
  3116  func (c *modelRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  3117  	baseUrl, err := url.Parse(c.endpoint)
  3118  	if err != nil {
  3119  		return nil, err
  3120  	}
  3121  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  3122  
  3123  	params := url.Values{}
  3124  	params.Add("$alt", "json;enum-encoding=int")
  3125  
  3126  	baseUrl.RawQuery = params.Encode()
  3127  
  3128  	// Build HTTP headers from client and context metadata.
  3129  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3130  
  3131  	hds = append(c.xGoogHeaders, hds...)
  3132  	hds = append(hds, "Content-Type", "application/json")
  3133  	headers := gax.BuildHeaders(ctx, hds...)
  3134  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  3135  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3136  	resp := &longrunningpb.Operation{}
  3137  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3138  		if settings.Path != "" {
  3139  			baseUrl.Path = settings.Path
  3140  		}
  3141  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3142  		if err != nil {
  3143  			return err
  3144  		}
  3145  		httpReq = httpReq.WithContext(ctx)
  3146  		httpReq.Header = headers
  3147  
  3148  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  3149  		if err != nil {
  3150  			return err
  3151  		}
  3152  
  3153  		if err := unm.Unmarshal(buf, resp); err != nil {
  3154  			return err
  3155  		}
  3156  
  3157  		return nil
  3158  	}, opts...)
  3159  	if e != nil {
  3160  		return nil, e
  3161  	}
  3162  	return resp, nil
  3163  }
  3164  
  3165  // ListOperations is a utility method from google.longrunning.Operations.
  3166  func (c *modelRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  3167  	it := &OperationIterator{}
  3168  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  3169  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3170  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  3171  		resp := &longrunningpb.ListOperationsResponse{}
  3172  		if pageToken != "" {
  3173  			req.PageToken = pageToken
  3174  		}
  3175  		if pageSize > math.MaxInt32 {
  3176  			req.PageSize = math.MaxInt32
  3177  		} else if pageSize != 0 {
  3178  			req.PageSize = int32(pageSize)
  3179  		}
  3180  		baseUrl, err := url.Parse(c.endpoint)
  3181  		if err != nil {
  3182  			return nil, "", err
  3183  		}
  3184  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  3185  
  3186  		params := url.Values{}
  3187  		params.Add("$alt", "json;enum-encoding=int")
  3188  		if req.GetFilter() != "" {
  3189  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3190  		}
  3191  		if req.GetPageSize() != 0 {
  3192  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3193  		}
  3194  		if req.GetPageToken() != "" {
  3195  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3196  		}
  3197  
  3198  		baseUrl.RawQuery = params.Encode()
  3199  
  3200  		// Build HTTP headers from client and context metadata.
  3201  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3202  		headers := gax.BuildHeaders(ctx, hds...)
  3203  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3204  			if settings.Path != "" {
  3205  				baseUrl.Path = settings.Path
  3206  			}
  3207  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3208  			if err != nil {
  3209  				return err
  3210  			}
  3211  			httpReq.Header = headers
  3212  
  3213  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  3214  			if err != nil {
  3215  				return err
  3216  			}
  3217  			if err := unm.Unmarshal(buf, resp); err != nil {
  3218  				return err
  3219  			}
  3220  
  3221  			return nil
  3222  		}, opts...)
  3223  		if e != nil {
  3224  			return nil, "", e
  3225  		}
  3226  		it.Response = resp
  3227  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  3228  	}
  3229  
  3230  	fetch := func(pageSize int, pageToken string) (string, error) {
  3231  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3232  		if err != nil {
  3233  			return "", err
  3234  		}
  3235  		it.items = append(it.items, items...)
  3236  		return nextPageToken, nil
  3237  	}
  3238  
  3239  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3240  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3241  	it.pageInfo.Token = req.GetPageToken()
  3242  
  3243  	return it
  3244  }
  3245  
  3246  // WaitOperation is a utility method from google.longrunning.Operations.
  3247  func (c *modelRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  3248  	baseUrl, err := url.Parse(c.endpoint)
  3249  	if err != nil {
  3250  		return nil, err
  3251  	}
  3252  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  3253  
  3254  	params := url.Values{}
  3255  	params.Add("$alt", "json;enum-encoding=int")
  3256  	if req.GetTimeout() != nil {
  3257  		field, err := protojson.Marshal(req.GetTimeout())
  3258  		if err != nil {
  3259  			return nil, err
  3260  		}
  3261  		params.Add("timeout", string(field[1:len(field)-1]))
  3262  	}
  3263  
  3264  	baseUrl.RawQuery = params.Encode()
  3265  
  3266  	// Build HTTP headers from client and context metadata.
  3267  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3268  
  3269  	hds = append(c.xGoogHeaders, hds...)
  3270  	hds = append(hds, "Content-Type", "application/json")
  3271  	headers := gax.BuildHeaders(ctx, hds...)
  3272  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  3273  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3274  	resp := &longrunningpb.Operation{}
  3275  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3276  		if settings.Path != "" {
  3277  			baseUrl.Path = settings.Path
  3278  		}
  3279  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  3280  		if err != nil {
  3281  			return err
  3282  		}
  3283  		httpReq = httpReq.WithContext(ctx)
  3284  		httpReq.Header = headers
  3285  
  3286  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  3287  		if err != nil {
  3288  			return err
  3289  		}
  3290  
  3291  		if err := unm.Unmarshal(buf, resp); err != nil {
  3292  			return err
  3293  		}
  3294  
  3295  		return nil
  3296  	}, opts...)
  3297  	if e != nil {
  3298  		return nil, e
  3299  	}
  3300  	return resp, nil
  3301  }
  3302  
  3303  // CopyModelOperation returns a new CopyModelOperation from a given name.
  3304  // The name must be that of a previously created CopyModelOperation, possibly from a different process.
  3305  func (c *modelGRPCClient) CopyModelOperation(name string) *CopyModelOperation {
  3306  	return &CopyModelOperation{
  3307  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3308  	}
  3309  }
  3310  
  3311  // CopyModelOperation returns a new CopyModelOperation from a given name.
  3312  // The name must be that of a previously created CopyModelOperation, possibly from a different process.
  3313  func (c *modelRESTClient) CopyModelOperation(name string) *CopyModelOperation {
  3314  	override := fmt.Sprintf("/ui/%s", name)
  3315  	return &CopyModelOperation{
  3316  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3317  		pollPath: override,
  3318  	}
  3319  }
  3320  
  3321  // DeleteModelOperation returns a new DeleteModelOperation from a given name.
  3322  // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
  3323  func (c *modelGRPCClient) DeleteModelOperation(name string) *DeleteModelOperation {
  3324  	return &DeleteModelOperation{
  3325  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3326  	}
  3327  }
  3328  
  3329  // DeleteModelOperation returns a new DeleteModelOperation from a given name.
  3330  // The name must be that of a previously created DeleteModelOperation, possibly from a different process.
  3331  func (c *modelRESTClient) DeleteModelOperation(name string) *DeleteModelOperation {
  3332  	override := fmt.Sprintf("/ui/%s", name)
  3333  	return &DeleteModelOperation{
  3334  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3335  		pollPath: override,
  3336  	}
  3337  }
  3338  
  3339  // DeleteModelVersionOperation returns a new DeleteModelVersionOperation from a given name.
  3340  // The name must be that of a previously created DeleteModelVersionOperation, possibly from a different process.
  3341  func (c *modelGRPCClient) DeleteModelVersionOperation(name string) *DeleteModelVersionOperation {
  3342  	return &DeleteModelVersionOperation{
  3343  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3344  	}
  3345  }
  3346  
  3347  // DeleteModelVersionOperation returns a new DeleteModelVersionOperation from a given name.
  3348  // The name must be that of a previously created DeleteModelVersionOperation, possibly from a different process.
  3349  func (c *modelRESTClient) DeleteModelVersionOperation(name string) *DeleteModelVersionOperation {
  3350  	override := fmt.Sprintf("/ui/%s", name)
  3351  	return &DeleteModelVersionOperation{
  3352  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3353  		pollPath: override,
  3354  	}
  3355  }
  3356  
  3357  // ExportModelOperation returns a new ExportModelOperation from a given name.
  3358  // The name must be that of a previously created ExportModelOperation, possibly from a different process.
  3359  func (c *modelGRPCClient) ExportModelOperation(name string) *ExportModelOperation {
  3360  	return &ExportModelOperation{
  3361  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3362  	}
  3363  }
  3364  
  3365  // ExportModelOperation returns a new ExportModelOperation from a given name.
  3366  // The name must be that of a previously created ExportModelOperation, possibly from a different process.
  3367  func (c *modelRESTClient) ExportModelOperation(name string) *ExportModelOperation {
  3368  	override := fmt.Sprintf("/ui/%s", name)
  3369  	return &ExportModelOperation{
  3370  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3371  		pollPath: override,
  3372  	}
  3373  }
  3374  
  3375  // UpdateExplanationDatasetOperation returns a new UpdateExplanationDatasetOperation from a given name.
  3376  // The name must be that of a previously created UpdateExplanationDatasetOperation, possibly from a different process.
  3377  func (c *modelGRPCClient) UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation {
  3378  	return &UpdateExplanationDatasetOperation{
  3379  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3380  	}
  3381  }
  3382  
  3383  // UpdateExplanationDatasetOperation returns a new UpdateExplanationDatasetOperation from a given name.
  3384  // The name must be that of a previously created UpdateExplanationDatasetOperation, possibly from a different process.
  3385  func (c *modelRESTClient) UpdateExplanationDatasetOperation(name string) *UpdateExplanationDatasetOperation {
  3386  	override := fmt.Sprintf("/ui/%s", name)
  3387  	return &UpdateExplanationDatasetOperation{
  3388  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3389  		pollPath: override,
  3390  	}
  3391  }
  3392  
  3393  // UploadModelOperation returns a new UploadModelOperation from a given name.
  3394  // The name must be that of a previously created UploadModelOperation, possibly from a different process.
  3395  func (c *modelGRPCClient) UploadModelOperation(name string) *UploadModelOperation {
  3396  	return &UploadModelOperation{
  3397  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3398  	}
  3399  }
  3400  
  3401  // UploadModelOperation returns a new UploadModelOperation from a given name.
  3402  // The name must be that of a previously created UploadModelOperation, possibly from a different process.
  3403  func (c *modelRESTClient) UploadModelOperation(name string) *UploadModelOperation {
  3404  	override := fmt.Sprintf("/ui/%s", name)
  3405  	return &UploadModelOperation{
  3406  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  3407  		pollPath: override,
  3408  	}
  3409  }