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