cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/metadata_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 newMetadataClientHook clientHook
    47  
    48  // MetadataCallOptions contains the retry settings for each method of MetadataClient.
    49  type MetadataCallOptions struct {
    50  	CreateMetadataStore              []gax.CallOption
    51  	GetMetadataStore                 []gax.CallOption
    52  	ListMetadataStores               []gax.CallOption
    53  	DeleteMetadataStore              []gax.CallOption
    54  	CreateArtifact                   []gax.CallOption
    55  	GetArtifact                      []gax.CallOption
    56  	ListArtifacts                    []gax.CallOption
    57  	UpdateArtifact                   []gax.CallOption
    58  	DeleteArtifact                   []gax.CallOption
    59  	PurgeArtifacts                   []gax.CallOption
    60  	CreateContext                    []gax.CallOption
    61  	GetContext                       []gax.CallOption
    62  	ListContexts                     []gax.CallOption
    63  	UpdateContext                    []gax.CallOption
    64  	DeleteContext                    []gax.CallOption
    65  	PurgeContexts                    []gax.CallOption
    66  	AddContextArtifactsAndExecutions []gax.CallOption
    67  	AddContextChildren               []gax.CallOption
    68  	RemoveContextChildren            []gax.CallOption
    69  	QueryContextLineageSubgraph      []gax.CallOption
    70  	CreateExecution                  []gax.CallOption
    71  	GetExecution                     []gax.CallOption
    72  	ListExecutions                   []gax.CallOption
    73  	UpdateExecution                  []gax.CallOption
    74  	DeleteExecution                  []gax.CallOption
    75  	PurgeExecutions                  []gax.CallOption
    76  	AddExecutionEvents               []gax.CallOption
    77  	QueryExecutionInputsAndOutputs   []gax.CallOption
    78  	CreateMetadataSchema             []gax.CallOption
    79  	GetMetadataSchema                []gax.CallOption
    80  	ListMetadataSchemas              []gax.CallOption
    81  	QueryArtifactLineageSubgraph     []gax.CallOption
    82  	GetLocation                      []gax.CallOption
    83  	ListLocations                    []gax.CallOption
    84  	GetIamPolicy                     []gax.CallOption
    85  	SetIamPolicy                     []gax.CallOption
    86  	TestIamPermissions               []gax.CallOption
    87  	CancelOperation                  []gax.CallOption
    88  	DeleteOperation                  []gax.CallOption
    89  	GetOperation                     []gax.CallOption
    90  	ListOperations                   []gax.CallOption
    91  	WaitOperation                    []gax.CallOption
    92  }
    93  
    94  func defaultMetadataGRPCClientOptions() []option.ClientOption {
    95  	return []option.ClientOption{
    96  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    97  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    98  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    99  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   100  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   101  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   102  		internaloption.EnableJwtWithScope(),
   103  		internaloption.EnableNewAuthLibrary(),
   104  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
   105  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
   106  	}
   107  }
   108  
   109  func defaultMetadataCallOptions() *MetadataCallOptions {
   110  	return &MetadataCallOptions{
   111  		CreateMetadataStore: []gax.CallOption{
   112  			gax.WithTimeout(5000 * time.Millisecond),
   113  		},
   114  		GetMetadataStore: []gax.CallOption{
   115  			gax.WithTimeout(5000 * time.Millisecond),
   116  		},
   117  		ListMetadataStores: []gax.CallOption{
   118  			gax.WithTimeout(5000 * time.Millisecond),
   119  		},
   120  		DeleteMetadataStore: []gax.CallOption{
   121  			gax.WithTimeout(5000 * time.Millisecond),
   122  		},
   123  		CreateArtifact: []gax.CallOption{
   124  			gax.WithTimeout(5000 * time.Millisecond),
   125  		},
   126  		GetArtifact: []gax.CallOption{
   127  			gax.WithTimeout(5000 * time.Millisecond),
   128  		},
   129  		ListArtifacts: []gax.CallOption{
   130  			gax.WithTimeout(5000 * time.Millisecond),
   131  		},
   132  		UpdateArtifact: []gax.CallOption{
   133  			gax.WithTimeout(5000 * time.Millisecond),
   134  		},
   135  		DeleteArtifact: []gax.CallOption{},
   136  		PurgeArtifacts: []gax.CallOption{},
   137  		CreateContext: []gax.CallOption{
   138  			gax.WithTimeout(5000 * time.Millisecond),
   139  		},
   140  		GetContext: []gax.CallOption{
   141  			gax.WithTimeout(5000 * time.Millisecond),
   142  		},
   143  		ListContexts: []gax.CallOption{
   144  			gax.WithTimeout(5000 * time.Millisecond),
   145  		},
   146  		UpdateContext: []gax.CallOption{
   147  			gax.WithTimeout(5000 * time.Millisecond),
   148  		},
   149  		DeleteContext: []gax.CallOption{
   150  			gax.WithTimeout(5000 * time.Millisecond),
   151  		},
   152  		PurgeContexts: []gax.CallOption{},
   153  		AddContextArtifactsAndExecutions: []gax.CallOption{
   154  			gax.WithTimeout(5000 * time.Millisecond),
   155  		},
   156  		AddContextChildren: []gax.CallOption{
   157  			gax.WithTimeout(5000 * time.Millisecond),
   158  		},
   159  		RemoveContextChildren: []gax.CallOption{},
   160  		QueryContextLineageSubgraph: []gax.CallOption{
   161  			gax.WithTimeout(5000 * time.Millisecond),
   162  		},
   163  		CreateExecution: []gax.CallOption{
   164  			gax.WithTimeout(5000 * time.Millisecond),
   165  		},
   166  		GetExecution: []gax.CallOption{
   167  			gax.WithTimeout(5000 * time.Millisecond),
   168  		},
   169  		ListExecutions: []gax.CallOption{
   170  			gax.WithTimeout(5000 * time.Millisecond),
   171  		},
   172  		UpdateExecution: []gax.CallOption{
   173  			gax.WithTimeout(5000 * time.Millisecond),
   174  		},
   175  		DeleteExecution: []gax.CallOption{},
   176  		PurgeExecutions: []gax.CallOption{},
   177  		AddExecutionEvents: []gax.CallOption{
   178  			gax.WithTimeout(5000 * time.Millisecond),
   179  		},
   180  		QueryExecutionInputsAndOutputs: []gax.CallOption{
   181  			gax.WithTimeout(5000 * time.Millisecond),
   182  		},
   183  		CreateMetadataSchema: []gax.CallOption{
   184  			gax.WithTimeout(5000 * time.Millisecond),
   185  		},
   186  		GetMetadataSchema: []gax.CallOption{
   187  			gax.WithTimeout(5000 * time.Millisecond),
   188  		},
   189  		ListMetadataSchemas: []gax.CallOption{
   190  			gax.WithTimeout(5000 * time.Millisecond),
   191  		},
   192  		QueryArtifactLineageSubgraph: []gax.CallOption{},
   193  		GetLocation:                  []gax.CallOption{},
   194  		ListLocations:                []gax.CallOption{},
   195  		GetIamPolicy:                 []gax.CallOption{},
   196  		SetIamPolicy:                 []gax.CallOption{},
   197  		TestIamPermissions:           []gax.CallOption{},
   198  		CancelOperation:              []gax.CallOption{},
   199  		DeleteOperation:              []gax.CallOption{},
   200  		GetOperation:                 []gax.CallOption{},
   201  		ListOperations:               []gax.CallOption{},
   202  		WaitOperation:                []gax.CallOption{},
   203  	}
   204  }
   205  
   206  func defaultMetadataRESTCallOptions() *MetadataCallOptions {
   207  	return &MetadataCallOptions{
   208  		CreateMetadataStore: []gax.CallOption{
   209  			gax.WithTimeout(5000 * time.Millisecond),
   210  		},
   211  		GetMetadataStore: []gax.CallOption{
   212  			gax.WithTimeout(5000 * time.Millisecond),
   213  		},
   214  		ListMetadataStores: []gax.CallOption{
   215  			gax.WithTimeout(5000 * time.Millisecond),
   216  		},
   217  		DeleteMetadataStore: []gax.CallOption{
   218  			gax.WithTimeout(5000 * time.Millisecond),
   219  		},
   220  		CreateArtifact: []gax.CallOption{
   221  			gax.WithTimeout(5000 * time.Millisecond),
   222  		},
   223  		GetArtifact: []gax.CallOption{
   224  			gax.WithTimeout(5000 * time.Millisecond),
   225  		},
   226  		ListArtifacts: []gax.CallOption{
   227  			gax.WithTimeout(5000 * time.Millisecond),
   228  		},
   229  		UpdateArtifact: []gax.CallOption{
   230  			gax.WithTimeout(5000 * time.Millisecond),
   231  		},
   232  		DeleteArtifact: []gax.CallOption{},
   233  		PurgeArtifacts: []gax.CallOption{},
   234  		CreateContext: []gax.CallOption{
   235  			gax.WithTimeout(5000 * time.Millisecond),
   236  		},
   237  		GetContext: []gax.CallOption{
   238  			gax.WithTimeout(5000 * time.Millisecond),
   239  		},
   240  		ListContexts: []gax.CallOption{
   241  			gax.WithTimeout(5000 * time.Millisecond),
   242  		},
   243  		UpdateContext: []gax.CallOption{
   244  			gax.WithTimeout(5000 * time.Millisecond),
   245  		},
   246  		DeleteContext: []gax.CallOption{
   247  			gax.WithTimeout(5000 * time.Millisecond),
   248  		},
   249  		PurgeContexts: []gax.CallOption{},
   250  		AddContextArtifactsAndExecutions: []gax.CallOption{
   251  			gax.WithTimeout(5000 * time.Millisecond),
   252  		},
   253  		AddContextChildren: []gax.CallOption{
   254  			gax.WithTimeout(5000 * time.Millisecond),
   255  		},
   256  		RemoveContextChildren: []gax.CallOption{},
   257  		QueryContextLineageSubgraph: []gax.CallOption{
   258  			gax.WithTimeout(5000 * time.Millisecond),
   259  		},
   260  		CreateExecution: []gax.CallOption{
   261  			gax.WithTimeout(5000 * time.Millisecond),
   262  		},
   263  		GetExecution: []gax.CallOption{
   264  			gax.WithTimeout(5000 * time.Millisecond),
   265  		},
   266  		ListExecutions: []gax.CallOption{
   267  			gax.WithTimeout(5000 * time.Millisecond),
   268  		},
   269  		UpdateExecution: []gax.CallOption{
   270  			gax.WithTimeout(5000 * time.Millisecond),
   271  		},
   272  		DeleteExecution: []gax.CallOption{},
   273  		PurgeExecutions: []gax.CallOption{},
   274  		AddExecutionEvents: []gax.CallOption{
   275  			gax.WithTimeout(5000 * time.Millisecond),
   276  		},
   277  		QueryExecutionInputsAndOutputs: []gax.CallOption{
   278  			gax.WithTimeout(5000 * time.Millisecond),
   279  		},
   280  		CreateMetadataSchema: []gax.CallOption{
   281  			gax.WithTimeout(5000 * time.Millisecond),
   282  		},
   283  		GetMetadataSchema: []gax.CallOption{
   284  			gax.WithTimeout(5000 * time.Millisecond),
   285  		},
   286  		ListMetadataSchemas: []gax.CallOption{
   287  			gax.WithTimeout(5000 * time.Millisecond),
   288  		},
   289  		QueryArtifactLineageSubgraph: []gax.CallOption{},
   290  		GetLocation:                  []gax.CallOption{},
   291  		ListLocations:                []gax.CallOption{},
   292  		GetIamPolicy:                 []gax.CallOption{},
   293  		SetIamPolicy:                 []gax.CallOption{},
   294  		TestIamPermissions:           []gax.CallOption{},
   295  		CancelOperation:              []gax.CallOption{},
   296  		DeleteOperation:              []gax.CallOption{},
   297  		GetOperation:                 []gax.CallOption{},
   298  		ListOperations:               []gax.CallOption{},
   299  		WaitOperation:                []gax.CallOption{},
   300  	}
   301  }
   302  
   303  // internalMetadataClient is an interface that defines the methods available from Vertex AI API.
   304  type internalMetadataClient interface {
   305  	Close() error
   306  	setGoogleClientInfo(...string)
   307  	Connection() *grpc.ClientConn
   308  	CreateMetadataStore(context.Context, *aiplatformpb.CreateMetadataStoreRequest, ...gax.CallOption) (*CreateMetadataStoreOperation, error)
   309  	CreateMetadataStoreOperation(name string) *CreateMetadataStoreOperation
   310  	GetMetadataStore(context.Context, *aiplatformpb.GetMetadataStoreRequest, ...gax.CallOption) (*aiplatformpb.MetadataStore, error)
   311  	ListMetadataStores(context.Context, *aiplatformpb.ListMetadataStoresRequest, ...gax.CallOption) *MetadataStoreIterator
   312  	DeleteMetadataStore(context.Context, *aiplatformpb.DeleteMetadataStoreRequest, ...gax.CallOption) (*DeleteMetadataStoreOperation, error)
   313  	DeleteMetadataStoreOperation(name string) *DeleteMetadataStoreOperation
   314  	CreateArtifact(context.Context, *aiplatformpb.CreateArtifactRequest, ...gax.CallOption) (*aiplatformpb.Artifact, error)
   315  	GetArtifact(context.Context, *aiplatformpb.GetArtifactRequest, ...gax.CallOption) (*aiplatformpb.Artifact, error)
   316  	ListArtifacts(context.Context, *aiplatformpb.ListArtifactsRequest, ...gax.CallOption) *ArtifactIterator
   317  	UpdateArtifact(context.Context, *aiplatformpb.UpdateArtifactRequest, ...gax.CallOption) (*aiplatformpb.Artifact, error)
   318  	DeleteArtifact(context.Context, *aiplatformpb.DeleteArtifactRequest, ...gax.CallOption) (*DeleteArtifactOperation, error)
   319  	DeleteArtifactOperation(name string) *DeleteArtifactOperation
   320  	PurgeArtifacts(context.Context, *aiplatformpb.PurgeArtifactsRequest, ...gax.CallOption) (*PurgeArtifactsOperation, error)
   321  	PurgeArtifactsOperation(name string) *PurgeArtifactsOperation
   322  	CreateContext(context.Context, *aiplatformpb.CreateContextRequest, ...gax.CallOption) (*aiplatformpb.Context, error)
   323  	GetContext(context.Context, *aiplatformpb.GetContextRequest, ...gax.CallOption) (*aiplatformpb.Context, error)
   324  	ListContexts(context.Context, *aiplatformpb.ListContextsRequest, ...gax.CallOption) *ContextIterator
   325  	UpdateContext(context.Context, *aiplatformpb.UpdateContextRequest, ...gax.CallOption) (*aiplatformpb.Context, error)
   326  	DeleteContext(context.Context, *aiplatformpb.DeleteContextRequest, ...gax.CallOption) (*DeleteContextOperation, error)
   327  	DeleteContextOperation(name string) *DeleteContextOperation
   328  	PurgeContexts(context.Context, *aiplatformpb.PurgeContextsRequest, ...gax.CallOption) (*PurgeContextsOperation, error)
   329  	PurgeContextsOperation(name string) *PurgeContextsOperation
   330  	AddContextArtifactsAndExecutions(context.Context, *aiplatformpb.AddContextArtifactsAndExecutionsRequest, ...gax.CallOption) (*aiplatformpb.AddContextArtifactsAndExecutionsResponse, error)
   331  	AddContextChildren(context.Context, *aiplatformpb.AddContextChildrenRequest, ...gax.CallOption) (*aiplatformpb.AddContextChildrenResponse, error)
   332  	RemoveContextChildren(context.Context, *aiplatformpb.RemoveContextChildrenRequest, ...gax.CallOption) (*aiplatformpb.RemoveContextChildrenResponse, error)
   333  	QueryContextLineageSubgraph(context.Context, *aiplatformpb.QueryContextLineageSubgraphRequest, ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error)
   334  	CreateExecution(context.Context, *aiplatformpb.CreateExecutionRequest, ...gax.CallOption) (*aiplatformpb.Execution, error)
   335  	GetExecution(context.Context, *aiplatformpb.GetExecutionRequest, ...gax.CallOption) (*aiplatformpb.Execution, error)
   336  	ListExecutions(context.Context, *aiplatformpb.ListExecutionsRequest, ...gax.CallOption) *ExecutionIterator
   337  	UpdateExecution(context.Context, *aiplatformpb.UpdateExecutionRequest, ...gax.CallOption) (*aiplatformpb.Execution, error)
   338  	DeleteExecution(context.Context, *aiplatformpb.DeleteExecutionRequest, ...gax.CallOption) (*DeleteExecutionOperation, error)
   339  	DeleteExecutionOperation(name string) *DeleteExecutionOperation
   340  	PurgeExecutions(context.Context, *aiplatformpb.PurgeExecutionsRequest, ...gax.CallOption) (*PurgeExecutionsOperation, error)
   341  	PurgeExecutionsOperation(name string) *PurgeExecutionsOperation
   342  	AddExecutionEvents(context.Context, *aiplatformpb.AddExecutionEventsRequest, ...gax.CallOption) (*aiplatformpb.AddExecutionEventsResponse, error)
   343  	QueryExecutionInputsAndOutputs(context.Context, *aiplatformpb.QueryExecutionInputsAndOutputsRequest, ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error)
   344  	CreateMetadataSchema(context.Context, *aiplatformpb.CreateMetadataSchemaRequest, ...gax.CallOption) (*aiplatformpb.MetadataSchema, error)
   345  	GetMetadataSchema(context.Context, *aiplatformpb.GetMetadataSchemaRequest, ...gax.CallOption) (*aiplatformpb.MetadataSchema, error)
   346  	ListMetadataSchemas(context.Context, *aiplatformpb.ListMetadataSchemasRequest, ...gax.CallOption) *MetadataSchemaIterator
   347  	QueryArtifactLineageSubgraph(context.Context, *aiplatformpb.QueryArtifactLineageSubgraphRequest, ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error)
   348  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   349  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   350  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   351  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   352  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   353  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   354  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   355  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   356  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   357  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   358  }
   359  
   360  // MetadataClient is a client for interacting with Vertex AI API.
   361  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   362  //
   363  // Service for reading and writing metadata entries.
   364  type MetadataClient struct {
   365  	// The internal transport-dependent client.
   366  	internalClient internalMetadataClient
   367  
   368  	// The call options for this service.
   369  	CallOptions *MetadataCallOptions
   370  
   371  	// LROClient is used internally to handle long-running operations.
   372  	// It is exposed so that its CallOptions can be modified if required.
   373  	// Users should not Close this client.
   374  	LROClient *lroauto.OperationsClient
   375  }
   376  
   377  // Wrapper methods routed to the internal client.
   378  
   379  // Close closes the connection to the API service. The user should invoke this when
   380  // the client is no longer required.
   381  func (c *MetadataClient) Close() error {
   382  	return c.internalClient.Close()
   383  }
   384  
   385  // setGoogleClientInfo sets the name and version of the application in
   386  // the `x-goog-api-client` header passed on each request. Intended for
   387  // use by Google-written clients.
   388  func (c *MetadataClient) setGoogleClientInfo(keyval ...string) {
   389  	c.internalClient.setGoogleClientInfo(keyval...)
   390  }
   391  
   392  // Connection returns a connection to the API service.
   393  //
   394  // Deprecated: Connections are now pooled so this method does not always
   395  // return the same resource.
   396  func (c *MetadataClient) Connection() *grpc.ClientConn {
   397  	return c.internalClient.Connection()
   398  }
   399  
   400  // CreateMetadataStore initializes a MetadataStore, including allocation of resources.
   401  func (c *MetadataClient) CreateMetadataStore(ctx context.Context, req *aiplatformpb.CreateMetadataStoreRequest, opts ...gax.CallOption) (*CreateMetadataStoreOperation, error) {
   402  	return c.internalClient.CreateMetadataStore(ctx, req, opts...)
   403  }
   404  
   405  // CreateMetadataStoreOperation returns a new CreateMetadataStoreOperation from a given name.
   406  // The name must be that of a previously created CreateMetadataStoreOperation, possibly from a different process.
   407  func (c *MetadataClient) CreateMetadataStoreOperation(name string) *CreateMetadataStoreOperation {
   408  	return c.internalClient.CreateMetadataStoreOperation(name)
   409  }
   410  
   411  // GetMetadataStore retrieves a specific MetadataStore.
   412  func (c *MetadataClient) GetMetadataStore(ctx context.Context, req *aiplatformpb.GetMetadataStoreRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataStore, error) {
   413  	return c.internalClient.GetMetadataStore(ctx, req, opts...)
   414  }
   415  
   416  // ListMetadataStores lists MetadataStores for a Location.
   417  func (c *MetadataClient) ListMetadataStores(ctx context.Context, req *aiplatformpb.ListMetadataStoresRequest, opts ...gax.CallOption) *MetadataStoreIterator {
   418  	return c.internalClient.ListMetadataStores(ctx, req, opts...)
   419  }
   420  
   421  // DeleteMetadataStore deletes a single MetadataStore and all its child resources (Artifacts,
   422  // Executions, and Contexts).
   423  func (c *MetadataClient) DeleteMetadataStore(ctx context.Context, req *aiplatformpb.DeleteMetadataStoreRequest, opts ...gax.CallOption) (*DeleteMetadataStoreOperation, error) {
   424  	return c.internalClient.DeleteMetadataStore(ctx, req, opts...)
   425  }
   426  
   427  // DeleteMetadataStoreOperation returns a new DeleteMetadataStoreOperation from a given name.
   428  // The name must be that of a previously created DeleteMetadataStoreOperation, possibly from a different process.
   429  func (c *MetadataClient) DeleteMetadataStoreOperation(name string) *DeleteMetadataStoreOperation {
   430  	return c.internalClient.DeleteMetadataStoreOperation(name)
   431  }
   432  
   433  // CreateArtifact creates an Artifact associated with a MetadataStore.
   434  func (c *MetadataClient) CreateArtifact(ctx context.Context, req *aiplatformpb.CreateArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
   435  	return c.internalClient.CreateArtifact(ctx, req, opts...)
   436  }
   437  
   438  // GetArtifact retrieves a specific Artifact.
   439  func (c *MetadataClient) GetArtifact(ctx context.Context, req *aiplatformpb.GetArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
   440  	return c.internalClient.GetArtifact(ctx, req, opts...)
   441  }
   442  
   443  // ListArtifacts lists Artifacts in the MetadataStore.
   444  func (c *MetadataClient) ListArtifacts(ctx context.Context, req *aiplatformpb.ListArtifactsRequest, opts ...gax.CallOption) *ArtifactIterator {
   445  	return c.internalClient.ListArtifacts(ctx, req, opts...)
   446  }
   447  
   448  // UpdateArtifact updates a stored Artifact.
   449  func (c *MetadataClient) UpdateArtifact(ctx context.Context, req *aiplatformpb.UpdateArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
   450  	return c.internalClient.UpdateArtifact(ctx, req, opts...)
   451  }
   452  
   453  // DeleteArtifact deletes an Artifact.
   454  func (c *MetadataClient) DeleteArtifact(ctx context.Context, req *aiplatformpb.DeleteArtifactRequest, opts ...gax.CallOption) (*DeleteArtifactOperation, error) {
   455  	return c.internalClient.DeleteArtifact(ctx, req, opts...)
   456  }
   457  
   458  // DeleteArtifactOperation returns a new DeleteArtifactOperation from a given name.
   459  // The name must be that of a previously created DeleteArtifactOperation, possibly from a different process.
   460  func (c *MetadataClient) DeleteArtifactOperation(name string) *DeleteArtifactOperation {
   461  	return c.internalClient.DeleteArtifactOperation(name)
   462  }
   463  
   464  // PurgeArtifacts purges Artifacts.
   465  func (c *MetadataClient) PurgeArtifacts(ctx context.Context, req *aiplatformpb.PurgeArtifactsRequest, opts ...gax.CallOption) (*PurgeArtifactsOperation, error) {
   466  	return c.internalClient.PurgeArtifacts(ctx, req, opts...)
   467  }
   468  
   469  // PurgeArtifactsOperation returns a new PurgeArtifactsOperation from a given name.
   470  // The name must be that of a previously created PurgeArtifactsOperation, possibly from a different process.
   471  func (c *MetadataClient) PurgeArtifactsOperation(name string) *PurgeArtifactsOperation {
   472  	return c.internalClient.PurgeArtifactsOperation(name)
   473  }
   474  
   475  // CreateContext creates a Context associated with a MetadataStore.
   476  func (c *MetadataClient) CreateContext(ctx context.Context, req *aiplatformpb.CreateContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
   477  	return c.internalClient.CreateContext(ctx, req, opts...)
   478  }
   479  
   480  // GetContext retrieves a specific Context.
   481  func (c *MetadataClient) GetContext(ctx context.Context, req *aiplatformpb.GetContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
   482  	return c.internalClient.GetContext(ctx, req, opts...)
   483  }
   484  
   485  // ListContexts lists Contexts on the MetadataStore.
   486  func (c *MetadataClient) ListContexts(ctx context.Context, req *aiplatformpb.ListContextsRequest, opts ...gax.CallOption) *ContextIterator {
   487  	return c.internalClient.ListContexts(ctx, req, opts...)
   488  }
   489  
   490  // UpdateContext updates a stored Context.
   491  func (c *MetadataClient) UpdateContext(ctx context.Context, req *aiplatformpb.UpdateContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
   492  	return c.internalClient.UpdateContext(ctx, req, opts...)
   493  }
   494  
   495  // DeleteContext deletes a stored Context.
   496  func (c *MetadataClient) DeleteContext(ctx context.Context, req *aiplatformpb.DeleteContextRequest, opts ...gax.CallOption) (*DeleteContextOperation, error) {
   497  	return c.internalClient.DeleteContext(ctx, req, opts...)
   498  }
   499  
   500  // DeleteContextOperation returns a new DeleteContextOperation from a given name.
   501  // The name must be that of a previously created DeleteContextOperation, possibly from a different process.
   502  func (c *MetadataClient) DeleteContextOperation(name string) *DeleteContextOperation {
   503  	return c.internalClient.DeleteContextOperation(name)
   504  }
   505  
   506  // PurgeContexts purges Contexts.
   507  func (c *MetadataClient) PurgeContexts(ctx context.Context, req *aiplatformpb.PurgeContextsRequest, opts ...gax.CallOption) (*PurgeContextsOperation, error) {
   508  	return c.internalClient.PurgeContexts(ctx, req, opts...)
   509  }
   510  
   511  // PurgeContextsOperation returns a new PurgeContextsOperation from a given name.
   512  // The name must be that of a previously created PurgeContextsOperation, possibly from a different process.
   513  func (c *MetadataClient) PurgeContextsOperation(name string) *PurgeContextsOperation {
   514  	return c.internalClient.PurgeContextsOperation(name)
   515  }
   516  
   517  // AddContextArtifactsAndExecutions adds a set of Artifacts and Executions to a Context. If any of the
   518  // Artifacts or Executions have already been added to a Context, they are
   519  // simply skipped.
   520  func (c *MetadataClient) AddContextArtifactsAndExecutions(ctx context.Context, req *aiplatformpb.AddContextArtifactsAndExecutionsRequest, opts ...gax.CallOption) (*aiplatformpb.AddContextArtifactsAndExecutionsResponse, error) {
   521  	return c.internalClient.AddContextArtifactsAndExecutions(ctx, req, opts...)
   522  }
   523  
   524  // AddContextChildren adds a set of Contexts as children to a parent Context. If any of the
   525  // child Contexts have already been added to the parent Context, they are
   526  // simply skipped. If this call would create a cycle or cause any Context to
   527  // have more than 10 parents, the request will fail with an INVALID_ARGUMENT
   528  // error.
   529  func (c *MetadataClient) AddContextChildren(ctx context.Context, req *aiplatformpb.AddContextChildrenRequest, opts ...gax.CallOption) (*aiplatformpb.AddContextChildrenResponse, error) {
   530  	return c.internalClient.AddContextChildren(ctx, req, opts...)
   531  }
   532  
   533  // RemoveContextChildren remove a set of children contexts from a parent Context. If any of the
   534  // child Contexts were NOT added to the parent Context, they are
   535  // simply skipped.
   536  func (c *MetadataClient) RemoveContextChildren(ctx context.Context, req *aiplatformpb.RemoveContextChildrenRequest, opts ...gax.CallOption) (*aiplatformpb.RemoveContextChildrenResponse, error) {
   537  	return c.internalClient.RemoveContextChildren(ctx, req, opts...)
   538  }
   539  
   540  // QueryContextLineageSubgraph retrieves Artifacts and Executions within the specified Context, connected
   541  // by Event edges and returned as a LineageSubgraph.
   542  func (c *MetadataClient) QueryContextLineageSubgraph(ctx context.Context, req *aiplatformpb.QueryContextLineageSubgraphRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
   543  	return c.internalClient.QueryContextLineageSubgraph(ctx, req, opts...)
   544  }
   545  
   546  // CreateExecution creates an Execution associated with a MetadataStore.
   547  func (c *MetadataClient) CreateExecution(ctx context.Context, req *aiplatformpb.CreateExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
   548  	return c.internalClient.CreateExecution(ctx, req, opts...)
   549  }
   550  
   551  // GetExecution retrieves a specific Execution.
   552  func (c *MetadataClient) GetExecution(ctx context.Context, req *aiplatformpb.GetExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
   553  	return c.internalClient.GetExecution(ctx, req, opts...)
   554  }
   555  
   556  // ListExecutions lists Executions in the MetadataStore.
   557  func (c *MetadataClient) ListExecutions(ctx context.Context, req *aiplatformpb.ListExecutionsRequest, opts ...gax.CallOption) *ExecutionIterator {
   558  	return c.internalClient.ListExecutions(ctx, req, opts...)
   559  }
   560  
   561  // UpdateExecution updates a stored Execution.
   562  func (c *MetadataClient) UpdateExecution(ctx context.Context, req *aiplatformpb.UpdateExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
   563  	return c.internalClient.UpdateExecution(ctx, req, opts...)
   564  }
   565  
   566  // DeleteExecution deletes an Execution.
   567  func (c *MetadataClient) DeleteExecution(ctx context.Context, req *aiplatformpb.DeleteExecutionRequest, opts ...gax.CallOption) (*DeleteExecutionOperation, error) {
   568  	return c.internalClient.DeleteExecution(ctx, req, opts...)
   569  }
   570  
   571  // DeleteExecutionOperation returns a new DeleteExecutionOperation from a given name.
   572  // The name must be that of a previously created DeleteExecutionOperation, possibly from a different process.
   573  func (c *MetadataClient) DeleteExecutionOperation(name string) *DeleteExecutionOperation {
   574  	return c.internalClient.DeleteExecutionOperation(name)
   575  }
   576  
   577  // PurgeExecutions purges Executions.
   578  func (c *MetadataClient) PurgeExecutions(ctx context.Context, req *aiplatformpb.PurgeExecutionsRequest, opts ...gax.CallOption) (*PurgeExecutionsOperation, error) {
   579  	return c.internalClient.PurgeExecutions(ctx, req, opts...)
   580  }
   581  
   582  // PurgeExecutionsOperation returns a new PurgeExecutionsOperation from a given name.
   583  // The name must be that of a previously created PurgeExecutionsOperation, possibly from a different process.
   584  func (c *MetadataClient) PurgeExecutionsOperation(name string) *PurgeExecutionsOperation {
   585  	return c.internalClient.PurgeExecutionsOperation(name)
   586  }
   587  
   588  // AddExecutionEvents adds Events to the specified Execution. An Event indicates whether an
   589  // Artifact was used as an input or output for an Execution. If an Event
   590  // already exists between the Execution and the Artifact, the Event is
   591  // skipped.
   592  func (c *MetadataClient) AddExecutionEvents(ctx context.Context, req *aiplatformpb.AddExecutionEventsRequest, opts ...gax.CallOption) (*aiplatformpb.AddExecutionEventsResponse, error) {
   593  	return c.internalClient.AddExecutionEvents(ctx, req, opts...)
   594  }
   595  
   596  // QueryExecutionInputsAndOutputs obtains the set of input and output Artifacts for this Execution, in the
   597  // form of LineageSubgraph that also contains the Execution and connecting
   598  // Events.
   599  func (c *MetadataClient) QueryExecutionInputsAndOutputs(ctx context.Context, req *aiplatformpb.QueryExecutionInputsAndOutputsRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
   600  	return c.internalClient.QueryExecutionInputsAndOutputs(ctx, req, opts...)
   601  }
   602  
   603  // CreateMetadataSchema creates a MetadataSchema.
   604  func (c *MetadataClient) CreateMetadataSchema(ctx context.Context, req *aiplatformpb.CreateMetadataSchemaRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataSchema, error) {
   605  	return c.internalClient.CreateMetadataSchema(ctx, req, opts...)
   606  }
   607  
   608  // GetMetadataSchema retrieves a specific MetadataSchema.
   609  func (c *MetadataClient) GetMetadataSchema(ctx context.Context, req *aiplatformpb.GetMetadataSchemaRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataSchema, error) {
   610  	return c.internalClient.GetMetadataSchema(ctx, req, opts...)
   611  }
   612  
   613  // ListMetadataSchemas lists MetadataSchemas.
   614  func (c *MetadataClient) ListMetadataSchemas(ctx context.Context, req *aiplatformpb.ListMetadataSchemasRequest, opts ...gax.CallOption) *MetadataSchemaIterator {
   615  	return c.internalClient.ListMetadataSchemas(ctx, req, opts...)
   616  }
   617  
   618  // QueryArtifactLineageSubgraph retrieves lineage of an Artifact represented through Artifacts and
   619  // Executions connected by Event edges and returned as a LineageSubgraph.
   620  func (c *MetadataClient) QueryArtifactLineageSubgraph(ctx context.Context, req *aiplatformpb.QueryArtifactLineageSubgraphRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
   621  	return c.internalClient.QueryArtifactLineageSubgraph(ctx, req, opts...)
   622  }
   623  
   624  // GetLocation gets information about a location.
   625  func (c *MetadataClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   626  	return c.internalClient.GetLocation(ctx, req, opts...)
   627  }
   628  
   629  // ListLocations lists information about the supported locations for this service.
   630  func (c *MetadataClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   631  	return c.internalClient.ListLocations(ctx, req, opts...)
   632  }
   633  
   634  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   635  // if the resource exists and does not have a policy set.
   636  func (c *MetadataClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   637  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   638  }
   639  
   640  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   641  // any existing policy.
   642  //
   643  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   644  // errors.
   645  func (c *MetadataClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   646  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   647  }
   648  
   649  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   650  // resource does not exist, this will return an empty set of
   651  // permissions, not a NOT_FOUND error.
   652  //
   653  // Note: This operation is designed to be used for building
   654  // permission-aware UIs and command-line tools, not for authorization
   655  // checking. This operation may “fail open” without warning.
   656  func (c *MetadataClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   657  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   658  }
   659  
   660  // CancelOperation is a utility method from google.longrunning.Operations.
   661  func (c *MetadataClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   662  	return c.internalClient.CancelOperation(ctx, req, opts...)
   663  }
   664  
   665  // DeleteOperation is a utility method from google.longrunning.Operations.
   666  func (c *MetadataClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   667  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   668  }
   669  
   670  // GetOperation is a utility method from google.longrunning.Operations.
   671  func (c *MetadataClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   672  	return c.internalClient.GetOperation(ctx, req, opts...)
   673  }
   674  
   675  // ListOperations is a utility method from google.longrunning.Operations.
   676  func (c *MetadataClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   677  	return c.internalClient.ListOperations(ctx, req, opts...)
   678  }
   679  
   680  // WaitOperation is a utility method from google.longrunning.Operations.
   681  func (c *MetadataClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   682  	return c.internalClient.WaitOperation(ctx, req, opts...)
   683  }
   684  
   685  // metadataGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   686  //
   687  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   688  type metadataGRPCClient struct {
   689  	// Connection pool of gRPC connections to the service.
   690  	connPool gtransport.ConnPool
   691  
   692  	// Points back to the CallOptions field of the containing MetadataClient
   693  	CallOptions **MetadataCallOptions
   694  
   695  	// The gRPC API client.
   696  	metadataClient aiplatformpb.MetadataServiceClient
   697  
   698  	// LROClient is used internally to handle long-running operations.
   699  	// It is exposed so that its CallOptions can be modified if required.
   700  	// Users should not Close this client.
   701  	LROClient **lroauto.OperationsClient
   702  
   703  	operationsClient longrunningpb.OperationsClient
   704  
   705  	iamPolicyClient iampb.IAMPolicyClient
   706  
   707  	locationsClient locationpb.LocationsClient
   708  
   709  	// The x-goog-* metadata to be sent with each request.
   710  	xGoogHeaders []string
   711  
   712  	logger *slog.Logger
   713  }
   714  
   715  // NewMetadataClient creates a new metadata service client based on gRPC.
   716  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   717  //
   718  // Service for reading and writing metadata entries.
   719  func NewMetadataClient(ctx context.Context, opts ...option.ClientOption) (*MetadataClient, error) {
   720  	clientOpts := defaultMetadataGRPCClientOptions()
   721  	if newMetadataClientHook != nil {
   722  		hookOpts, err := newMetadataClientHook(ctx, clientHookParams{})
   723  		if err != nil {
   724  			return nil, err
   725  		}
   726  		clientOpts = append(clientOpts, hookOpts...)
   727  	}
   728  
   729  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   730  	if err != nil {
   731  		return nil, err
   732  	}
   733  	client := MetadataClient{CallOptions: defaultMetadataCallOptions()}
   734  
   735  	c := &metadataGRPCClient{
   736  		connPool:         connPool,
   737  		metadataClient:   aiplatformpb.NewMetadataServiceClient(connPool),
   738  		CallOptions:      &client.CallOptions,
   739  		logger:           internaloption.GetLogger(opts),
   740  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   741  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   742  		locationsClient:  locationpb.NewLocationsClient(connPool),
   743  	}
   744  	c.setGoogleClientInfo()
   745  
   746  	client.internalClient = c
   747  
   748  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   749  	if err != nil {
   750  		// This error "should not happen", since we are just reusing old connection pool
   751  		// and never actually need to dial.
   752  		// If this does happen, we could leak connp. However, we cannot close conn:
   753  		// If the user invoked the constructor with option.WithGRPCConn,
   754  		// we would close a connection that's still in use.
   755  		// TODO: investigate error conditions.
   756  		return nil, err
   757  	}
   758  	c.LROClient = &client.LROClient
   759  	return &client, nil
   760  }
   761  
   762  // Connection returns a connection to the API service.
   763  //
   764  // Deprecated: Connections are now pooled so this method does not always
   765  // return the same resource.
   766  func (c *metadataGRPCClient) Connection() *grpc.ClientConn {
   767  	return c.connPool.Conn()
   768  }
   769  
   770  // setGoogleClientInfo sets the name and version of the application in
   771  // the `x-goog-api-client` header passed on each request. Intended for
   772  // use by Google-written clients.
   773  func (c *metadataGRPCClient) setGoogleClientInfo(keyval ...string) {
   774  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   775  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   776  	c.xGoogHeaders = []string{
   777  		"x-goog-api-client", gax.XGoogHeader(kv...),
   778  	}
   779  }
   780  
   781  // Close closes the connection to the API service. The user should invoke this when
   782  // the client is no longer required.
   783  func (c *metadataGRPCClient) Close() error {
   784  	return c.connPool.Close()
   785  }
   786  
   787  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   788  type metadataRESTClient struct {
   789  	// The http endpoint to connect to.
   790  	endpoint string
   791  
   792  	// The http client.
   793  	httpClient *http.Client
   794  
   795  	// LROClient is used internally to handle long-running operations.
   796  	// It is exposed so that its CallOptions can be modified if required.
   797  	// Users should not Close this client.
   798  	LROClient **lroauto.OperationsClient
   799  
   800  	// The x-goog-* headers to be sent with each request.
   801  	xGoogHeaders []string
   802  
   803  	// Points back to the CallOptions field of the containing MetadataClient
   804  	CallOptions **MetadataCallOptions
   805  
   806  	logger *slog.Logger
   807  }
   808  
   809  // NewMetadataRESTClient creates a new metadata service rest client.
   810  //
   811  // Service for reading and writing metadata entries.
   812  func NewMetadataRESTClient(ctx context.Context, opts ...option.ClientOption) (*MetadataClient, error) {
   813  	clientOpts := append(defaultMetadataRESTClientOptions(), opts...)
   814  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   815  	if err != nil {
   816  		return nil, err
   817  	}
   818  
   819  	callOpts := defaultMetadataRESTCallOptions()
   820  	c := &metadataRESTClient{
   821  		endpoint:    endpoint,
   822  		httpClient:  httpClient,
   823  		CallOptions: &callOpts,
   824  		logger:      internaloption.GetLogger(opts),
   825  	}
   826  	c.setGoogleClientInfo()
   827  
   828  	lroOpts := []option.ClientOption{
   829  		option.WithHTTPClient(httpClient),
   830  		option.WithEndpoint(endpoint),
   831  	}
   832  	opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
   833  	if err != nil {
   834  		return nil, err
   835  	}
   836  	c.LROClient = &opClient
   837  
   838  	return &MetadataClient{internalClient: c, CallOptions: callOpts}, nil
   839  }
   840  
   841  func defaultMetadataRESTClientOptions() []option.ClientOption {
   842  	return []option.ClientOption{
   843  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   844  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   845  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   846  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   847  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   848  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   849  		internaloption.EnableNewAuthLibrary(),
   850  	}
   851  }
   852  
   853  // setGoogleClientInfo sets the name and version of the application in
   854  // the `x-goog-api-client` header passed on each request. Intended for
   855  // use by Google-written clients.
   856  func (c *metadataRESTClient) setGoogleClientInfo(keyval ...string) {
   857  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   858  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   859  	c.xGoogHeaders = []string{
   860  		"x-goog-api-client", gax.XGoogHeader(kv...),
   861  	}
   862  }
   863  
   864  // Close closes the connection to the API service. The user should invoke this when
   865  // the client is no longer required.
   866  func (c *metadataRESTClient) Close() error {
   867  	// Replace httpClient with nil to force cleanup.
   868  	c.httpClient = nil
   869  	return nil
   870  }
   871  
   872  // Connection returns a connection to the API service.
   873  //
   874  // Deprecated: This method always returns nil.
   875  func (c *metadataRESTClient) Connection() *grpc.ClientConn {
   876  	return nil
   877  }
   878  func (c *metadataGRPCClient) CreateMetadataStore(ctx context.Context, req *aiplatformpb.CreateMetadataStoreRequest, opts ...gax.CallOption) (*CreateMetadataStoreOperation, error) {
   879  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   880  
   881  	hds = append(c.xGoogHeaders, hds...)
   882  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   883  	opts = append((*c.CallOptions).CreateMetadataStore[0:len((*c.CallOptions).CreateMetadataStore):len((*c.CallOptions).CreateMetadataStore)], opts...)
   884  	var resp *longrunningpb.Operation
   885  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   886  		var err error
   887  		resp, err = executeRPC(ctx, c.metadataClient.CreateMetadataStore, req, settings.GRPC, c.logger, "CreateMetadataStore")
   888  		return err
   889  	}, opts...)
   890  	if err != nil {
   891  		return nil, err
   892  	}
   893  	return &CreateMetadataStoreOperation{
   894  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   895  	}, nil
   896  }
   897  
   898  func (c *metadataGRPCClient) GetMetadataStore(ctx context.Context, req *aiplatformpb.GetMetadataStoreRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataStore, error) {
   899  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   900  
   901  	hds = append(c.xGoogHeaders, hds...)
   902  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   903  	opts = append((*c.CallOptions).GetMetadataStore[0:len((*c.CallOptions).GetMetadataStore):len((*c.CallOptions).GetMetadataStore)], opts...)
   904  	var resp *aiplatformpb.MetadataStore
   905  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   906  		var err error
   907  		resp, err = executeRPC(ctx, c.metadataClient.GetMetadataStore, req, settings.GRPC, c.logger, "GetMetadataStore")
   908  		return err
   909  	}, opts...)
   910  	if err != nil {
   911  		return nil, err
   912  	}
   913  	return resp, nil
   914  }
   915  
   916  func (c *metadataGRPCClient) ListMetadataStores(ctx context.Context, req *aiplatformpb.ListMetadataStoresRequest, opts ...gax.CallOption) *MetadataStoreIterator {
   917  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   918  
   919  	hds = append(c.xGoogHeaders, hds...)
   920  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   921  	opts = append((*c.CallOptions).ListMetadataStores[0:len((*c.CallOptions).ListMetadataStores):len((*c.CallOptions).ListMetadataStores)], opts...)
   922  	it := &MetadataStoreIterator{}
   923  	req = proto.Clone(req).(*aiplatformpb.ListMetadataStoresRequest)
   924  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.MetadataStore, string, error) {
   925  		resp := &aiplatformpb.ListMetadataStoresResponse{}
   926  		if pageToken != "" {
   927  			req.PageToken = pageToken
   928  		}
   929  		if pageSize > math.MaxInt32 {
   930  			req.PageSize = math.MaxInt32
   931  		} else if pageSize != 0 {
   932  			req.PageSize = int32(pageSize)
   933  		}
   934  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   935  			var err error
   936  			resp, err = executeRPC(ctx, c.metadataClient.ListMetadataStores, req, settings.GRPC, c.logger, "ListMetadataStores")
   937  			return err
   938  		}, opts...)
   939  		if err != nil {
   940  			return nil, "", err
   941  		}
   942  
   943  		it.Response = resp
   944  		return resp.GetMetadataStores(), resp.GetNextPageToken(), nil
   945  	}
   946  	fetch := func(pageSize int, pageToken string) (string, error) {
   947  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   948  		if err != nil {
   949  			return "", err
   950  		}
   951  		it.items = append(it.items, items...)
   952  		return nextPageToken, nil
   953  	}
   954  
   955  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   956  	it.pageInfo.MaxSize = int(req.GetPageSize())
   957  	it.pageInfo.Token = req.GetPageToken()
   958  
   959  	return it
   960  }
   961  
   962  func (c *metadataGRPCClient) DeleteMetadataStore(ctx context.Context, req *aiplatformpb.DeleteMetadataStoreRequest, opts ...gax.CallOption) (*DeleteMetadataStoreOperation, error) {
   963  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   964  
   965  	hds = append(c.xGoogHeaders, hds...)
   966  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   967  	opts = append((*c.CallOptions).DeleteMetadataStore[0:len((*c.CallOptions).DeleteMetadataStore):len((*c.CallOptions).DeleteMetadataStore)], opts...)
   968  	var resp *longrunningpb.Operation
   969  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   970  		var err error
   971  		resp, err = executeRPC(ctx, c.metadataClient.DeleteMetadataStore, req, settings.GRPC, c.logger, "DeleteMetadataStore")
   972  		return err
   973  	}, opts...)
   974  	if err != nil {
   975  		return nil, err
   976  	}
   977  	return &DeleteMetadataStoreOperation{
   978  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   979  	}, nil
   980  }
   981  
   982  func (c *metadataGRPCClient) CreateArtifact(ctx context.Context, req *aiplatformpb.CreateArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
   983  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   984  
   985  	hds = append(c.xGoogHeaders, hds...)
   986  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   987  	opts = append((*c.CallOptions).CreateArtifact[0:len((*c.CallOptions).CreateArtifact):len((*c.CallOptions).CreateArtifact)], opts...)
   988  	var resp *aiplatformpb.Artifact
   989  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   990  		var err error
   991  		resp, err = executeRPC(ctx, c.metadataClient.CreateArtifact, req, settings.GRPC, c.logger, "CreateArtifact")
   992  		return err
   993  	}, opts...)
   994  	if err != nil {
   995  		return nil, err
   996  	}
   997  	return resp, nil
   998  }
   999  
  1000  func (c *metadataGRPCClient) GetArtifact(ctx context.Context, req *aiplatformpb.GetArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
  1001  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1002  
  1003  	hds = append(c.xGoogHeaders, hds...)
  1004  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1005  	opts = append((*c.CallOptions).GetArtifact[0:len((*c.CallOptions).GetArtifact):len((*c.CallOptions).GetArtifact)], opts...)
  1006  	var resp *aiplatformpb.Artifact
  1007  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1008  		var err error
  1009  		resp, err = executeRPC(ctx, c.metadataClient.GetArtifact, req, settings.GRPC, c.logger, "GetArtifact")
  1010  		return err
  1011  	}, opts...)
  1012  	if err != nil {
  1013  		return nil, err
  1014  	}
  1015  	return resp, nil
  1016  }
  1017  
  1018  func (c *metadataGRPCClient) ListArtifacts(ctx context.Context, req *aiplatformpb.ListArtifactsRequest, opts ...gax.CallOption) *ArtifactIterator {
  1019  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1020  
  1021  	hds = append(c.xGoogHeaders, hds...)
  1022  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1023  	opts = append((*c.CallOptions).ListArtifacts[0:len((*c.CallOptions).ListArtifacts):len((*c.CallOptions).ListArtifacts)], opts...)
  1024  	it := &ArtifactIterator{}
  1025  	req = proto.Clone(req).(*aiplatformpb.ListArtifactsRequest)
  1026  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Artifact, string, error) {
  1027  		resp := &aiplatformpb.ListArtifactsResponse{}
  1028  		if pageToken != "" {
  1029  			req.PageToken = pageToken
  1030  		}
  1031  		if pageSize > math.MaxInt32 {
  1032  			req.PageSize = math.MaxInt32
  1033  		} else if pageSize != 0 {
  1034  			req.PageSize = int32(pageSize)
  1035  		}
  1036  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1037  			var err error
  1038  			resp, err = executeRPC(ctx, c.metadataClient.ListArtifacts, req, settings.GRPC, c.logger, "ListArtifacts")
  1039  			return err
  1040  		}, opts...)
  1041  		if err != nil {
  1042  			return nil, "", err
  1043  		}
  1044  
  1045  		it.Response = resp
  1046  		return resp.GetArtifacts(), resp.GetNextPageToken(), nil
  1047  	}
  1048  	fetch := func(pageSize int, pageToken string) (string, error) {
  1049  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1050  		if err != nil {
  1051  			return "", err
  1052  		}
  1053  		it.items = append(it.items, items...)
  1054  		return nextPageToken, nil
  1055  	}
  1056  
  1057  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1058  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1059  	it.pageInfo.Token = req.GetPageToken()
  1060  
  1061  	return it
  1062  }
  1063  
  1064  func (c *metadataGRPCClient) UpdateArtifact(ctx context.Context, req *aiplatformpb.UpdateArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
  1065  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "artifact.name", url.QueryEscape(req.GetArtifact().GetName()))}
  1066  
  1067  	hds = append(c.xGoogHeaders, hds...)
  1068  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1069  	opts = append((*c.CallOptions).UpdateArtifact[0:len((*c.CallOptions).UpdateArtifact):len((*c.CallOptions).UpdateArtifact)], opts...)
  1070  	var resp *aiplatformpb.Artifact
  1071  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1072  		var err error
  1073  		resp, err = executeRPC(ctx, c.metadataClient.UpdateArtifact, req, settings.GRPC, c.logger, "UpdateArtifact")
  1074  		return err
  1075  	}, opts...)
  1076  	if err != nil {
  1077  		return nil, err
  1078  	}
  1079  	return resp, nil
  1080  }
  1081  
  1082  func (c *metadataGRPCClient) DeleteArtifact(ctx context.Context, req *aiplatformpb.DeleteArtifactRequest, opts ...gax.CallOption) (*DeleteArtifactOperation, error) {
  1083  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1084  
  1085  	hds = append(c.xGoogHeaders, hds...)
  1086  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1087  	opts = append((*c.CallOptions).DeleteArtifact[0:len((*c.CallOptions).DeleteArtifact):len((*c.CallOptions).DeleteArtifact)], opts...)
  1088  	var resp *longrunningpb.Operation
  1089  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1090  		var err error
  1091  		resp, err = executeRPC(ctx, c.metadataClient.DeleteArtifact, req, settings.GRPC, c.logger, "DeleteArtifact")
  1092  		return err
  1093  	}, opts...)
  1094  	if err != nil {
  1095  		return nil, err
  1096  	}
  1097  	return &DeleteArtifactOperation{
  1098  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1099  	}, nil
  1100  }
  1101  
  1102  func (c *metadataGRPCClient) PurgeArtifacts(ctx context.Context, req *aiplatformpb.PurgeArtifactsRequest, opts ...gax.CallOption) (*PurgeArtifactsOperation, error) {
  1103  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1104  
  1105  	hds = append(c.xGoogHeaders, hds...)
  1106  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1107  	opts = append((*c.CallOptions).PurgeArtifacts[0:len((*c.CallOptions).PurgeArtifacts):len((*c.CallOptions).PurgeArtifacts)], opts...)
  1108  	var resp *longrunningpb.Operation
  1109  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1110  		var err error
  1111  		resp, err = executeRPC(ctx, c.metadataClient.PurgeArtifacts, req, settings.GRPC, c.logger, "PurgeArtifacts")
  1112  		return err
  1113  	}, opts...)
  1114  	if err != nil {
  1115  		return nil, err
  1116  	}
  1117  	return &PurgeArtifactsOperation{
  1118  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1119  	}, nil
  1120  }
  1121  
  1122  func (c *metadataGRPCClient) CreateContext(ctx context.Context, req *aiplatformpb.CreateContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
  1123  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1124  
  1125  	hds = append(c.xGoogHeaders, hds...)
  1126  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1127  	opts = append((*c.CallOptions).CreateContext[0:len((*c.CallOptions).CreateContext):len((*c.CallOptions).CreateContext)], opts...)
  1128  	var resp *aiplatformpb.Context
  1129  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1130  		var err error
  1131  		resp, err = executeRPC(ctx, c.metadataClient.CreateContext, req, settings.GRPC, c.logger, "CreateContext")
  1132  		return err
  1133  	}, opts...)
  1134  	if err != nil {
  1135  		return nil, err
  1136  	}
  1137  	return resp, nil
  1138  }
  1139  
  1140  func (c *metadataGRPCClient) GetContext(ctx context.Context, req *aiplatformpb.GetContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
  1141  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1142  
  1143  	hds = append(c.xGoogHeaders, hds...)
  1144  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1145  	opts = append((*c.CallOptions).GetContext[0:len((*c.CallOptions).GetContext):len((*c.CallOptions).GetContext)], opts...)
  1146  	var resp *aiplatformpb.Context
  1147  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1148  		var err error
  1149  		resp, err = executeRPC(ctx, c.metadataClient.GetContext, req, settings.GRPC, c.logger, "GetContext")
  1150  		return err
  1151  	}, opts...)
  1152  	if err != nil {
  1153  		return nil, err
  1154  	}
  1155  	return resp, nil
  1156  }
  1157  
  1158  func (c *metadataGRPCClient) ListContexts(ctx context.Context, req *aiplatformpb.ListContextsRequest, opts ...gax.CallOption) *ContextIterator {
  1159  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1160  
  1161  	hds = append(c.xGoogHeaders, hds...)
  1162  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1163  	opts = append((*c.CallOptions).ListContexts[0:len((*c.CallOptions).ListContexts):len((*c.CallOptions).ListContexts)], opts...)
  1164  	it := &ContextIterator{}
  1165  	req = proto.Clone(req).(*aiplatformpb.ListContextsRequest)
  1166  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Context, string, error) {
  1167  		resp := &aiplatformpb.ListContextsResponse{}
  1168  		if pageToken != "" {
  1169  			req.PageToken = pageToken
  1170  		}
  1171  		if pageSize > math.MaxInt32 {
  1172  			req.PageSize = math.MaxInt32
  1173  		} else if pageSize != 0 {
  1174  			req.PageSize = int32(pageSize)
  1175  		}
  1176  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1177  			var err error
  1178  			resp, err = executeRPC(ctx, c.metadataClient.ListContexts, req, settings.GRPC, c.logger, "ListContexts")
  1179  			return err
  1180  		}, opts...)
  1181  		if err != nil {
  1182  			return nil, "", err
  1183  		}
  1184  
  1185  		it.Response = resp
  1186  		return resp.GetContexts(), resp.GetNextPageToken(), nil
  1187  	}
  1188  	fetch := func(pageSize int, pageToken string) (string, error) {
  1189  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1190  		if err != nil {
  1191  			return "", err
  1192  		}
  1193  		it.items = append(it.items, items...)
  1194  		return nextPageToken, nil
  1195  	}
  1196  
  1197  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1198  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1199  	it.pageInfo.Token = req.GetPageToken()
  1200  
  1201  	return it
  1202  }
  1203  
  1204  func (c *metadataGRPCClient) UpdateContext(ctx context.Context, req *aiplatformpb.UpdateContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
  1205  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context.name", url.QueryEscape(req.GetContext().GetName()))}
  1206  
  1207  	hds = append(c.xGoogHeaders, hds...)
  1208  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1209  	opts = append((*c.CallOptions).UpdateContext[0:len((*c.CallOptions).UpdateContext):len((*c.CallOptions).UpdateContext)], opts...)
  1210  	var resp *aiplatformpb.Context
  1211  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1212  		var err error
  1213  		resp, err = executeRPC(ctx, c.metadataClient.UpdateContext, req, settings.GRPC, c.logger, "UpdateContext")
  1214  		return err
  1215  	}, opts...)
  1216  	if err != nil {
  1217  		return nil, err
  1218  	}
  1219  	return resp, nil
  1220  }
  1221  
  1222  func (c *metadataGRPCClient) DeleteContext(ctx context.Context, req *aiplatformpb.DeleteContextRequest, opts ...gax.CallOption) (*DeleteContextOperation, error) {
  1223  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1224  
  1225  	hds = append(c.xGoogHeaders, hds...)
  1226  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1227  	opts = append((*c.CallOptions).DeleteContext[0:len((*c.CallOptions).DeleteContext):len((*c.CallOptions).DeleteContext)], opts...)
  1228  	var resp *longrunningpb.Operation
  1229  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1230  		var err error
  1231  		resp, err = executeRPC(ctx, c.metadataClient.DeleteContext, req, settings.GRPC, c.logger, "DeleteContext")
  1232  		return err
  1233  	}, opts...)
  1234  	if err != nil {
  1235  		return nil, err
  1236  	}
  1237  	return &DeleteContextOperation{
  1238  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1239  	}, nil
  1240  }
  1241  
  1242  func (c *metadataGRPCClient) PurgeContexts(ctx context.Context, req *aiplatformpb.PurgeContextsRequest, opts ...gax.CallOption) (*PurgeContextsOperation, error) {
  1243  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1244  
  1245  	hds = append(c.xGoogHeaders, hds...)
  1246  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1247  	opts = append((*c.CallOptions).PurgeContexts[0:len((*c.CallOptions).PurgeContexts):len((*c.CallOptions).PurgeContexts)], opts...)
  1248  	var resp *longrunningpb.Operation
  1249  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1250  		var err error
  1251  		resp, err = executeRPC(ctx, c.metadataClient.PurgeContexts, req, settings.GRPC, c.logger, "PurgeContexts")
  1252  		return err
  1253  	}, opts...)
  1254  	if err != nil {
  1255  		return nil, err
  1256  	}
  1257  	return &PurgeContextsOperation{
  1258  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1259  	}, nil
  1260  }
  1261  
  1262  func (c *metadataGRPCClient) AddContextArtifactsAndExecutions(ctx context.Context, req *aiplatformpb.AddContextArtifactsAndExecutionsRequest, opts ...gax.CallOption) (*aiplatformpb.AddContextArtifactsAndExecutionsResponse, error) {
  1263  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  1264  
  1265  	hds = append(c.xGoogHeaders, hds...)
  1266  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1267  	opts = append((*c.CallOptions).AddContextArtifactsAndExecutions[0:len((*c.CallOptions).AddContextArtifactsAndExecutions):len((*c.CallOptions).AddContextArtifactsAndExecutions)], opts...)
  1268  	var resp *aiplatformpb.AddContextArtifactsAndExecutionsResponse
  1269  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1270  		var err error
  1271  		resp, err = executeRPC(ctx, c.metadataClient.AddContextArtifactsAndExecutions, req, settings.GRPC, c.logger, "AddContextArtifactsAndExecutions")
  1272  		return err
  1273  	}, opts...)
  1274  	if err != nil {
  1275  		return nil, err
  1276  	}
  1277  	return resp, nil
  1278  }
  1279  
  1280  func (c *metadataGRPCClient) AddContextChildren(ctx context.Context, req *aiplatformpb.AddContextChildrenRequest, opts ...gax.CallOption) (*aiplatformpb.AddContextChildrenResponse, error) {
  1281  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  1282  
  1283  	hds = append(c.xGoogHeaders, hds...)
  1284  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1285  	opts = append((*c.CallOptions).AddContextChildren[0:len((*c.CallOptions).AddContextChildren):len((*c.CallOptions).AddContextChildren)], opts...)
  1286  	var resp *aiplatformpb.AddContextChildrenResponse
  1287  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1288  		var err error
  1289  		resp, err = executeRPC(ctx, c.metadataClient.AddContextChildren, req, settings.GRPC, c.logger, "AddContextChildren")
  1290  		return err
  1291  	}, opts...)
  1292  	if err != nil {
  1293  		return nil, err
  1294  	}
  1295  	return resp, nil
  1296  }
  1297  
  1298  func (c *metadataGRPCClient) RemoveContextChildren(ctx context.Context, req *aiplatformpb.RemoveContextChildrenRequest, opts ...gax.CallOption) (*aiplatformpb.RemoveContextChildrenResponse, error) {
  1299  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  1300  
  1301  	hds = append(c.xGoogHeaders, hds...)
  1302  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1303  	opts = append((*c.CallOptions).RemoveContextChildren[0:len((*c.CallOptions).RemoveContextChildren):len((*c.CallOptions).RemoveContextChildren)], opts...)
  1304  	var resp *aiplatformpb.RemoveContextChildrenResponse
  1305  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1306  		var err error
  1307  		resp, err = executeRPC(ctx, c.metadataClient.RemoveContextChildren, req, settings.GRPC, c.logger, "RemoveContextChildren")
  1308  		return err
  1309  	}, opts...)
  1310  	if err != nil {
  1311  		return nil, err
  1312  	}
  1313  	return resp, nil
  1314  }
  1315  
  1316  func (c *metadataGRPCClient) QueryContextLineageSubgraph(ctx context.Context, req *aiplatformpb.QueryContextLineageSubgraphRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
  1317  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  1318  
  1319  	hds = append(c.xGoogHeaders, hds...)
  1320  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1321  	opts = append((*c.CallOptions).QueryContextLineageSubgraph[0:len((*c.CallOptions).QueryContextLineageSubgraph):len((*c.CallOptions).QueryContextLineageSubgraph)], opts...)
  1322  	var resp *aiplatformpb.LineageSubgraph
  1323  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1324  		var err error
  1325  		resp, err = executeRPC(ctx, c.metadataClient.QueryContextLineageSubgraph, req, settings.GRPC, c.logger, "QueryContextLineageSubgraph")
  1326  		return err
  1327  	}, opts...)
  1328  	if err != nil {
  1329  		return nil, err
  1330  	}
  1331  	return resp, nil
  1332  }
  1333  
  1334  func (c *metadataGRPCClient) CreateExecution(ctx context.Context, req *aiplatformpb.CreateExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
  1335  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1336  
  1337  	hds = append(c.xGoogHeaders, hds...)
  1338  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1339  	opts = append((*c.CallOptions).CreateExecution[0:len((*c.CallOptions).CreateExecution):len((*c.CallOptions).CreateExecution)], opts...)
  1340  	var resp *aiplatformpb.Execution
  1341  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1342  		var err error
  1343  		resp, err = executeRPC(ctx, c.metadataClient.CreateExecution, req, settings.GRPC, c.logger, "CreateExecution")
  1344  		return err
  1345  	}, opts...)
  1346  	if err != nil {
  1347  		return nil, err
  1348  	}
  1349  	return resp, nil
  1350  }
  1351  
  1352  func (c *metadataGRPCClient) GetExecution(ctx context.Context, req *aiplatformpb.GetExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
  1353  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1354  
  1355  	hds = append(c.xGoogHeaders, hds...)
  1356  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1357  	opts = append((*c.CallOptions).GetExecution[0:len((*c.CallOptions).GetExecution):len((*c.CallOptions).GetExecution)], opts...)
  1358  	var resp *aiplatformpb.Execution
  1359  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1360  		var err error
  1361  		resp, err = executeRPC(ctx, c.metadataClient.GetExecution, req, settings.GRPC, c.logger, "GetExecution")
  1362  		return err
  1363  	}, opts...)
  1364  	if err != nil {
  1365  		return nil, err
  1366  	}
  1367  	return resp, nil
  1368  }
  1369  
  1370  func (c *metadataGRPCClient) ListExecutions(ctx context.Context, req *aiplatformpb.ListExecutionsRequest, opts ...gax.CallOption) *ExecutionIterator {
  1371  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1372  
  1373  	hds = append(c.xGoogHeaders, hds...)
  1374  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1375  	opts = append((*c.CallOptions).ListExecutions[0:len((*c.CallOptions).ListExecutions):len((*c.CallOptions).ListExecutions)], opts...)
  1376  	it := &ExecutionIterator{}
  1377  	req = proto.Clone(req).(*aiplatformpb.ListExecutionsRequest)
  1378  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Execution, string, error) {
  1379  		resp := &aiplatformpb.ListExecutionsResponse{}
  1380  		if pageToken != "" {
  1381  			req.PageToken = pageToken
  1382  		}
  1383  		if pageSize > math.MaxInt32 {
  1384  			req.PageSize = math.MaxInt32
  1385  		} else if pageSize != 0 {
  1386  			req.PageSize = int32(pageSize)
  1387  		}
  1388  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1389  			var err error
  1390  			resp, err = executeRPC(ctx, c.metadataClient.ListExecutions, req, settings.GRPC, c.logger, "ListExecutions")
  1391  			return err
  1392  		}, opts...)
  1393  		if err != nil {
  1394  			return nil, "", err
  1395  		}
  1396  
  1397  		it.Response = resp
  1398  		return resp.GetExecutions(), resp.GetNextPageToken(), nil
  1399  	}
  1400  	fetch := func(pageSize int, pageToken string) (string, error) {
  1401  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1402  		if err != nil {
  1403  			return "", err
  1404  		}
  1405  		it.items = append(it.items, items...)
  1406  		return nextPageToken, nil
  1407  	}
  1408  
  1409  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1410  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1411  	it.pageInfo.Token = req.GetPageToken()
  1412  
  1413  	return it
  1414  }
  1415  
  1416  func (c *metadataGRPCClient) UpdateExecution(ctx context.Context, req *aiplatformpb.UpdateExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
  1417  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "execution.name", url.QueryEscape(req.GetExecution().GetName()))}
  1418  
  1419  	hds = append(c.xGoogHeaders, hds...)
  1420  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1421  	opts = append((*c.CallOptions).UpdateExecution[0:len((*c.CallOptions).UpdateExecution):len((*c.CallOptions).UpdateExecution)], opts...)
  1422  	var resp *aiplatformpb.Execution
  1423  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1424  		var err error
  1425  		resp, err = executeRPC(ctx, c.metadataClient.UpdateExecution, req, settings.GRPC, c.logger, "UpdateExecution")
  1426  		return err
  1427  	}, opts...)
  1428  	if err != nil {
  1429  		return nil, err
  1430  	}
  1431  	return resp, nil
  1432  }
  1433  
  1434  func (c *metadataGRPCClient) DeleteExecution(ctx context.Context, req *aiplatformpb.DeleteExecutionRequest, opts ...gax.CallOption) (*DeleteExecutionOperation, error) {
  1435  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1436  
  1437  	hds = append(c.xGoogHeaders, hds...)
  1438  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1439  	opts = append((*c.CallOptions).DeleteExecution[0:len((*c.CallOptions).DeleteExecution):len((*c.CallOptions).DeleteExecution)], opts...)
  1440  	var resp *longrunningpb.Operation
  1441  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1442  		var err error
  1443  		resp, err = executeRPC(ctx, c.metadataClient.DeleteExecution, req, settings.GRPC, c.logger, "DeleteExecution")
  1444  		return err
  1445  	}, opts...)
  1446  	if err != nil {
  1447  		return nil, err
  1448  	}
  1449  	return &DeleteExecutionOperation{
  1450  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1451  	}, nil
  1452  }
  1453  
  1454  func (c *metadataGRPCClient) PurgeExecutions(ctx context.Context, req *aiplatformpb.PurgeExecutionsRequest, opts ...gax.CallOption) (*PurgeExecutionsOperation, error) {
  1455  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1456  
  1457  	hds = append(c.xGoogHeaders, hds...)
  1458  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1459  	opts = append((*c.CallOptions).PurgeExecutions[0:len((*c.CallOptions).PurgeExecutions):len((*c.CallOptions).PurgeExecutions)], opts...)
  1460  	var resp *longrunningpb.Operation
  1461  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1462  		var err error
  1463  		resp, err = executeRPC(ctx, c.metadataClient.PurgeExecutions, req, settings.GRPC, c.logger, "PurgeExecutions")
  1464  		return err
  1465  	}, opts...)
  1466  	if err != nil {
  1467  		return nil, err
  1468  	}
  1469  	return &PurgeExecutionsOperation{
  1470  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1471  	}, nil
  1472  }
  1473  
  1474  func (c *metadataGRPCClient) AddExecutionEvents(ctx context.Context, req *aiplatformpb.AddExecutionEventsRequest, opts ...gax.CallOption) (*aiplatformpb.AddExecutionEventsResponse, error) {
  1475  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "execution", url.QueryEscape(req.GetExecution()))}
  1476  
  1477  	hds = append(c.xGoogHeaders, hds...)
  1478  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1479  	opts = append((*c.CallOptions).AddExecutionEvents[0:len((*c.CallOptions).AddExecutionEvents):len((*c.CallOptions).AddExecutionEvents)], opts...)
  1480  	var resp *aiplatformpb.AddExecutionEventsResponse
  1481  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1482  		var err error
  1483  		resp, err = executeRPC(ctx, c.metadataClient.AddExecutionEvents, req, settings.GRPC, c.logger, "AddExecutionEvents")
  1484  		return err
  1485  	}, opts...)
  1486  	if err != nil {
  1487  		return nil, err
  1488  	}
  1489  	return resp, nil
  1490  }
  1491  
  1492  func (c *metadataGRPCClient) QueryExecutionInputsAndOutputs(ctx context.Context, req *aiplatformpb.QueryExecutionInputsAndOutputsRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
  1493  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "execution", url.QueryEscape(req.GetExecution()))}
  1494  
  1495  	hds = append(c.xGoogHeaders, hds...)
  1496  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1497  	opts = append((*c.CallOptions).QueryExecutionInputsAndOutputs[0:len((*c.CallOptions).QueryExecutionInputsAndOutputs):len((*c.CallOptions).QueryExecutionInputsAndOutputs)], opts...)
  1498  	var resp *aiplatformpb.LineageSubgraph
  1499  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1500  		var err error
  1501  		resp, err = executeRPC(ctx, c.metadataClient.QueryExecutionInputsAndOutputs, req, settings.GRPC, c.logger, "QueryExecutionInputsAndOutputs")
  1502  		return err
  1503  	}, opts...)
  1504  	if err != nil {
  1505  		return nil, err
  1506  	}
  1507  	return resp, nil
  1508  }
  1509  
  1510  func (c *metadataGRPCClient) CreateMetadataSchema(ctx context.Context, req *aiplatformpb.CreateMetadataSchemaRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataSchema, error) {
  1511  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1512  
  1513  	hds = append(c.xGoogHeaders, hds...)
  1514  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1515  	opts = append((*c.CallOptions).CreateMetadataSchema[0:len((*c.CallOptions).CreateMetadataSchema):len((*c.CallOptions).CreateMetadataSchema)], opts...)
  1516  	var resp *aiplatformpb.MetadataSchema
  1517  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1518  		var err error
  1519  		resp, err = executeRPC(ctx, c.metadataClient.CreateMetadataSchema, req, settings.GRPC, c.logger, "CreateMetadataSchema")
  1520  		return err
  1521  	}, opts...)
  1522  	if err != nil {
  1523  		return nil, err
  1524  	}
  1525  	return resp, nil
  1526  }
  1527  
  1528  func (c *metadataGRPCClient) GetMetadataSchema(ctx context.Context, req *aiplatformpb.GetMetadataSchemaRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataSchema, error) {
  1529  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1530  
  1531  	hds = append(c.xGoogHeaders, hds...)
  1532  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1533  	opts = append((*c.CallOptions).GetMetadataSchema[0:len((*c.CallOptions).GetMetadataSchema):len((*c.CallOptions).GetMetadataSchema)], opts...)
  1534  	var resp *aiplatformpb.MetadataSchema
  1535  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1536  		var err error
  1537  		resp, err = executeRPC(ctx, c.metadataClient.GetMetadataSchema, req, settings.GRPC, c.logger, "GetMetadataSchema")
  1538  		return err
  1539  	}, opts...)
  1540  	if err != nil {
  1541  		return nil, err
  1542  	}
  1543  	return resp, nil
  1544  }
  1545  
  1546  func (c *metadataGRPCClient) ListMetadataSchemas(ctx context.Context, req *aiplatformpb.ListMetadataSchemasRequest, opts ...gax.CallOption) *MetadataSchemaIterator {
  1547  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1548  
  1549  	hds = append(c.xGoogHeaders, hds...)
  1550  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1551  	opts = append((*c.CallOptions).ListMetadataSchemas[0:len((*c.CallOptions).ListMetadataSchemas):len((*c.CallOptions).ListMetadataSchemas)], opts...)
  1552  	it := &MetadataSchemaIterator{}
  1553  	req = proto.Clone(req).(*aiplatformpb.ListMetadataSchemasRequest)
  1554  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.MetadataSchema, string, error) {
  1555  		resp := &aiplatformpb.ListMetadataSchemasResponse{}
  1556  		if pageToken != "" {
  1557  			req.PageToken = pageToken
  1558  		}
  1559  		if pageSize > math.MaxInt32 {
  1560  			req.PageSize = math.MaxInt32
  1561  		} else if pageSize != 0 {
  1562  			req.PageSize = int32(pageSize)
  1563  		}
  1564  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1565  			var err error
  1566  			resp, err = executeRPC(ctx, c.metadataClient.ListMetadataSchemas, req, settings.GRPC, c.logger, "ListMetadataSchemas")
  1567  			return err
  1568  		}, opts...)
  1569  		if err != nil {
  1570  			return nil, "", err
  1571  		}
  1572  
  1573  		it.Response = resp
  1574  		return resp.GetMetadataSchemas(), resp.GetNextPageToken(), nil
  1575  	}
  1576  	fetch := func(pageSize int, pageToken string) (string, error) {
  1577  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1578  		if err != nil {
  1579  			return "", err
  1580  		}
  1581  		it.items = append(it.items, items...)
  1582  		return nextPageToken, nil
  1583  	}
  1584  
  1585  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1586  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1587  	it.pageInfo.Token = req.GetPageToken()
  1588  
  1589  	return it
  1590  }
  1591  
  1592  func (c *metadataGRPCClient) QueryArtifactLineageSubgraph(ctx context.Context, req *aiplatformpb.QueryArtifactLineageSubgraphRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
  1593  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "artifact", url.QueryEscape(req.GetArtifact()))}
  1594  
  1595  	hds = append(c.xGoogHeaders, hds...)
  1596  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1597  	opts = append((*c.CallOptions).QueryArtifactLineageSubgraph[0:len((*c.CallOptions).QueryArtifactLineageSubgraph):len((*c.CallOptions).QueryArtifactLineageSubgraph)], opts...)
  1598  	var resp *aiplatformpb.LineageSubgraph
  1599  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1600  		var err error
  1601  		resp, err = executeRPC(ctx, c.metadataClient.QueryArtifactLineageSubgraph, req, settings.GRPC, c.logger, "QueryArtifactLineageSubgraph")
  1602  		return err
  1603  	}, opts...)
  1604  	if err != nil {
  1605  		return nil, err
  1606  	}
  1607  	return resp, nil
  1608  }
  1609  
  1610  func (c *metadataGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1611  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1612  
  1613  	hds = append(c.xGoogHeaders, hds...)
  1614  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1615  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1616  	var resp *locationpb.Location
  1617  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1618  		var err error
  1619  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
  1620  		return err
  1621  	}, opts...)
  1622  	if err != nil {
  1623  		return nil, err
  1624  	}
  1625  	return resp, nil
  1626  }
  1627  
  1628  func (c *metadataGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1629  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1630  
  1631  	hds = append(c.xGoogHeaders, hds...)
  1632  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1633  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
  1634  	it := &LocationIterator{}
  1635  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1636  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1637  		resp := &locationpb.ListLocationsResponse{}
  1638  		if pageToken != "" {
  1639  			req.PageToken = pageToken
  1640  		}
  1641  		if pageSize > math.MaxInt32 {
  1642  			req.PageSize = math.MaxInt32
  1643  		} else if pageSize != 0 {
  1644  			req.PageSize = int32(pageSize)
  1645  		}
  1646  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1647  			var err error
  1648  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
  1649  			return err
  1650  		}, opts...)
  1651  		if err != nil {
  1652  			return nil, "", err
  1653  		}
  1654  
  1655  		it.Response = resp
  1656  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1657  	}
  1658  	fetch := func(pageSize int, pageToken string) (string, error) {
  1659  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1660  		if err != nil {
  1661  			return "", err
  1662  		}
  1663  		it.items = append(it.items, items...)
  1664  		return nextPageToken, nil
  1665  	}
  1666  
  1667  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1668  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1669  	it.pageInfo.Token = req.GetPageToken()
  1670  
  1671  	return it
  1672  }
  1673  
  1674  func (c *metadataGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1675  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1676  
  1677  	hds = append(c.xGoogHeaders, hds...)
  1678  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1679  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1680  	var resp *iampb.Policy
  1681  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1682  		var err error
  1683  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
  1684  		return err
  1685  	}, opts...)
  1686  	if err != nil {
  1687  		return nil, err
  1688  	}
  1689  	return resp, nil
  1690  }
  1691  
  1692  func (c *metadataGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1693  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1694  
  1695  	hds = append(c.xGoogHeaders, hds...)
  1696  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1697  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1698  	var resp *iampb.Policy
  1699  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1700  		var err error
  1701  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
  1702  		return err
  1703  	}, opts...)
  1704  	if err != nil {
  1705  		return nil, err
  1706  	}
  1707  	return resp, nil
  1708  }
  1709  
  1710  func (c *metadataGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1711  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1712  
  1713  	hds = append(c.xGoogHeaders, hds...)
  1714  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1715  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1716  	var resp *iampb.TestIamPermissionsResponse
  1717  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1718  		var err error
  1719  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
  1720  		return err
  1721  	}, opts...)
  1722  	if err != nil {
  1723  		return nil, err
  1724  	}
  1725  	return resp, nil
  1726  }
  1727  
  1728  func (c *metadataGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1729  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1730  
  1731  	hds = append(c.xGoogHeaders, hds...)
  1732  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1733  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
  1734  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1735  		var err error
  1736  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
  1737  		return err
  1738  	}, opts...)
  1739  	return err
  1740  }
  1741  
  1742  func (c *metadataGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1743  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1744  
  1745  	hds = append(c.xGoogHeaders, hds...)
  1746  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1747  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
  1748  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1749  		var err error
  1750  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
  1751  		return err
  1752  	}, opts...)
  1753  	return err
  1754  }
  1755  
  1756  func (c *metadataGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1757  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1758  
  1759  	hds = append(c.xGoogHeaders, hds...)
  1760  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1761  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1762  	var resp *longrunningpb.Operation
  1763  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1764  		var err error
  1765  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
  1766  		return err
  1767  	}, opts...)
  1768  	if err != nil {
  1769  		return nil, err
  1770  	}
  1771  	return resp, nil
  1772  }
  1773  
  1774  func (c *metadataGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1775  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1776  
  1777  	hds = append(c.xGoogHeaders, hds...)
  1778  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1779  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
  1780  	it := &OperationIterator{}
  1781  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1782  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1783  		resp := &longrunningpb.ListOperationsResponse{}
  1784  		if pageToken != "" {
  1785  			req.PageToken = pageToken
  1786  		}
  1787  		if pageSize > math.MaxInt32 {
  1788  			req.PageSize = math.MaxInt32
  1789  		} else if pageSize != 0 {
  1790  			req.PageSize = int32(pageSize)
  1791  		}
  1792  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1793  			var err error
  1794  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
  1795  			return err
  1796  		}, opts...)
  1797  		if err != nil {
  1798  			return nil, "", err
  1799  		}
  1800  
  1801  		it.Response = resp
  1802  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1803  	}
  1804  	fetch := func(pageSize int, pageToken string) (string, error) {
  1805  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1806  		if err != nil {
  1807  			return "", err
  1808  		}
  1809  		it.items = append(it.items, items...)
  1810  		return nextPageToken, nil
  1811  	}
  1812  
  1813  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1814  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1815  	it.pageInfo.Token = req.GetPageToken()
  1816  
  1817  	return it
  1818  }
  1819  
  1820  func (c *metadataGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1821  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1822  
  1823  	hds = append(c.xGoogHeaders, hds...)
  1824  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1825  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1826  	var resp *longrunningpb.Operation
  1827  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1828  		var err error
  1829  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
  1830  		return err
  1831  	}, opts...)
  1832  	if err != nil {
  1833  		return nil, err
  1834  	}
  1835  	return resp, nil
  1836  }
  1837  
  1838  // CreateMetadataStore initializes a MetadataStore, including allocation of resources.
  1839  func (c *metadataRESTClient) CreateMetadataStore(ctx context.Context, req *aiplatformpb.CreateMetadataStoreRequest, opts ...gax.CallOption) (*CreateMetadataStoreOperation, error) {
  1840  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1841  	body := req.GetMetadataStore()
  1842  	jsonReq, err := m.Marshal(body)
  1843  	if err != nil {
  1844  		return nil, err
  1845  	}
  1846  
  1847  	baseUrl, err := url.Parse(c.endpoint)
  1848  	if err != nil {
  1849  		return nil, err
  1850  	}
  1851  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/metadataStores", req.GetParent())
  1852  
  1853  	params := url.Values{}
  1854  	params.Add("$alt", "json;enum-encoding=int")
  1855  	if req.GetMetadataStoreId() != "" {
  1856  		params.Add("metadataStoreId", fmt.Sprintf("%v", req.GetMetadataStoreId()))
  1857  	}
  1858  
  1859  	baseUrl.RawQuery = params.Encode()
  1860  
  1861  	// Build HTTP headers from client and context metadata.
  1862  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1863  
  1864  	hds = append(c.xGoogHeaders, hds...)
  1865  	hds = append(hds, "Content-Type", "application/json")
  1866  	headers := gax.BuildHeaders(ctx, hds...)
  1867  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1868  	resp := &longrunningpb.Operation{}
  1869  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1870  		if settings.Path != "" {
  1871  			baseUrl.Path = settings.Path
  1872  		}
  1873  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1874  		if err != nil {
  1875  			return err
  1876  		}
  1877  		httpReq = httpReq.WithContext(ctx)
  1878  		httpReq.Header = headers
  1879  
  1880  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateMetadataStore")
  1881  		if err != nil {
  1882  			return err
  1883  		}
  1884  		if err := unm.Unmarshal(buf, resp); err != nil {
  1885  			return err
  1886  		}
  1887  
  1888  		return nil
  1889  	}, opts...)
  1890  	if e != nil {
  1891  		return nil, e
  1892  	}
  1893  
  1894  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1895  	return &CreateMetadataStoreOperation{
  1896  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1897  		pollPath: override,
  1898  	}, nil
  1899  }
  1900  
  1901  // GetMetadataStore retrieves a specific MetadataStore.
  1902  func (c *metadataRESTClient) GetMetadataStore(ctx context.Context, req *aiplatformpb.GetMetadataStoreRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataStore, error) {
  1903  	baseUrl, err := url.Parse(c.endpoint)
  1904  	if err != nil {
  1905  		return nil, err
  1906  	}
  1907  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1908  
  1909  	params := url.Values{}
  1910  	params.Add("$alt", "json;enum-encoding=int")
  1911  
  1912  	baseUrl.RawQuery = params.Encode()
  1913  
  1914  	// Build HTTP headers from client and context metadata.
  1915  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1916  
  1917  	hds = append(c.xGoogHeaders, hds...)
  1918  	hds = append(hds, "Content-Type", "application/json")
  1919  	headers := gax.BuildHeaders(ctx, hds...)
  1920  	opts = append((*c.CallOptions).GetMetadataStore[0:len((*c.CallOptions).GetMetadataStore):len((*c.CallOptions).GetMetadataStore)], opts...)
  1921  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1922  	resp := &aiplatformpb.MetadataStore{}
  1923  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1924  		if settings.Path != "" {
  1925  			baseUrl.Path = settings.Path
  1926  		}
  1927  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1928  		if err != nil {
  1929  			return err
  1930  		}
  1931  		httpReq = httpReq.WithContext(ctx)
  1932  		httpReq.Header = headers
  1933  
  1934  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetMetadataStore")
  1935  		if err != nil {
  1936  			return err
  1937  		}
  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  	return resp, nil
  1949  }
  1950  
  1951  // ListMetadataStores lists MetadataStores for a Location.
  1952  func (c *metadataRESTClient) ListMetadataStores(ctx context.Context, req *aiplatformpb.ListMetadataStoresRequest, opts ...gax.CallOption) *MetadataStoreIterator {
  1953  	it := &MetadataStoreIterator{}
  1954  	req = proto.Clone(req).(*aiplatformpb.ListMetadataStoresRequest)
  1955  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1956  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.MetadataStore, string, error) {
  1957  		resp := &aiplatformpb.ListMetadataStoresResponse{}
  1958  		if pageToken != "" {
  1959  			req.PageToken = pageToken
  1960  		}
  1961  		if pageSize > math.MaxInt32 {
  1962  			req.PageSize = math.MaxInt32
  1963  		} else if pageSize != 0 {
  1964  			req.PageSize = int32(pageSize)
  1965  		}
  1966  		baseUrl, err := url.Parse(c.endpoint)
  1967  		if err != nil {
  1968  			return nil, "", err
  1969  		}
  1970  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/metadataStores", req.GetParent())
  1971  
  1972  		params := url.Values{}
  1973  		params.Add("$alt", "json;enum-encoding=int")
  1974  		if req.GetPageSize() != 0 {
  1975  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1976  		}
  1977  		if req.GetPageToken() != "" {
  1978  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1979  		}
  1980  
  1981  		baseUrl.RawQuery = params.Encode()
  1982  
  1983  		// Build HTTP headers from client and context metadata.
  1984  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1985  		headers := gax.BuildHeaders(ctx, hds...)
  1986  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1987  			if settings.Path != "" {
  1988  				baseUrl.Path = settings.Path
  1989  			}
  1990  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1991  			if err != nil {
  1992  				return err
  1993  			}
  1994  			httpReq.Header = headers
  1995  
  1996  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListMetadataStores")
  1997  			if err != nil {
  1998  				return err
  1999  			}
  2000  			if err := unm.Unmarshal(buf, resp); err != nil {
  2001  				return err
  2002  			}
  2003  
  2004  			return nil
  2005  		}, opts...)
  2006  		if e != nil {
  2007  			return nil, "", e
  2008  		}
  2009  		it.Response = resp
  2010  		return resp.GetMetadataStores(), resp.GetNextPageToken(), nil
  2011  	}
  2012  
  2013  	fetch := func(pageSize int, pageToken string) (string, error) {
  2014  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2015  		if err != nil {
  2016  			return "", err
  2017  		}
  2018  		it.items = append(it.items, items...)
  2019  		return nextPageToken, nil
  2020  	}
  2021  
  2022  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2023  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2024  	it.pageInfo.Token = req.GetPageToken()
  2025  
  2026  	return it
  2027  }
  2028  
  2029  // DeleteMetadataStore deletes a single MetadataStore and all its child resources (Artifacts,
  2030  // Executions, and Contexts).
  2031  func (c *metadataRESTClient) DeleteMetadataStore(ctx context.Context, req *aiplatformpb.DeleteMetadataStoreRequest, opts ...gax.CallOption) (*DeleteMetadataStoreOperation, error) {
  2032  	baseUrl, err := url.Parse(c.endpoint)
  2033  	if err != nil {
  2034  		return nil, err
  2035  	}
  2036  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2037  
  2038  	params := url.Values{}
  2039  	params.Add("$alt", "json;enum-encoding=int")
  2040  	if req.GetForce() {
  2041  		params.Add("force", fmt.Sprintf("%v", req.GetForce()))
  2042  	}
  2043  
  2044  	baseUrl.RawQuery = params.Encode()
  2045  
  2046  	// Build HTTP headers from client and context metadata.
  2047  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2048  
  2049  	hds = append(c.xGoogHeaders, hds...)
  2050  	hds = append(hds, "Content-Type", "application/json")
  2051  	headers := gax.BuildHeaders(ctx, hds...)
  2052  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2053  	resp := &longrunningpb.Operation{}
  2054  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2055  		if settings.Path != "" {
  2056  			baseUrl.Path = settings.Path
  2057  		}
  2058  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2059  		if err != nil {
  2060  			return err
  2061  		}
  2062  		httpReq = httpReq.WithContext(ctx)
  2063  		httpReq.Header = headers
  2064  
  2065  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteMetadataStore")
  2066  		if err != nil {
  2067  			return err
  2068  		}
  2069  		if err := unm.Unmarshal(buf, resp); err != nil {
  2070  			return err
  2071  		}
  2072  
  2073  		return nil
  2074  	}, opts...)
  2075  	if e != nil {
  2076  		return nil, e
  2077  	}
  2078  
  2079  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2080  	return &DeleteMetadataStoreOperation{
  2081  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2082  		pollPath: override,
  2083  	}, nil
  2084  }
  2085  
  2086  // CreateArtifact creates an Artifact associated with a MetadataStore.
  2087  func (c *metadataRESTClient) CreateArtifact(ctx context.Context, req *aiplatformpb.CreateArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
  2088  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2089  	body := req.GetArtifact()
  2090  	jsonReq, err := m.Marshal(body)
  2091  	if err != nil {
  2092  		return nil, err
  2093  	}
  2094  
  2095  	baseUrl, err := url.Parse(c.endpoint)
  2096  	if err != nil {
  2097  		return nil, err
  2098  	}
  2099  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/artifacts", req.GetParent())
  2100  
  2101  	params := url.Values{}
  2102  	params.Add("$alt", "json;enum-encoding=int")
  2103  	if req.GetArtifactId() != "" {
  2104  		params.Add("artifactId", fmt.Sprintf("%v", req.GetArtifactId()))
  2105  	}
  2106  
  2107  	baseUrl.RawQuery = params.Encode()
  2108  
  2109  	// Build HTTP headers from client and context metadata.
  2110  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2111  
  2112  	hds = append(c.xGoogHeaders, hds...)
  2113  	hds = append(hds, "Content-Type", "application/json")
  2114  	headers := gax.BuildHeaders(ctx, hds...)
  2115  	opts = append((*c.CallOptions).CreateArtifact[0:len((*c.CallOptions).CreateArtifact):len((*c.CallOptions).CreateArtifact)], opts...)
  2116  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2117  	resp := &aiplatformpb.Artifact{}
  2118  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2119  		if settings.Path != "" {
  2120  			baseUrl.Path = settings.Path
  2121  		}
  2122  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2123  		if err != nil {
  2124  			return err
  2125  		}
  2126  		httpReq = httpReq.WithContext(ctx)
  2127  		httpReq.Header = headers
  2128  
  2129  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateArtifact")
  2130  		if err != nil {
  2131  			return err
  2132  		}
  2133  
  2134  		if err := unm.Unmarshal(buf, resp); err != nil {
  2135  			return err
  2136  		}
  2137  
  2138  		return nil
  2139  	}, opts...)
  2140  	if e != nil {
  2141  		return nil, e
  2142  	}
  2143  	return resp, nil
  2144  }
  2145  
  2146  // GetArtifact retrieves a specific Artifact.
  2147  func (c *metadataRESTClient) GetArtifact(ctx context.Context, req *aiplatformpb.GetArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
  2148  	baseUrl, err := url.Parse(c.endpoint)
  2149  	if err != nil {
  2150  		return nil, err
  2151  	}
  2152  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2153  
  2154  	params := url.Values{}
  2155  	params.Add("$alt", "json;enum-encoding=int")
  2156  
  2157  	baseUrl.RawQuery = params.Encode()
  2158  
  2159  	// Build HTTP headers from client and context metadata.
  2160  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2161  
  2162  	hds = append(c.xGoogHeaders, hds...)
  2163  	hds = append(hds, "Content-Type", "application/json")
  2164  	headers := gax.BuildHeaders(ctx, hds...)
  2165  	opts = append((*c.CallOptions).GetArtifact[0:len((*c.CallOptions).GetArtifact):len((*c.CallOptions).GetArtifact)], opts...)
  2166  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2167  	resp := &aiplatformpb.Artifact{}
  2168  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2169  		if settings.Path != "" {
  2170  			baseUrl.Path = settings.Path
  2171  		}
  2172  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2173  		if err != nil {
  2174  			return err
  2175  		}
  2176  		httpReq = httpReq.WithContext(ctx)
  2177  		httpReq.Header = headers
  2178  
  2179  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetArtifact")
  2180  		if err != nil {
  2181  			return err
  2182  		}
  2183  
  2184  		if err := unm.Unmarshal(buf, resp); err != nil {
  2185  			return err
  2186  		}
  2187  
  2188  		return nil
  2189  	}, opts...)
  2190  	if e != nil {
  2191  		return nil, e
  2192  	}
  2193  	return resp, nil
  2194  }
  2195  
  2196  // ListArtifacts lists Artifacts in the MetadataStore.
  2197  func (c *metadataRESTClient) ListArtifacts(ctx context.Context, req *aiplatformpb.ListArtifactsRequest, opts ...gax.CallOption) *ArtifactIterator {
  2198  	it := &ArtifactIterator{}
  2199  	req = proto.Clone(req).(*aiplatformpb.ListArtifactsRequest)
  2200  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2201  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Artifact, string, error) {
  2202  		resp := &aiplatformpb.ListArtifactsResponse{}
  2203  		if pageToken != "" {
  2204  			req.PageToken = pageToken
  2205  		}
  2206  		if pageSize > math.MaxInt32 {
  2207  			req.PageSize = math.MaxInt32
  2208  		} else if pageSize != 0 {
  2209  			req.PageSize = int32(pageSize)
  2210  		}
  2211  		baseUrl, err := url.Parse(c.endpoint)
  2212  		if err != nil {
  2213  			return nil, "", err
  2214  		}
  2215  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/artifacts", req.GetParent())
  2216  
  2217  		params := url.Values{}
  2218  		params.Add("$alt", "json;enum-encoding=int")
  2219  		if req.GetFilter() != "" {
  2220  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2221  		}
  2222  		if req.GetOrderBy() != "" {
  2223  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  2224  		}
  2225  		if req.GetPageSize() != 0 {
  2226  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2227  		}
  2228  		if req.GetPageToken() != "" {
  2229  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2230  		}
  2231  
  2232  		baseUrl.RawQuery = params.Encode()
  2233  
  2234  		// Build HTTP headers from client and context metadata.
  2235  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2236  		headers := gax.BuildHeaders(ctx, hds...)
  2237  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2238  			if settings.Path != "" {
  2239  				baseUrl.Path = settings.Path
  2240  			}
  2241  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2242  			if err != nil {
  2243  				return err
  2244  			}
  2245  			httpReq.Header = headers
  2246  
  2247  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListArtifacts")
  2248  			if err != nil {
  2249  				return err
  2250  			}
  2251  			if err := unm.Unmarshal(buf, resp); err != nil {
  2252  				return err
  2253  			}
  2254  
  2255  			return nil
  2256  		}, opts...)
  2257  		if e != nil {
  2258  			return nil, "", e
  2259  		}
  2260  		it.Response = resp
  2261  		return resp.GetArtifacts(), resp.GetNextPageToken(), nil
  2262  	}
  2263  
  2264  	fetch := func(pageSize int, pageToken string) (string, error) {
  2265  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2266  		if err != nil {
  2267  			return "", err
  2268  		}
  2269  		it.items = append(it.items, items...)
  2270  		return nextPageToken, nil
  2271  	}
  2272  
  2273  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2274  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2275  	it.pageInfo.Token = req.GetPageToken()
  2276  
  2277  	return it
  2278  }
  2279  
  2280  // UpdateArtifact updates a stored Artifact.
  2281  func (c *metadataRESTClient) UpdateArtifact(ctx context.Context, req *aiplatformpb.UpdateArtifactRequest, opts ...gax.CallOption) (*aiplatformpb.Artifact, error) {
  2282  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2283  	body := req.GetArtifact()
  2284  	jsonReq, err := m.Marshal(body)
  2285  	if err != nil {
  2286  		return nil, err
  2287  	}
  2288  
  2289  	baseUrl, err := url.Parse(c.endpoint)
  2290  	if err != nil {
  2291  		return nil, err
  2292  	}
  2293  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetArtifact().GetName())
  2294  
  2295  	params := url.Values{}
  2296  	params.Add("$alt", "json;enum-encoding=int")
  2297  	if req.GetAllowMissing() {
  2298  		params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
  2299  	}
  2300  	if req.GetUpdateMask() != nil {
  2301  		field, err := protojson.Marshal(req.GetUpdateMask())
  2302  		if err != nil {
  2303  			return nil, err
  2304  		}
  2305  		params.Add("updateMask", string(field[1:len(field)-1]))
  2306  	}
  2307  
  2308  	baseUrl.RawQuery = params.Encode()
  2309  
  2310  	// Build HTTP headers from client and context metadata.
  2311  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "artifact.name", url.QueryEscape(req.GetArtifact().GetName()))}
  2312  
  2313  	hds = append(c.xGoogHeaders, hds...)
  2314  	hds = append(hds, "Content-Type", "application/json")
  2315  	headers := gax.BuildHeaders(ctx, hds...)
  2316  	opts = append((*c.CallOptions).UpdateArtifact[0:len((*c.CallOptions).UpdateArtifact):len((*c.CallOptions).UpdateArtifact)], opts...)
  2317  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2318  	resp := &aiplatformpb.Artifact{}
  2319  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2320  		if settings.Path != "" {
  2321  			baseUrl.Path = settings.Path
  2322  		}
  2323  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  2324  		if err != nil {
  2325  			return err
  2326  		}
  2327  		httpReq = httpReq.WithContext(ctx)
  2328  		httpReq.Header = headers
  2329  
  2330  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateArtifact")
  2331  		if err != nil {
  2332  			return err
  2333  		}
  2334  
  2335  		if err := unm.Unmarshal(buf, resp); err != nil {
  2336  			return err
  2337  		}
  2338  
  2339  		return nil
  2340  	}, opts...)
  2341  	if e != nil {
  2342  		return nil, e
  2343  	}
  2344  	return resp, nil
  2345  }
  2346  
  2347  // DeleteArtifact deletes an Artifact.
  2348  func (c *metadataRESTClient) DeleteArtifact(ctx context.Context, req *aiplatformpb.DeleteArtifactRequest, opts ...gax.CallOption) (*DeleteArtifactOperation, error) {
  2349  	baseUrl, err := url.Parse(c.endpoint)
  2350  	if err != nil {
  2351  		return nil, err
  2352  	}
  2353  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2354  
  2355  	params := url.Values{}
  2356  	params.Add("$alt", "json;enum-encoding=int")
  2357  	if req.GetEtag() != "" {
  2358  		params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
  2359  	}
  2360  
  2361  	baseUrl.RawQuery = params.Encode()
  2362  
  2363  	// Build HTTP headers from client and context metadata.
  2364  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2365  
  2366  	hds = append(c.xGoogHeaders, hds...)
  2367  	hds = append(hds, "Content-Type", "application/json")
  2368  	headers := gax.BuildHeaders(ctx, hds...)
  2369  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2370  	resp := &longrunningpb.Operation{}
  2371  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2372  		if settings.Path != "" {
  2373  			baseUrl.Path = settings.Path
  2374  		}
  2375  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2376  		if err != nil {
  2377  			return err
  2378  		}
  2379  		httpReq = httpReq.WithContext(ctx)
  2380  		httpReq.Header = headers
  2381  
  2382  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteArtifact")
  2383  		if err != nil {
  2384  			return err
  2385  		}
  2386  		if err := unm.Unmarshal(buf, resp); err != nil {
  2387  			return err
  2388  		}
  2389  
  2390  		return nil
  2391  	}, opts...)
  2392  	if e != nil {
  2393  		return nil, e
  2394  	}
  2395  
  2396  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2397  	return &DeleteArtifactOperation{
  2398  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2399  		pollPath: override,
  2400  	}, nil
  2401  }
  2402  
  2403  // PurgeArtifacts purges Artifacts.
  2404  func (c *metadataRESTClient) PurgeArtifacts(ctx context.Context, req *aiplatformpb.PurgeArtifactsRequest, opts ...gax.CallOption) (*PurgeArtifactsOperation, error) {
  2405  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2406  	jsonReq, err := m.Marshal(req)
  2407  	if err != nil {
  2408  		return nil, err
  2409  	}
  2410  
  2411  	baseUrl, err := url.Parse(c.endpoint)
  2412  	if err != nil {
  2413  		return nil, err
  2414  	}
  2415  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/artifacts:purge", req.GetParent())
  2416  
  2417  	params := url.Values{}
  2418  	params.Add("$alt", "json;enum-encoding=int")
  2419  
  2420  	baseUrl.RawQuery = params.Encode()
  2421  
  2422  	// Build HTTP headers from client and context metadata.
  2423  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2424  
  2425  	hds = append(c.xGoogHeaders, hds...)
  2426  	hds = append(hds, "Content-Type", "application/json")
  2427  	headers := gax.BuildHeaders(ctx, hds...)
  2428  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2429  	resp := &longrunningpb.Operation{}
  2430  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2431  		if settings.Path != "" {
  2432  			baseUrl.Path = settings.Path
  2433  		}
  2434  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2435  		if err != nil {
  2436  			return err
  2437  		}
  2438  		httpReq = httpReq.WithContext(ctx)
  2439  		httpReq.Header = headers
  2440  
  2441  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PurgeArtifacts")
  2442  		if err != nil {
  2443  			return err
  2444  		}
  2445  		if err := unm.Unmarshal(buf, resp); err != nil {
  2446  			return err
  2447  		}
  2448  
  2449  		return nil
  2450  	}, opts...)
  2451  	if e != nil {
  2452  		return nil, e
  2453  	}
  2454  
  2455  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2456  	return &PurgeArtifactsOperation{
  2457  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2458  		pollPath: override,
  2459  	}, nil
  2460  }
  2461  
  2462  // CreateContext creates a Context associated with a MetadataStore.
  2463  func (c *metadataRESTClient) CreateContext(ctx context.Context, req *aiplatformpb.CreateContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
  2464  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2465  	body := req.GetContext()
  2466  	jsonReq, err := m.Marshal(body)
  2467  	if err != nil {
  2468  		return nil, err
  2469  	}
  2470  
  2471  	baseUrl, err := url.Parse(c.endpoint)
  2472  	if err != nil {
  2473  		return nil, err
  2474  	}
  2475  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/contexts", req.GetParent())
  2476  
  2477  	params := url.Values{}
  2478  	params.Add("$alt", "json;enum-encoding=int")
  2479  	if req.GetContextId() != "" {
  2480  		params.Add("contextId", fmt.Sprintf("%v", req.GetContextId()))
  2481  	}
  2482  
  2483  	baseUrl.RawQuery = params.Encode()
  2484  
  2485  	// Build HTTP headers from client and context metadata.
  2486  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2487  
  2488  	hds = append(c.xGoogHeaders, hds...)
  2489  	hds = append(hds, "Content-Type", "application/json")
  2490  	headers := gax.BuildHeaders(ctx, hds...)
  2491  	opts = append((*c.CallOptions).CreateContext[0:len((*c.CallOptions).CreateContext):len((*c.CallOptions).CreateContext)], opts...)
  2492  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2493  	resp := &aiplatformpb.Context{}
  2494  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2495  		if settings.Path != "" {
  2496  			baseUrl.Path = settings.Path
  2497  		}
  2498  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2499  		if err != nil {
  2500  			return err
  2501  		}
  2502  		httpReq = httpReq.WithContext(ctx)
  2503  		httpReq.Header = headers
  2504  
  2505  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateContext")
  2506  		if err != nil {
  2507  			return err
  2508  		}
  2509  
  2510  		if err := unm.Unmarshal(buf, resp); err != nil {
  2511  			return err
  2512  		}
  2513  
  2514  		return nil
  2515  	}, opts...)
  2516  	if e != nil {
  2517  		return nil, e
  2518  	}
  2519  	return resp, nil
  2520  }
  2521  
  2522  // GetContext retrieves a specific Context.
  2523  func (c *metadataRESTClient) GetContext(ctx context.Context, req *aiplatformpb.GetContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
  2524  	baseUrl, err := url.Parse(c.endpoint)
  2525  	if err != nil {
  2526  		return nil, err
  2527  	}
  2528  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2529  
  2530  	params := url.Values{}
  2531  	params.Add("$alt", "json;enum-encoding=int")
  2532  
  2533  	baseUrl.RawQuery = params.Encode()
  2534  
  2535  	// Build HTTP headers from client and context metadata.
  2536  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2537  
  2538  	hds = append(c.xGoogHeaders, hds...)
  2539  	hds = append(hds, "Content-Type", "application/json")
  2540  	headers := gax.BuildHeaders(ctx, hds...)
  2541  	opts = append((*c.CallOptions).GetContext[0:len((*c.CallOptions).GetContext):len((*c.CallOptions).GetContext)], opts...)
  2542  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2543  	resp := &aiplatformpb.Context{}
  2544  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2545  		if settings.Path != "" {
  2546  			baseUrl.Path = settings.Path
  2547  		}
  2548  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2549  		if err != nil {
  2550  			return err
  2551  		}
  2552  		httpReq = httpReq.WithContext(ctx)
  2553  		httpReq.Header = headers
  2554  
  2555  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetContext")
  2556  		if err != nil {
  2557  			return err
  2558  		}
  2559  
  2560  		if err := unm.Unmarshal(buf, resp); err != nil {
  2561  			return err
  2562  		}
  2563  
  2564  		return nil
  2565  	}, opts...)
  2566  	if e != nil {
  2567  		return nil, e
  2568  	}
  2569  	return resp, nil
  2570  }
  2571  
  2572  // ListContexts lists Contexts on the MetadataStore.
  2573  func (c *metadataRESTClient) ListContexts(ctx context.Context, req *aiplatformpb.ListContextsRequest, opts ...gax.CallOption) *ContextIterator {
  2574  	it := &ContextIterator{}
  2575  	req = proto.Clone(req).(*aiplatformpb.ListContextsRequest)
  2576  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2577  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Context, string, error) {
  2578  		resp := &aiplatformpb.ListContextsResponse{}
  2579  		if pageToken != "" {
  2580  			req.PageToken = pageToken
  2581  		}
  2582  		if pageSize > math.MaxInt32 {
  2583  			req.PageSize = math.MaxInt32
  2584  		} else if pageSize != 0 {
  2585  			req.PageSize = int32(pageSize)
  2586  		}
  2587  		baseUrl, err := url.Parse(c.endpoint)
  2588  		if err != nil {
  2589  			return nil, "", err
  2590  		}
  2591  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/contexts", req.GetParent())
  2592  
  2593  		params := url.Values{}
  2594  		params.Add("$alt", "json;enum-encoding=int")
  2595  		if req.GetFilter() != "" {
  2596  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2597  		}
  2598  		if req.GetOrderBy() != "" {
  2599  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  2600  		}
  2601  		if req.GetPageSize() != 0 {
  2602  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2603  		}
  2604  		if req.GetPageToken() != "" {
  2605  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2606  		}
  2607  
  2608  		baseUrl.RawQuery = params.Encode()
  2609  
  2610  		// Build HTTP headers from client and context metadata.
  2611  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2612  		headers := gax.BuildHeaders(ctx, hds...)
  2613  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2614  			if settings.Path != "" {
  2615  				baseUrl.Path = settings.Path
  2616  			}
  2617  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2618  			if err != nil {
  2619  				return err
  2620  			}
  2621  			httpReq.Header = headers
  2622  
  2623  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListContexts")
  2624  			if err != nil {
  2625  				return err
  2626  			}
  2627  			if err := unm.Unmarshal(buf, resp); err != nil {
  2628  				return err
  2629  			}
  2630  
  2631  			return nil
  2632  		}, opts...)
  2633  		if e != nil {
  2634  			return nil, "", e
  2635  		}
  2636  		it.Response = resp
  2637  		return resp.GetContexts(), resp.GetNextPageToken(), nil
  2638  	}
  2639  
  2640  	fetch := func(pageSize int, pageToken string) (string, error) {
  2641  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2642  		if err != nil {
  2643  			return "", err
  2644  		}
  2645  		it.items = append(it.items, items...)
  2646  		return nextPageToken, nil
  2647  	}
  2648  
  2649  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2650  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2651  	it.pageInfo.Token = req.GetPageToken()
  2652  
  2653  	return it
  2654  }
  2655  
  2656  // UpdateContext updates a stored Context.
  2657  func (c *metadataRESTClient) UpdateContext(ctx context.Context, req *aiplatformpb.UpdateContextRequest, opts ...gax.CallOption) (*aiplatformpb.Context, error) {
  2658  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2659  	body := req.GetContext()
  2660  	jsonReq, err := m.Marshal(body)
  2661  	if err != nil {
  2662  		return nil, err
  2663  	}
  2664  
  2665  	baseUrl, err := url.Parse(c.endpoint)
  2666  	if err != nil {
  2667  		return nil, err
  2668  	}
  2669  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetContext().GetName())
  2670  
  2671  	params := url.Values{}
  2672  	params.Add("$alt", "json;enum-encoding=int")
  2673  	if req.GetAllowMissing() {
  2674  		params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
  2675  	}
  2676  	if req.GetUpdateMask() != nil {
  2677  		field, err := protojson.Marshal(req.GetUpdateMask())
  2678  		if err != nil {
  2679  			return nil, err
  2680  		}
  2681  		params.Add("updateMask", string(field[1:len(field)-1]))
  2682  	}
  2683  
  2684  	baseUrl.RawQuery = params.Encode()
  2685  
  2686  	// Build HTTP headers from client and context metadata.
  2687  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context.name", url.QueryEscape(req.GetContext().GetName()))}
  2688  
  2689  	hds = append(c.xGoogHeaders, hds...)
  2690  	hds = append(hds, "Content-Type", "application/json")
  2691  	headers := gax.BuildHeaders(ctx, hds...)
  2692  	opts = append((*c.CallOptions).UpdateContext[0:len((*c.CallOptions).UpdateContext):len((*c.CallOptions).UpdateContext)], opts...)
  2693  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2694  	resp := &aiplatformpb.Context{}
  2695  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2696  		if settings.Path != "" {
  2697  			baseUrl.Path = settings.Path
  2698  		}
  2699  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  2700  		if err != nil {
  2701  			return err
  2702  		}
  2703  		httpReq = httpReq.WithContext(ctx)
  2704  		httpReq.Header = headers
  2705  
  2706  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateContext")
  2707  		if err != nil {
  2708  			return err
  2709  		}
  2710  
  2711  		if err := unm.Unmarshal(buf, resp); err != nil {
  2712  			return err
  2713  		}
  2714  
  2715  		return nil
  2716  	}, opts...)
  2717  	if e != nil {
  2718  		return nil, e
  2719  	}
  2720  	return resp, nil
  2721  }
  2722  
  2723  // DeleteContext deletes a stored Context.
  2724  func (c *metadataRESTClient) DeleteContext(ctx context.Context, req *aiplatformpb.DeleteContextRequest, opts ...gax.CallOption) (*DeleteContextOperation, error) {
  2725  	baseUrl, err := url.Parse(c.endpoint)
  2726  	if err != nil {
  2727  		return nil, err
  2728  	}
  2729  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2730  
  2731  	params := url.Values{}
  2732  	params.Add("$alt", "json;enum-encoding=int")
  2733  	if req.GetEtag() != "" {
  2734  		params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
  2735  	}
  2736  	if req.GetForce() {
  2737  		params.Add("force", fmt.Sprintf("%v", req.GetForce()))
  2738  	}
  2739  
  2740  	baseUrl.RawQuery = params.Encode()
  2741  
  2742  	// Build HTTP headers from client and context metadata.
  2743  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2744  
  2745  	hds = append(c.xGoogHeaders, hds...)
  2746  	hds = append(hds, "Content-Type", "application/json")
  2747  	headers := gax.BuildHeaders(ctx, hds...)
  2748  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2749  	resp := &longrunningpb.Operation{}
  2750  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2751  		if settings.Path != "" {
  2752  			baseUrl.Path = settings.Path
  2753  		}
  2754  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2755  		if err != nil {
  2756  			return err
  2757  		}
  2758  		httpReq = httpReq.WithContext(ctx)
  2759  		httpReq.Header = headers
  2760  
  2761  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteContext")
  2762  		if err != nil {
  2763  			return err
  2764  		}
  2765  		if err := unm.Unmarshal(buf, resp); err != nil {
  2766  			return err
  2767  		}
  2768  
  2769  		return nil
  2770  	}, opts...)
  2771  	if e != nil {
  2772  		return nil, e
  2773  	}
  2774  
  2775  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2776  	return &DeleteContextOperation{
  2777  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2778  		pollPath: override,
  2779  	}, nil
  2780  }
  2781  
  2782  // PurgeContexts purges Contexts.
  2783  func (c *metadataRESTClient) PurgeContexts(ctx context.Context, req *aiplatformpb.PurgeContextsRequest, opts ...gax.CallOption) (*PurgeContextsOperation, error) {
  2784  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2785  	jsonReq, err := m.Marshal(req)
  2786  	if err != nil {
  2787  		return nil, err
  2788  	}
  2789  
  2790  	baseUrl, err := url.Parse(c.endpoint)
  2791  	if err != nil {
  2792  		return nil, err
  2793  	}
  2794  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/contexts:purge", req.GetParent())
  2795  
  2796  	params := url.Values{}
  2797  	params.Add("$alt", "json;enum-encoding=int")
  2798  
  2799  	baseUrl.RawQuery = params.Encode()
  2800  
  2801  	// Build HTTP headers from client and context metadata.
  2802  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2803  
  2804  	hds = append(c.xGoogHeaders, hds...)
  2805  	hds = append(hds, "Content-Type", "application/json")
  2806  	headers := gax.BuildHeaders(ctx, hds...)
  2807  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2808  	resp := &longrunningpb.Operation{}
  2809  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2810  		if settings.Path != "" {
  2811  			baseUrl.Path = settings.Path
  2812  		}
  2813  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2814  		if err != nil {
  2815  			return err
  2816  		}
  2817  		httpReq = httpReq.WithContext(ctx)
  2818  		httpReq.Header = headers
  2819  
  2820  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PurgeContexts")
  2821  		if err != nil {
  2822  			return err
  2823  		}
  2824  		if err := unm.Unmarshal(buf, resp); err != nil {
  2825  			return err
  2826  		}
  2827  
  2828  		return nil
  2829  	}, opts...)
  2830  	if e != nil {
  2831  		return nil, e
  2832  	}
  2833  
  2834  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2835  	return &PurgeContextsOperation{
  2836  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2837  		pollPath: override,
  2838  	}, nil
  2839  }
  2840  
  2841  // AddContextArtifactsAndExecutions adds a set of Artifacts and Executions to a Context. If any of the
  2842  // Artifacts or Executions have already been added to a Context, they are
  2843  // simply skipped.
  2844  func (c *metadataRESTClient) AddContextArtifactsAndExecutions(ctx context.Context, req *aiplatformpb.AddContextArtifactsAndExecutionsRequest, opts ...gax.CallOption) (*aiplatformpb.AddContextArtifactsAndExecutionsResponse, error) {
  2845  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2846  	jsonReq, err := m.Marshal(req)
  2847  	if err != nil {
  2848  		return nil, err
  2849  	}
  2850  
  2851  	baseUrl, err := url.Parse(c.endpoint)
  2852  	if err != nil {
  2853  		return nil, err
  2854  	}
  2855  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:addContextArtifactsAndExecutions", req.GetContext())
  2856  
  2857  	params := url.Values{}
  2858  	params.Add("$alt", "json;enum-encoding=int")
  2859  
  2860  	baseUrl.RawQuery = params.Encode()
  2861  
  2862  	// Build HTTP headers from client and context metadata.
  2863  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  2864  
  2865  	hds = append(c.xGoogHeaders, hds...)
  2866  	hds = append(hds, "Content-Type", "application/json")
  2867  	headers := gax.BuildHeaders(ctx, hds...)
  2868  	opts = append((*c.CallOptions).AddContextArtifactsAndExecutions[0:len((*c.CallOptions).AddContextArtifactsAndExecutions):len((*c.CallOptions).AddContextArtifactsAndExecutions)], opts...)
  2869  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2870  	resp := &aiplatformpb.AddContextArtifactsAndExecutionsResponse{}
  2871  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2872  		if settings.Path != "" {
  2873  			baseUrl.Path = settings.Path
  2874  		}
  2875  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2876  		if err != nil {
  2877  			return err
  2878  		}
  2879  		httpReq = httpReq.WithContext(ctx)
  2880  		httpReq.Header = headers
  2881  
  2882  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AddContextArtifactsAndExecutions")
  2883  		if err != nil {
  2884  			return err
  2885  		}
  2886  
  2887  		if err := unm.Unmarshal(buf, resp); err != nil {
  2888  			return err
  2889  		}
  2890  
  2891  		return nil
  2892  	}, opts...)
  2893  	if e != nil {
  2894  		return nil, e
  2895  	}
  2896  	return resp, nil
  2897  }
  2898  
  2899  // AddContextChildren adds a set of Contexts as children to a parent Context. If any of the
  2900  // child Contexts have already been added to the parent Context, they are
  2901  // simply skipped. If this call would create a cycle or cause any Context to
  2902  // have more than 10 parents, the request will fail with an INVALID_ARGUMENT
  2903  // error.
  2904  func (c *metadataRESTClient) AddContextChildren(ctx context.Context, req *aiplatformpb.AddContextChildrenRequest, opts ...gax.CallOption) (*aiplatformpb.AddContextChildrenResponse, error) {
  2905  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2906  	jsonReq, err := m.Marshal(req)
  2907  	if err != nil {
  2908  		return nil, err
  2909  	}
  2910  
  2911  	baseUrl, err := url.Parse(c.endpoint)
  2912  	if err != nil {
  2913  		return nil, err
  2914  	}
  2915  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:addContextChildren", req.GetContext())
  2916  
  2917  	params := url.Values{}
  2918  	params.Add("$alt", "json;enum-encoding=int")
  2919  
  2920  	baseUrl.RawQuery = params.Encode()
  2921  
  2922  	// Build HTTP headers from client and context metadata.
  2923  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  2924  
  2925  	hds = append(c.xGoogHeaders, hds...)
  2926  	hds = append(hds, "Content-Type", "application/json")
  2927  	headers := gax.BuildHeaders(ctx, hds...)
  2928  	opts = append((*c.CallOptions).AddContextChildren[0:len((*c.CallOptions).AddContextChildren):len((*c.CallOptions).AddContextChildren)], opts...)
  2929  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2930  	resp := &aiplatformpb.AddContextChildrenResponse{}
  2931  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2932  		if settings.Path != "" {
  2933  			baseUrl.Path = settings.Path
  2934  		}
  2935  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2936  		if err != nil {
  2937  			return err
  2938  		}
  2939  		httpReq = httpReq.WithContext(ctx)
  2940  		httpReq.Header = headers
  2941  
  2942  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AddContextChildren")
  2943  		if err != nil {
  2944  			return err
  2945  		}
  2946  
  2947  		if err := unm.Unmarshal(buf, resp); err != nil {
  2948  			return err
  2949  		}
  2950  
  2951  		return nil
  2952  	}, opts...)
  2953  	if e != nil {
  2954  		return nil, e
  2955  	}
  2956  	return resp, nil
  2957  }
  2958  
  2959  // RemoveContextChildren remove a set of children contexts from a parent Context. If any of the
  2960  // child Contexts were NOT added to the parent Context, they are
  2961  // simply skipped.
  2962  func (c *metadataRESTClient) RemoveContextChildren(ctx context.Context, req *aiplatformpb.RemoveContextChildrenRequest, opts ...gax.CallOption) (*aiplatformpb.RemoveContextChildrenResponse, error) {
  2963  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2964  	jsonReq, err := m.Marshal(req)
  2965  	if err != nil {
  2966  		return nil, err
  2967  	}
  2968  
  2969  	baseUrl, err := url.Parse(c.endpoint)
  2970  	if err != nil {
  2971  		return nil, err
  2972  	}
  2973  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:removeContextChildren", req.GetContext())
  2974  
  2975  	params := url.Values{}
  2976  	params.Add("$alt", "json;enum-encoding=int")
  2977  
  2978  	baseUrl.RawQuery = params.Encode()
  2979  
  2980  	// Build HTTP headers from client and context metadata.
  2981  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  2982  
  2983  	hds = append(c.xGoogHeaders, hds...)
  2984  	hds = append(hds, "Content-Type", "application/json")
  2985  	headers := gax.BuildHeaders(ctx, hds...)
  2986  	opts = append((*c.CallOptions).RemoveContextChildren[0:len((*c.CallOptions).RemoveContextChildren):len((*c.CallOptions).RemoveContextChildren)], opts...)
  2987  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2988  	resp := &aiplatformpb.RemoveContextChildrenResponse{}
  2989  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2990  		if settings.Path != "" {
  2991  			baseUrl.Path = settings.Path
  2992  		}
  2993  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2994  		if err != nil {
  2995  			return err
  2996  		}
  2997  		httpReq = httpReq.WithContext(ctx)
  2998  		httpReq.Header = headers
  2999  
  3000  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RemoveContextChildren")
  3001  		if err != nil {
  3002  			return err
  3003  		}
  3004  
  3005  		if err := unm.Unmarshal(buf, resp); err != nil {
  3006  			return err
  3007  		}
  3008  
  3009  		return nil
  3010  	}, opts...)
  3011  	if e != nil {
  3012  		return nil, e
  3013  	}
  3014  	return resp, nil
  3015  }
  3016  
  3017  // QueryContextLineageSubgraph retrieves Artifacts and Executions within the specified Context, connected
  3018  // by Event edges and returned as a LineageSubgraph.
  3019  func (c *metadataRESTClient) QueryContextLineageSubgraph(ctx context.Context, req *aiplatformpb.QueryContextLineageSubgraphRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
  3020  	baseUrl, err := url.Parse(c.endpoint)
  3021  	if err != nil {
  3022  		return nil, err
  3023  	}
  3024  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:queryContextLineageSubgraph", req.GetContext())
  3025  
  3026  	params := url.Values{}
  3027  	params.Add("$alt", "json;enum-encoding=int")
  3028  
  3029  	baseUrl.RawQuery = params.Encode()
  3030  
  3031  	// Build HTTP headers from client and context metadata.
  3032  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "context", url.QueryEscape(req.GetContext()))}
  3033  
  3034  	hds = append(c.xGoogHeaders, hds...)
  3035  	hds = append(hds, "Content-Type", "application/json")
  3036  	headers := gax.BuildHeaders(ctx, hds...)
  3037  	opts = append((*c.CallOptions).QueryContextLineageSubgraph[0:len((*c.CallOptions).QueryContextLineageSubgraph):len((*c.CallOptions).QueryContextLineageSubgraph)], opts...)
  3038  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3039  	resp := &aiplatformpb.LineageSubgraph{}
  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 = httpReq.WithContext(ctx)
  3049  		httpReq.Header = headers
  3050  
  3051  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "QueryContextLineageSubgraph")
  3052  		if err != nil {
  3053  			return err
  3054  		}
  3055  
  3056  		if err := unm.Unmarshal(buf, resp); err != nil {
  3057  			return err
  3058  		}
  3059  
  3060  		return nil
  3061  	}, opts...)
  3062  	if e != nil {
  3063  		return nil, e
  3064  	}
  3065  	return resp, nil
  3066  }
  3067  
  3068  // CreateExecution creates an Execution associated with a MetadataStore.
  3069  func (c *metadataRESTClient) CreateExecution(ctx context.Context, req *aiplatformpb.CreateExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
  3070  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3071  	body := req.GetExecution()
  3072  	jsonReq, err := m.Marshal(body)
  3073  	if err != nil {
  3074  		return nil, err
  3075  	}
  3076  
  3077  	baseUrl, err := url.Parse(c.endpoint)
  3078  	if err != nil {
  3079  		return nil, err
  3080  	}
  3081  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/executions", req.GetParent())
  3082  
  3083  	params := url.Values{}
  3084  	params.Add("$alt", "json;enum-encoding=int")
  3085  	if req.GetExecutionId() != "" {
  3086  		params.Add("executionId", fmt.Sprintf("%v", req.GetExecutionId()))
  3087  	}
  3088  
  3089  	baseUrl.RawQuery = params.Encode()
  3090  
  3091  	// Build HTTP headers from client and context metadata.
  3092  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  3093  
  3094  	hds = append(c.xGoogHeaders, hds...)
  3095  	hds = append(hds, "Content-Type", "application/json")
  3096  	headers := gax.BuildHeaders(ctx, hds...)
  3097  	opts = append((*c.CallOptions).CreateExecution[0:len((*c.CallOptions).CreateExecution):len((*c.CallOptions).CreateExecution)], opts...)
  3098  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3099  	resp := &aiplatformpb.Execution{}
  3100  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3101  		if settings.Path != "" {
  3102  			baseUrl.Path = settings.Path
  3103  		}
  3104  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3105  		if err != nil {
  3106  			return err
  3107  		}
  3108  		httpReq = httpReq.WithContext(ctx)
  3109  		httpReq.Header = headers
  3110  
  3111  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateExecution")
  3112  		if err != nil {
  3113  			return err
  3114  		}
  3115  
  3116  		if err := unm.Unmarshal(buf, resp); err != nil {
  3117  			return err
  3118  		}
  3119  
  3120  		return nil
  3121  	}, opts...)
  3122  	if e != nil {
  3123  		return nil, e
  3124  	}
  3125  	return resp, nil
  3126  }
  3127  
  3128  // GetExecution retrieves a specific Execution.
  3129  func (c *metadataRESTClient) GetExecution(ctx context.Context, req *aiplatformpb.GetExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
  3130  	baseUrl, err := url.Parse(c.endpoint)
  3131  	if err != nil {
  3132  		return nil, err
  3133  	}
  3134  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3135  
  3136  	params := url.Values{}
  3137  	params.Add("$alt", "json;enum-encoding=int")
  3138  
  3139  	baseUrl.RawQuery = params.Encode()
  3140  
  3141  	// Build HTTP headers from client and context metadata.
  3142  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3143  
  3144  	hds = append(c.xGoogHeaders, hds...)
  3145  	hds = append(hds, "Content-Type", "application/json")
  3146  	headers := gax.BuildHeaders(ctx, hds...)
  3147  	opts = append((*c.CallOptions).GetExecution[0:len((*c.CallOptions).GetExecution):len((*c.CallOptions).GetExecution)], opts...)
  3148  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3149  	resp := &aiplatformpb.Execution{}
  3150  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3151  		if settings.Path != "" {
  3152  			baseUrl.Path = settings.Path
  3153  		}
  3154  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3155  		if err != nil {
  3156  			return err
  3157  		}
  3158  		httpReq = httpReq.WithContext(ctx)
  3159  		httpReq.Header = headers
  3160  
  3161  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetExecution")
  3162  		if err != nil {
  3163  			return err
  3164  		}
  3165  
  3166  		if err := unm.Unmarshal(buf, resp); err != nil {
  3167  			return err
  3168  		}
  3169  
  3170  		return nil
  3171  	}, opts...)
  3172  	if e != nil {
  3173  		return nil, e
  3174  	}
  3175  	return resp, nil
  3176  }
  3177  
  3178  // ListExecutions lists Executions in the MetadataStore.
  3179  func (c *metadataRESTClient) ListExecutions(ctx context.Context, req *aiplatformpb.ListExecutionsRequest, opts ...gax.CallOption) *ExecutionIterator {
  3180  	it := &ExecutionIterator{}
  3181  	req = proto.Clone(req).(*aiplatformpb.ListExecutionsRequest)
  3182  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3183  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Execution, string, error) {
  3184  		resp := &aiplatformpb.ListExecutionsResponse{}
  3185  		if pageToken != "" {
  3186  			req.PageToken = pageToken
  3187  		}
  3188  		if pageSize > math.MaxInt32 {
  3189  			req.PageSize = math.MaxInt32
  3190  		} else if pageSize != 0 {
  3191  			req.PageSize = int32(pageSize)
  3192  		}
  3193  		baseUrl, err := url.Parse(c.endpoint)
  3194  		if err != nil {
  3195  			return nil, "", err
  3196  		}
  3197  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/executions", req.GetParent())
  3198  
  3199  		params := url.Values{}
  3200  		params.Add("$alt", "json;enum-encoding=int")
  3201  		if req.GetFilter() != "" {
  3202  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3203  		}
  3204  		if req.GetOrderBy() != "" {
  3205  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  3206  		}
  3207  		if req.GetPageSize() != 0 {
  3208  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3209  		}
  3210  		if req.GetPageToken() != "" {
  3211  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3212  		}
  3213  
  3214  		baseUrl.RawQuery = params.Encode()
  3215  
  3216  		// Build HTTP headers from client and context metadata.
  3217  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3218  		headers := gax.BuildHeaders(ctx, hds...)
  3219  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3220  			if settings.Path != "" {
  3221  				baseUrl.Path = settings.Path
  3222  			}
  3223  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3224  			if err != nil {
  3225  				return err
  3226  			}
  3227  			httpReq.Header = headers
  3228  
  3229  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListExecutions")
  3230  			if err != nil {
  3231  				return err
  3232  			}
  3233  			if err := unm.Unmarshal(buf, resp); err != nil {
  3234  				return err
  3235  			}
  3236  
  3237  			return nil
  3238  		}, opts...)
  3239  		if e != nil {
  3240  			return nil, "", e
  3241  		}
  3242  		it.Response = resp
  3243  		return resp.GetExecutions(), resp.GetNextPageToken(), nil
  3244  	}
  3245  
  3246  	fetch := func(pageSize int, pageToken string) (string, error) {
  3247  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3248  		if err != nil {
  3249  			return "", err
  3250  		}
  3251  		it.items = append(it.items, items...)
  3252  		return nextPageToken, nil
  3253  	}
  3254  
  3255  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3256  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3257  	it.pageInfo.Token = req.GetPageToken()
  3258  
  3259  	return it
  3260  }
  3261  
  3262  // UpdateExecution updates a stored Execution.
  3263  func (c *metadataRESTClient) UpdateExecution(ctx context.Context, req *aiplatformpb.UpdateExecutionRequest, opts ...gax.CallOption) (*aiplatformpb.Execution, error) {
  3264  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3265  	body := req.GetExecution()
  3266  	jsonReq, err := m.Marshal(body)
  3267  	if err != nil {
  3268  		return nil, err
  3269  	}
  3270  
  3271  	baseUrl, err := url.Parse(c.endpoint)
  3272  	if err != nil {
  3273  		return nil, err
  3274  	}
  3275  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetExecution().GetName())
  3276  
  3277  	params := url.Values{}
  3278  	params.Add("$alt", "json;enum-encoding=int")
  3279  	if req.GetAllowMissing() {
  3280  		params.Add("allowMissing", fmt.Sprintf("%v", req.GetAllowMissing()))
  3281  	}
  3282  	if req.GetUpdateMask() != nil {
  3283  		field, err := protojson.Marshal(req.GetUpdateMask())
  3284  		if err != nil {
  3285  			return nil, err
  3286  		}
  3287  		params.Add("updateMask", string(field[1:len(field)-1]))
  3288  	}
  3289  
  3290  	baseUrl.RawQuery = params.Encode()
  3291  
  3292  	// Build HTTP headers from client and context metadata.
  3293  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "execution.name", url.QueryEscape(req.GetExecution().GetName()))}
  3294  
  3295  	hds = append(c.xGoogHeaders, hds...)
  3296  	hds = append(hds, "Content-Type", "application/json")
  3297  	headers := gax.BuildHeaders(ctx, hds...)
  3298  	opts = append((*c.CallOptions).UpdateExecution[0:len((*c.CallOptions).UpdateExecution):len((*c.CallOptions).UpdateExecution)], opts...)
  3299  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3300  	resp := &aiplatformpb.Execution{}
  3301  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3302  		if settings.Path != "" {
  3303  			baseUrl.Path = settings.Path
  3304  		}
  3305  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  3306  		if err != nil {
  3307  			return err
  3308  		}
  3309  		httpReq = httpReq.WithContext(ctx)
  3310  		httpReq.Header = headers
  3311  
  3312  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateExecution")
  3313  		if err != nil {
  3314  			return err
  3315  		}
  3316  
  3317  		if err := unm.Unmarshal(buf, resp); err != nil {
  3318  			return err
  3319  		}
  3320  
  3321  		return nil
  3322  	}, opts...)
  3323  	if e != nil {
  3324  		return nil, e
  3325  	}
  3326  	return resp, nil
  3327  }
  3328  
  3329  // DeleteExecution deletes an Execution.
  3330  func (c *metadataRESTClient) DeleteExecution(ctx context.Context, req *aiplatformpb.DeleteExecutionRequest, opts ...gax.CallOption) (*DeleteExecutionOperation, error) {
  3331  	baseUrl, err := url.Parse(c.endpoint)
  3332  	if err != nil {
  3333  		return nil, err
  3334  	}
  3335  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3336  
  3337  	params := url.Values{}
  3338  	params.Add("$alt", "json;enum-encoding=int")
  3339  	if req.GetEtag() != "" {
  3340  		params.Add("etag", fmt.Sprintf("%v", req.GetEtag()))
  3341  	}
  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  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3352  	resp := &longrunningpb.Operation{}
  3353  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3354  		if settings.Path != "" {
  3355  			baseUrl.Path = settings.Path
  3356  		}
  3357  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  3358  		if err != nil {
  3359  			return err
  3360  		}
  3361  		httpReq = httpReq.WithContext(ctx)
  3362  		httpReq.Header = headers
  3363  
  3364  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteExecution")
  3365  		if err != nil {
  3366  			return err
  3367  		}
  3368  		if err := unm.Unmarshal(buf, resp); err != nil {
  3369  			return err
  3370  		}
  3371  
  3372  		return nil
  3373  	}, opts...)
  3374  	if e != nil {
  3375  		return nil, e
  3376  	}
  3377  
  3378  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  3379  	return &DeleteExecutionOperation{
  3380  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  3381  		pollPath: override,
  3382  	}, nil
  3383  }
  3384  
  3385  // PurgeExecutions purges Executions.
  3386  func (c *metadataRESTClient) PurgeExecutions(ctx context.Context, req *aiplatformpb.PurgeExecutionsRequest, opts ...gax.CallOption) (*PurgeExecutionsOperation, error) {
  3387  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3388  	jsonReq, err := m.Marshal(req)
  3389  	if err != nil {
  3390  		return nil, err
  3391  	}
  3392  
  3393  	baseUrl, err := url.Parse(c.endpoint)
  3394  	if err != nil {
  3395  		return nil, err
  3396  	}
  3397  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/executions:purge", req.GetParent())
  3398  
  3399  	params := url.Values{}
  3400  	params.Add("$alt", "json;enum-encoding=int")
  3401  
  3402  	baseUrl.RawQuery = params.Encode()
  3403  
  3404  	// Build HTTP headers from client and context metadata.
  3405  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  3406  
  3407  	hds = append(c.xGoogHeaders, hds...)
  3408  	hds = append(hds, "Content-Type", "application/json")
  3409  	headers := gax.BuildHeaders(ctx, hds...)
  3410  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3411  	resp := &longrunningpb.Operation{}
  3412  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3413  		if settings.Path != "" {
  3414  			baseUrl.Path = settings.Path
  3415  		}
  3416  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3417  		if err != nil {
  3418  			return err
  3419  		}
  3420  		httpReq = httpReq.WithContext(ctx)
  3421  		httpReq.Header = headers
  3422  
  3423  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "PurgeExecutions")
  3424  		if err != nil {
  3425  			return err
  3426  		}
  3427  		if err := unm.Unmarshal(buf, resp); err != nil {
  3428  			return err
  3429  		}
  3430  
  3431  		return nil
  3432  	}, opts...)
  3433  	if e != nil {
  3434  		return nil, e
  3435  	}
  3436  
  3437  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  3438  	return &PurgeExecutionsOperation{
  3439  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  3440  		pollPath: override,
  3441  	}, nil
  3442  }
  3443  
  3444  // AddExecutionEvents adds Events to the specified Execution. An Event indicates whether an
  3445  // Artifact was used as an input or output for an Execution. If an Event
  3446  // already exists between the Execution and the Artifact, the Event is
  3447  // skipped.
  3448  func (c *metadataRESTClient) AddExecutionEvents(ctx context.Context, req *aiplatformpb.AddExecutionEventsRequest, opts ...gax.CallOption) (*aiplatformpb.AddExecutionEventsResponse, error) {
  3449  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3450  	jsonReq, err := m.Marshal(req)
  3451  	if err != nil {
  3452  		return nil, err
  3453  	}
  3454  
  3455  	baseUrl, err := url.Parse(c.endpoint)
  3456  	if err != nil {
  3457  		return nil, err
  3458  	}
  3459  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:addExecutionEvents", req.GetExecution())
  3460  
  3461  	params := url.Values{}
  3462  	params.Add("$alt", "json;enum-encoding=int")
  3463  
  3464  	baseUrl.RawQuery = params.Encode()
  3465  
  3466  	// Build HTTP headers from client and context metadata.
  3467  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "execution", url.QueryEscape(req.GetExecution()))}
  3468  
  3469  	hds = append(c.xGoogHeaders, hds...)
  3470  	hds = append(hds, "Content-Type", "application/json")
  3471  	headers := gax.BuildHeaders(ctx, hds...)
  3472  	opts = append((*c.CallOptions).AddExecutionEvents[0:len((*c.CallOptions).AddExecutionEvents):len((*c.CallOptions).AddExecutionEvents)], opts...)
  3473  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3474  	resp := &aiplatformpb.AddExecutionEventsResponse{}
  3475  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3476  		if settings.Path != "" {
  3477  			baseUrl.Path = settings.Path
  3478  		}
  3479  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3480  		if err != nil {
  3481  			return err
  3482  		}
  3483  		httpReq = httpReq.WithContext(ctx)
  3484  		httpReq.Header = headers
  3485  
  3486  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AddExecutionEvents")
  3487  		if err != nil {
  3488  			return err
  3489  		}
  3490  
  3491  		if err := unm.Unmarshal(buf, resp); err != nil {
  3492  			return err
  3493  		}
  3494  
  3495  		return nil
  3496  	}, opts...)
  3497  	if e != nil {
  3498  		return nil, e
  3499  	}
  3500  	return resp, nil
  3501  }
  3502  
  3503  // QueryExecutionInputsAndOutputs obtains the set of input and output Artifacts for this Execution, in the
  3504  // form of LineageSubgraph that also contains the Execution and connecting
  3505  // Events.
  3506  func (c *metadataRESTClient) QueryExecutionInputsAndOutputs(ctx context.Context, req *aiplatformpb.QueryExecutionInputsAndOutputsRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
  3507  	baseUrl, err := url.Parse(c.endpoint)
  3508  	if err != nil {
  3509  		return nil, err
  3510  	}
  3511  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:queryExecutionInputsAndOutputs", req.GetExecution())
  3512  
  3513  	params := url.Values{}
  3514  	params.Add("$alt", "json;enum-encoding=int")
  3515  
  3516  	baseUrl.RawQuery = params.Encode()
  3517  
  3518  	// Build HTTP headers from client and context metadata.
  3519  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "execution", url.QueryEscape(req.GetExecution()))}
  3520  
  3521  	hds = append(c.xGoogHeaders, hds...)
  3522  	hds = append(hds, "Content-Type", "application/json")
  3523  	headers := gax.BuildHeaders(ctx, hds...)
  3524  	opts = append((*c.CallOptions).QueryExecutionInputsAndOutputs[0:len((*c.CallOptions).QueryExecutionInputsAndOutputs):len((*c.CallOptions).QueryExecutionInputsAndOutputs)], opts...)
  3525  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3526  	resp := &aiplatformpb.LineageSubgraph{}
  3527  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3528  		if settings.Path != "" {
  3529  			baseUrl.Path = settings.Path
  3530  		}
  3531  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3532  		if err != nil {
  3533  			return err
  3534  		}
  3535  		httpReq = httpReq.WithContext(ctx)
  3536  		httpReq.Header = headers
  3537  
  3538  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "QueryExecutionInputsAndOutputs")
  3539  		if err != nil {
  3540  			return err
  3541  		}
  3542  
  3543  		if err := unm.Unmarshal(buf, resp); err != nil {
  3544  			return err
  3545  		}
  3546  
  3547  		return nil
  3548  	}, opts...)
  3549  	if e != nil {
  3550  		return nil, e
  3551  	}
  3552  	return resp, nil
  3553  }
  3554  
  3555  // CreateMetadataSchema creates a MetadataSchema.
  3556  func (c *metadataRESTClient) CreateMetadataSchema(ctx context.Context, req *aiplatformpb.CreateMetadataSchemaRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataSchema, error) {
  3557  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3558  	body := req.GetMetadataSchema()
  3559  	jsonReq, err := m.Marshal(body)
  3560  	if err != nil {
  3561  		return nil, err
  3562  	}
  3563  
  3564  	baseUrl, err := url.Parse(c.endpoint)
  3565  	if err != nil {
  3566  		return nil, err
  3567  	}
  3568  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/metadataSchemas", req.GetParent())
  3569  
  3570  	params := url.Values{}
  3571  	params.Add("$alt", "json;enum-encoding=int")
  3572  	if req.GetMetadataSchemaId() != "" {
  3573  		params.Add("metadataSchemaId", fmt.Sprintf("%v", req.GetMetadataSchemaId()))
  3574  	}
  3575  
  3576  	baseUrl.RawQuery = params.Encode()
  3577  
  3578  	// Build HTTP headers from client and context metadata.
  3579  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  3580  
  3581  	hds = append(c.xGoogHeaders, hds...)
  3582  	hds = append(hds, "Content-Type", "application/json")
  3583  	headers := gax.BuildHeaders(ctx, hds...)
  3584  	opts = append((*c.CallOptions).CreateMetadataSchema[0:len((*c.CallOptions).CreateMetadataSchema):len((*c.CallOptions).CreateMetadataSchema)], opts...)
  3585  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3586  	resp := &aiplatformpb.MetadataSchema{}
  3587  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3588  		if settings.Path != "" {
  3589  			baseUrl.Path = settings.Path
  3590  		}
  3591  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3592  		if err != nil {
  3593  			return err
  3594  		}
  3595  		httpReq = httpReq.WithContext(ctx)
  3596  		httpReq.Header = headers
  3597  
  3598  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateMetadataSchema")
  3599  		if err != nil {
  3600  			return err
  3601  		}
  3602  
  3603  		if err := unm.Unmarshal(buf, resp); err != nil {
  3604  			return err
  3605  		}
  3606  
  3607  		return nil
  3608  	}, opts...)
  3609  	if e != nil {
  3610  		return nil, e
  3611  	}
  3612  	return resp, nil
  3613  }
  3614  
  3615  // GetMetadataSchema retrieves a specific MetadataSchema.
  3616  func (c *metadataRESTClient) GetMetadataSchema(ctx context.Context, req *aiplatformpb.GetMetadataSchemaRequest, opts ...gax.CallOption) (*aiplatformpb.MetadataSchema, error) {
  3617  	baseUrl, err := url.Parse(c.endpoint)
  3618  	if err != nil {
  3619  		return nil, err
  3620  	}
  3621  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  3622  
  3623  	params := url.Values{}
  3624  	params.Add("$alt", "json;enum-encoding=int")
  3625  
  3626  	baseUrl.RawQuery = params.Encode()
  3627  
  3628  	// Build HTTP headers from client and context metadata.
  3629  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3630  
  3631  	hds = append(c.xGoogHeaders, hds...)
  3632  	hds = append(hds, "Content-Type", "application/json")
  3633  	headers := gax.BuildHeaders(ctx, hds...)
  3634  	opts = append((*c.CallOptions).GetMetadataSchema[0:len((*c.CallOptions).GetMetadataSchema):len((*c.CallOptions).GetMetadataSchema)], opts...)
  3635  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3636  	resp := &aiplatformpb.MetadataSchema{}
  3637  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3638  		if settings.Path != "" {
  3639  			baseUrl.Path = settings.Path
  3640  		}
  3641  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3642  		if err != nil {
  3643  			return err
  3644  		}
  3645  		httpReq = httpReq.WithContext(ctx)
  3646  		httpReq.Header = headers
  3647  
  3648  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetMetadataSchema")
  3649  		if err != nil {
  3650  			return err
  3651  		}
  3652  
  3653  		if err := unm.Unmarshal(buf, resp); err != nil {
  3654  			return err
  3655  		}
  3656  
  3657  		return nil
  3658  	}, opts...)
  3659  	if e != nil {
  3660  		return nil, e
  3661  	}
  3662  	return resp, nil
  3663  }
  3664  
  3665  // ListMetadataSchemas lists MetadataSchemas.
  3666  func (c *metadataRESTClient) ListMetadataSchemas(ctx context.Context, req *aiplatformpb.ListMetadataSchemasRequest, opts ...gax.CallOption) *MetadataSchemaIterator {
  3667  	it := &MetadataSchemaIterator{}
  3668  	req = proto.Clone(req).(*aiplatformpb.ListMetadataSchemasRequest)
  3669  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3670  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.MetadataSchema, string, error) {
  3671  		resp := &aiplatformpb.ListMetadataSchemasResponse{}
  3672  		if pageToken != "" {
  3673  			req.PageToken = pageToken
  3674  		}
  3675  		if pageSize > math.MaxInt32 {
  3676  			req.PageSize = math.MaxInt32
  3677  		} else if pageSize != 0 {
  3678  			req.PageSize = int32(pageSize)
  3679  		}
  3680  		baseUrl, err := url.Parse(c.endpoint)
  3681  		if err != nil {
  3682  			return nil, "", err
  3683  		}
  3684  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/metadataSchemas", req.GetParent())
  3685  
  3686  		params := url.Values{}
  3687  		params.Add("$alt", "json;enum-encoding=int")
  3688  		if req.GetFilter() != "" {
  3689  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3690  		}
  3691  		if req.GetPageSize() != 0 {
  3692  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3693  		}
  3694  		if req.GetPageToken() != "" {
  3695  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3696  		}
  3697  
  3698  		baseUrl.RawQuery = params.Encode()
  3699  
  3700  		// Build HTTP headers from client and context metadata.
  3701  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3702  		headers := gax.BuildHeaders(ctx, hds...)
  3703  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3704  			if settings.Path != "" {
  3705  				baseUrl.Path = settings.Path
  3706  			}
  3707  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3708  			if err != nil {
  3709  				return err
  3710  			}
  3711  			httpReq.Header = headers
  3712  
  3713  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListMetadataSchemas")
  3714  			if err != nil {
  3715  				return err
  3716  			}
  3717  			if err := unm.Unmarshal(buf, resp); err != nil {
  3718  				return err
  3719  			}
  3720  
  3721  			return nil
  3722  		}, opts...)
  3723  		if e != nil {
  3724  			return nil, "", e
  3725  		}
  3726  		it.Response = resp
  3727  		return resp.GetMetadataSchemas(), resp.GetNextPageToken(), nil
  3728  	}
  3729  
  3730  	fetch := func(pageSize int, pageToken string) (string, error) {
  3731  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3732  		if err != nil {
  3733  			return "", err
  3734  		}
  3735  		it.items = append(it.items, items...)
  3736  		return nextPageToken, nil
  3737  	}
  3738  
  3739  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3740  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3741  	it.pageInfo.Token = req.GetPageToken()
  3742  
  3743  	return it
  3744  }
  3745  
  3746  // QueryArtifactLineageSubgraph retrieves lineage of an Artifact represented through Artifacts and
  3747  // Executions connected by Event edges and returned as a LineageSubgraph.
  3748  func (c *metadataRESTClient) QueryArtifactLineageSubgraph(ctx context.Context, req *aiplatformpb.QueryArtifactLineageSubgraphRequest, opts ...gax.CallOption) (*aiplatformpb.LineageSubgraph, error) {
  3749  	baseUrl, err := url.Parse(c.endpoint)
  3750  	if err != nil {
  3751  		return nil, err
  3752  	}
  3753  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:queryArtifactLineageSubgraph", req.GetArtifact())
  3754  
  3755  	params := url.Values{}
  3756  	params.Add("$alt", "json;enum-encoding=int")
  3757  	if req.GetFilter() != "" {
  3758  		params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3759  	}
  3760  	if req.GetMaxHops() != 0 {
  3761  		params.Add("maxHops", fmt.Sprintf("%v", req.GetMaxHops()))
  3762  	}
  3763  
  3764  	baseUrl.RawQuery = params.Encode()
  3765  
  3766  	// Build HTTP headers from client and context metadata.
  3767  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "artifact", url.QueryEscape(req.GetArtifact()))}
  3768  
  3769  	hds = append(c.xGoogHeaders, hds...)
  3770  	hds = append(hds, "Content-Type", "application/json")
  3771  	headers := gax.BuildHeaders(ctx, hds...)
  3772  	opts = append((*c.CallOptions).QueryArtifactLineageSubgraph[0:len((*c.CallOptions).QueryArtifactLineageSubgraph):len((*c.CallOptions).QueryArtifactLineageSubgraph)], opts...)
  3773  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3774  	resp := &aiplatformpb.LineageSubgraph{}
  3775  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3776  		if settings.Path != "" {
  3777  			baseUrl.Path = settings.Path
  3778  		}
  3779  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3780  		if err != nil {
  3781  			return err
  3782  		}
  3783  		httpReq = httpReq.WithContext(ctx)
  3784  		httpReq.Header = headers
  3785  
  3786  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "QueryArtifactLineageSubgraph")
  3787  		if err != nil {
  3788  			return err
  3789  		}
  3790  
  3791  		if err := unm.Unmarshal(buf, resp); err != nil {
  3792  			return err
  3793  		}
  3794  
  3795  		return nil
  3796  	}, opts...)
  3797  	if e != nil {
  3798  		return nil, e
  3799  	}
  3800  	return resp, nil
  3801  }
  3802  
  3803  // GetLocation gets information about a location.
  3804  func (c *metadataRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  3805  	baseUrl, err := url.Parse(c.endpoint)
  3806  	if err != nil {
  3807  		return nil, err
  3808  	}
  3809  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  3810  
  3811  	params := url.Values{}
  3812  	params.Add("$alt", "json;enum-encoding=int")
  3813  
  3814  	baseUrl.RawQuery = params.Encode()
  3815  
  3816  	// Build HTTP headers from client and context metadata.
  3817  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  3818  
  3819  	hds = append(c.xGoogHeaders, hds...)
  3820  	hds = append(hds, "Content-Type", "application/json")
  3821  	headers := gax.BuildHeaders(ctx, hds...)
  3822  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  3823  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3824  	resp := &locationpb.Location{}
  3825  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3826  		if settings.Path != "" {
  3827  			baseUrl.Path = settings.Path
  3828  		}
  3829  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3830  		if err != nil {
  3831  			return err
  3832  		}
  3833  		httpReq = httpReq.WithContext(ctx)
  3834  		httpReq.Header = headers
  3835  
  3836  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
  3837  		if err != nil {
  3838  			return err
  3839  		}
  3840  
  3841  		if err := unm.Unmarshal(buf, resp); err != nil {
  3842  			return err
  3843  		}
  3844  
  3845  		return nil
  3846  	}, opts...)
  3847  	if e != nil {
  3848  		return nil, e
  3849  	}
  3850  	return resp, nil
  3851  }
  3852  
  3853  // ListLocations lists information about the supported locations for this service.
  3854  func (c *metadataRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  3855  	it := &LocationIterator{}
  3856  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  3857  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3858  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  3859  		resp := &locationpb.ListLocationsResponse{}
  3860  		if pageToken != "" {
  3861  			req.PageToken = pageToken
  3862  		}
  3863  		if pageSize > math.MaxInt32 {
  3864  			req.PageSize = math.MaxInt32
  3865  		} else if pageSize != 0 {
  3866  			req.PageSize = int32(pageSize)
  3867  		}
  3868  		baseUrl, err := url.Parse(c.endpoint)
  3869  		if err != nil {
  3870  			return nil, "", err
  3871  		}
  3872  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  3873  
  3874  		params := url.Values{}
  3875  		params.Add("$alt", "json;enum-encoding=int")
  3876  		if req.GetFilter() != "" {
  3877  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  3878  		}
  3879  		if req.GetPageSize() != 0 {
  3880  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  3881  		}
  3882  		if req.GetPageToken() != "" {
  3883  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  3884  		}
  3885  
  3886  		baseUrl.RawQuery = params.Encode()
  3887  
  3888  		// Build HTTP headers from client and context metadata.
  3889  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  3890  		headers := gax.BuildHeaders(ctx, hds...)
  3891  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3892  			if settings.Path != "" {
  3893  				baseUrl.Path = settings.Path
  3894  			}
  3895  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  3896  			if err != nil {
  3897  				return err
  3898  			}
  3899  			httpReq.Header = headers
  3900  
  3901  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  3902  			if err != nil {
  3903  				return err
  3904  			}
  3905  			if err := unm.Unmarshal(buf, resp); err != nil {
  3906  				return err
  3907  			}
  3908  
  3909  			return nil
  3910  		}, opts...)
  3911  		if e != nil {
  3912  			return nil, "", e
  3913  		}
  3914  		it.Response = resp
  3915  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  3916  	}
  3917  
  3918  	fetch := func(pageSize int, pageToken string) (string, error) {
  3919  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  3920  		if err != nil {
  3921  			return "", err
  3922  		}
  3923  		it.items = append(it.items, items...)
  3924  		return nextPageToken, nil
  3925  	}
  3926  
  3927  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  3928  	it.pageInfo.MaxSize = int(req.GetPageSize())
  3929  	it.pageInfo.Token = req.GetPageToken()
  3930  
  3931  	return it
  3932  }
  3933  
  3934  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  3935  // if the resource exists and does not have a policy set.
  3936  func (c *metadataRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  3937  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3938  	jsonReq, err := m.Marshal(req)
  3939  	if err != nil {
  3940  		return nil, err
  3941  	}
  3942  
  3943  	baseUrl, err := url.Parse(c.endpoint)
  3944  	if err != nil {
  3945  		return nil, err
  3946  	}
  3947  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  3948  
  3949  	params := url.Values{}
  3950  	params.Add("$alt", "json;enum-encoding=int")
  3951  
  3952  	baseUrl.RawQuery = params.Encode()
  3953  
  3954  	// Build HTTP headers from client and context metadata.
  3955  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  3956  
  3957  	hds = append(c.xGoogHeaders, hds...)
  3958  	hds = append(hds, "Content-Type", "application/json")
  3959  	headers := gax.BuildHeaders(ctx, hds...)
  3960  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  3961  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  3962  	resp := &iampb.Policy{}
  3963  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  3964  		if settings.Path != "" {
  3965  			baseUrl.Path = settings.Path
  3966  		}
  3967  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  3968  		if err != nil {
  3969  			return err
  3970  		}
  3971  		httpReq = httpReq.WithContext(ctx)
  3972  		httpReq.Header = headers
  3973  
  3974  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  3975  		if err != nil {
  3976  			return err
  3977  		}
  3978  
  3979  		if err := unm.Unmarshal(buf, resp); err != nil {
  3980  			return err
  3981  		}
  3982  
  3983  		return nil
  3984  	}, opts...)
  3985  	if e != nil {
  3986  		return nil, e
  3987  	}
  3988  	return resp, nil
  3989  }
  3990  
  3991  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  3992  // any existing policy.
  3993  //
  3994  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  3995  // errors.
  3996  func (c *metadataRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  3997  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  3998  	jsonReq, err := m.Marshal(req)
  3999  	if err != nil {
  4000  		return nil, err
  4001  	}
  4002  
  4003  	baseUrl, err := url.Parse(c.endpoint)
  4004  	if err != nil {
  4005  		return nil, err
  4006  	}
  4007  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  4008  
  4009  	params := url.Values{}
  4010  	params.Add("$alt", "json;enum-encoding=int")
  4011  
  4012  	baseUrl.RawQuery = params.Encode()
  4013  
  4014  	// Build HTTP headers from client and context metadata.
  4015  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  4016  
  4017  	hds = append(c.xGoogHeaders, hds...)
  4018  	hds = append(hds, "Content-Type", "application/json")
  4019  	headers := gax.BuildHeaders(ctx, hds...)
  4020  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  4021  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4022  	resp := &iampb.Policy{}
  4023  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4024  		if settings.Path != "" {
  4025  			baseUrl.Path = settings.Path
  4026  		}
  4027  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4028  		if err != nil {
  4029  			return err
  4030  		}
  4031  		httpReq = httpReq.WithContext(ctx)
  4032  		httpReq.Header = headers
  4033  
  4034  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  4035  		if err != nil {
  4036  			return err
  4037  		}
  4038  
  4039  		if err := unm.Unmarshal(buf, resp); err != nil {
  4040  			return err
  4041  		}
  4042  
  4043  		return nil
  4044  	}, opts...)
  4045  	if e != nil {
  4046  		return nil, e
  4047  	}
  4048  	return resp, nil
  4049  }
  4050  
  4051  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  4052  // resource does not exist, this will return an empty set of
  4053  // permissions, not a NOT_FOUND error.
  4054  //
  4055  // Note: This operation is designed to be used for building
  4056  // permission-aware UIs and command-line tools, not for authorization
  4057  // checking. This operation may “fail open” without warning.
  4058  func (c *metadataRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  4059  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  4060  	jsonReq, err := m.Marshal(req)
  4061  	if err != nil {
  4062  		return nil, err
  4063  	}
  4064  
  4065  	baseUrl, err := url.Parse(c.endpoint)
  4066  	if err != nil {
  4067  		return nil, err
  4068  	}
  4069  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  4070  
  4071  	params := url.Values{}
  4072  	params.Add("$alt", "json;enum-encoding=int")
  4073  
  4074  	baseUrl.RawQuery = params.Encode()
  4075  
  4076  	// Build HTTP headers from client and context metadata.
  4077  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  4078  
  4079  	hds = append(c.xGoogHeaders, hds...)
  4080  	hds = append(hds, "Content-Type", "application/json")
  4081  	headers := gax.BuildHeaders(ctx, hds...)
  4082  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  4083  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4084  	resp := &iampb.TestIamPermissionsResponse{}
  4085  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4086  		if settings.Path != "" {
  4087  			baseUrl.Path = settings.Path
  4088  		}
  4089  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  4090  		if err != nil {
  4091  			return err
  4092  		}
  4093  		httpReq = httpReq.WithContext(ctx)
  4094  		httpReq.Header = headers
  4095  
  4096  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  4097  		if err != nil {
  4098  			return err
  4099  		}
  4100  
  4101  		if err := unm.Unmarshal(buf, resp); err != nil {
  4102  			return err
  4103  		}
  4104  
  4105  		return nil
  4106  	}, opts...)
  4107  	if e != nil {
  4108  		return nil, e
  4109  	}
  4110  	return resp, nil
  4111  }
  4112  
  4113  // CancelOperation is a utility method from google.longrunning.Operations.
  4114  func (c *metadataRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  4115  	baseUrl, err := url.Parse(c.endpoint)
  4116  	if err != nil {
  4117  		return err
  4118  	}
  4119  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  4120  
  4121  	params := url.Values{}
  4122  	params.Add("$alt", "json;enum-encoding=int")
  4123  
  4124  	baseUrl.RawQuery = params.Encode()
  4125  
  4126  	// Build HTTP headers from client and context metadata.
  4127  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4128  
  4129  	hds = append(c.xGoogHeaders, hds...)
  4130  	hds = append(hds, "Content-Type", "application/json")
  4131  	headers := gax.BuildHeaders(ctx, hds...)
  4132  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4133  		if settings.Path != "" {
  4134  			baseUrl.Path = settings.Path
  4135  		}
  4136  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  4137  		if err != nil {
  4138  			return err
  4139  		}
  4140  		httpReq = httpReq.WithContext(ctx)
  4141  		httpReq.Header = headers
  4142  
  4143  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  4144  		return err
  4145  	}, opts...)
  4146  }
  4147  
  4148  // DeleteOperation is a utility method from google.longrunning.Operations.
  4149  func (c *metadataRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  4150  	baseUrl, err := url.Parse(c.endpoint)
  4151  	if err != nil {
  4152  		return err
  4153  	}
  4154  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  4155  
  4156  	params := url.Values{}
  4157  	params.Add("$alt", "json;enum-encoding=int")
  4158  
  4159  	baseUrl.RawQuery = params.Encode()
  4160  
  4161  	// Build HTTP headers from client and context metadata.
  4162  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4163  
  4164  	hds = append(c.xGoogHeaders, hds...)
  4165  	hds = append(hds, "Content-Type", "application/json")
  4166  	headers := gax.BuildHeaders(ctx, hds...)
  4167  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4168  		if settings.Path != "" {
  4169  			baseUrl.Path = settings.Path
  4170  		}
  4171  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  4172  		if err != nil {
  4173  			return err
  4174  		}
  4175  		httpReq = httpReq.WithContext(ctx)
  4176  		httpReq.Header = headers
  4177  
  4178  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  4179  		return err
  4180  	}, opts...)
  4181  }
  4182  
  4183  // GetOperation is a utility method from google.longrunning.Operations.
  4184  func (c *metadataRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  4185  	baseUrl, err := url.Parse(c.endpoint)
  4186  	if err != nil {
  4187  		return nil, err
  4188  	}
  4189  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  4190  
  4191  	params := url.Values{}
  4192  	params.Add("$alt", "json;enum-encoding=int")
  4193  
  4194  	baseUrl.RawQuery = params.Encode()
  4195  
  4196  	// Build HTTP headers from client and context metadata.
  4197  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4198  
  4199  	hds = append(c.xGoogHeaders, hds...)
  4200  	hds = append(hds, "Content-Type", "application/json")
  4201  	headers := gax.BuildHeaders(ctx, hds...)
  4202  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  4203  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4204  	resp := &longrunningpb.Operation{}
  4205  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4206  		if settings.Path != "" {
  4207  			baseUrl.Path = settings.Path
  4208  		}
  4209  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4210  		if err != nil {
  4211  			return err
  4212  		}
  4213  		httpReq = httpReq.WithContext(ctx)
  4214  		httpReq.Header = headers
  4215  
  4216  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  4217  		if err != nil {
  4218  			return err
  4219  		}
  4220  
  4221  		if err := unm.Unmarshal(buf, resp); err != nil {
  4222  			return err
  4223  		}
  4224  
  4225  		return nil
  4226  	}, opts...)
  4227  	if e != nil {
  4228  		return nil, e
  4229  	}
  4230  	return resp, nil
  4231  }
  4232  
  4233  // ListOperations is a utility method from google.longrunning.Operations.
  4234  func (c *metadataRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  4235  	it := &OperationIterator{}
  4236  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  4237  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4238  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  4239  		resp := &longrunningpb.ListOperationsResponse{}
  4240  		if pageToken != "" {
  4241  			req.PageToken = pageToken
  4242  		}
  4243  		if pageSize > math.MaxInt32 {
  4244  			req.PageSize = math.MaxInt32
  4245  		} else if pageSize != 0 {
  4246  			req.PageSize = int32(pageSize)
  4247  		}
  4248  		baseUrl, err := url.Parse(c.endpoint)
  4249  		if err != nil {
  4250  			return nil, "", err
  4251  		}
  4252  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  4253  
  4254  		params := url.Values{}
  4255  		params.Add("$alt", "json;enum-encoding=int")
  4256  		if req.GetFilter() != "" {
  4257  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  4258  		}
  4259  		if req.GetPageSize() != 0 {
  4260  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  4261  		}
  4262  		if req.GetPageToken() != "" {
  4263  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  4264  		}
  4265  
  4266  		baseUrl.RawQuery = params.Encode()
  4267  
  4268  		// Build HTTP headers from client and context metadata.
  4269  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  4270  		headers := gax.BuildHeaders(ctx, hds...)
  4271  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4272  			if settings.Path != "" {
  4273  				baseUrl.Path = settings.Path
  4274  			}
  4275  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  4276  			if err != nil {
  4277  				return err
  4278  			}
  4279  			httpReq.Header = headers
  4280  
  4281  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  4282  			if err != nil {
  4283  				return err
  4284  			}
  4285  			if err := unm.Unmarshal(buf, resp); err != nil {
  4286  				return err
  4287  			}
  4288  
  4289  			return nil
  4290  		}, opts...)
  4291  		if e != nil {
  4292  			return nil, "", e
  4293  		}
  4294  		it.Response = resp
  4295  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  4296  	}
  4297  
  4298  	fetch := func(pageSize int, pageToken string) (string, error) {
  4299  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  4300  		if err != nil {
  4301  			return "", err
  4302  		}
  4303  		it.items = append(it.items, items...)
  4304  		return nextPageToken, nil
  4305  	}
  4306  
  4307  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  4308  	it.pageInfo.MaxSize = int(req.GetPageSize())
  4309  	it.pageInfo.Token = req.GetPageToken()
  4310  
  4311  	return it
  4312  }
  4313  
  4314  // WaitOperation is a utility method from google.longrunning.Operations.
  4315  func (c *metadataRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  4316  	baseUrl, err := url.Parse(c.endpoint)
  4317  	if err != nil {
  4318  		return nil, err
  4319  	}
  4320  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  4321  
  4322  	params := url.Values{}
  4323  	params.Add("$alt", "json;enum-encoding=int")
  4324  	if req.GetTimeout() != nil {
  4325  		field, err := protojson.Marshal(req.GetTimeout())
  4326  		if err != nil {
  4327  			return nil, err
  4328  		}
  4329  		params.Add("timeout", string(field[1:len(field)-1]))
  4330  	}
  4331  
  4332  	baseUrl.RawQuery = params.Encode()
  4333  
  4334  	// Build HTTP headers from client and context metadata.
  4335  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  4336  
  4337  	hds = append(c.xGoogHeaders, hds...)
  4338  	hds = append(hds, "Content-Type", "application/json")
  4339  	headers := gax.BuildHeaders(ctx, hds...)
  4340  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  4341  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  4342  	resp := &longrunningpb.Operation{}
  4343  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  4344  		if settings.Path != "" {
  4345  			baseUrl.Path = settings.Path
  4346  		}
  4347  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  4348  		if err != nil {
  4349  			return err
  4350  		}
  4351  		httpReq = httpReq.WithContext(ctx)
  4352  		httpReq.Header = headers
  4353  
  4354  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  4355  		if err != nil {
  4356  			return err
  4357  		}
  4358  
  4359  		if err := unm.Unmarshal(buf, resp); err != nil {
  4360  			return err
  4361  		}
  4362  
  4363  		return nil
  4364  	}, opts...)
  4365  	if e != nil {
  4366  		return nil, e
  4367  	}
  4368  	return resp, nil
  4369  }
  4370  
  4371  // CreateMetadataStoreOperation returns a new CreateMetadataStoreOperation from a given name.
  4372  // The name must be that of a previously created CreateMetadataStoreOperation, possibly from a different process.
  4373  func (c *metadataGRPCClient) CreateMetadataStoreOperation(name string) *CreateMetadataStoreOperation {
  4374  	return &CreateMetadataStoreOperation{
  4375  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4376  	}
  4377  }
  4378  
  4379  // CreateMetadataStoreOperation returns a new CreateMetadataStoreOperation from a given name.
  4380  // The name must be that of a previously created CreateMetadataStoreOperation, possibly from a different process.
  4381  func (c *metadataRESTClient) CreateMetadataStoreOperation(name string) *CreateMetadataStoreOperation {
  4382  	override := fmt.Sprintf("/ui/%s", name)
  4383  	return &CreateMetadataStoreOperation{
  4384  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4385  		pollPath: override,
  4386  	}
  4387  }
  4388  
  4389  // DeleteArtifactOperation returns a new DeleteArtifactOperation from a given name.
  4390  // The name must be that of a previously created DeleteArtifactOperation, possibly from a different process.
  4391  func (c *metadataGRPCClient) DeleteArtifactOperation(name string) *DeleteArtifactOperation {
  4392  	return &DeleteArtifactOperation{
  4393  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4394  	}
  4395  }
  4396  
  4397  // DeleteArtifactOperation returns a new DeleteArtifactOperation from a given name.
  4398  // The name must be that of a previously created DeleteArtifactOperation, possibly from a different process.
  4399  func (c *metadataRESTClient) DeleteArtifactOperation(name string) *DeleteArtifactOperation {
  4400  	override := fmt.Sprintf("/ui/%s", name)
  4401  	return &DeleteArtifactOperation{
  4402  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4403  		pollPath: override,
  4404  	}
  4405  }
  4406  
  4407  // DeleteContextOperation returns a new DeleteContextOperation from a given name.
  4408  // The name must be that of a previously created DeleteContextOperation, possibly from a different process.
  4409  func (c *metadataGRPCClient) DeleteContextOperation(name string) *DeleteContextOperation {
  4410  	return &DeleteContextOperation{
  4411  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4412  	}
  4413  }
  4414  
  4415  // DeleteContextOperation returns a new DeleteContextOperation from a given name.
  4416  // The name must be that of a previously created DeleteContextOperation, possibly from a different process.
  4417  func (c *metadataRESTClient) DeleteContextOperation(name string) *DeleteContextOperation {
  4418  	override := fmt.Sprintf("/ui/%s", name)
  4419  	return &DeleteContextOperation{
  4420  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4421  		pollPath: override,
  4422  	}
  4423  }
  4424  
  4425  // DeleteExecutionOperation returns a new DeleteExecutionOperation from a given name.
  4426  // The name must be that of a previously created DeleteExecutionOperation, possibly from a different process.
  4427  func (c *metadataGRPCClient) DeleteExecutionOperation(name string) *DeleteExecutionOperation {
  4428  	return &DeleteExecutionOperation{
  4429  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4430  	}
  4431  }
  4432  
  4433  // DeleteExecutionOperation returns a new DeleteExecutionOperation from a given name.
  4434  // The name must be that of a previously created DeleteExecutionOperation, possibly from a different process.
  4435  func (c *metadataRESTClient) DeleteExecutionOperation(name string) *DeleteExecutionOperation {
  4436  	override := fmt.Sprintf("/ui/%s", name)
  4437  	return &DeleteExecutionOperation{
  4438  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4439  		pollPath: override,
  4440  	}
  4441  }
  4442  
  4443  // DeleteMetadataStoreOperation returns a new DeleteMetadataStoreOperation from a given name.
  4444  // The name must be that of a previously created DeleteMetadataStoreOperation, possibly from a different process.
  4445  func (c *metadataGRPCClient) DeleteMetadataStoreOperation(name string) *DeleteMetadataStoreOperation {
  4446  	return &DeleteMetadataStoreOperation{
  4447  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4448  	}
  4449  }
  4450  
  4451  // DeleteMetadataStoreOperation returns a new DeleteMetadataStoreOperation from a given name.
  4452  // The name must be that of a previously created DeleteMetadataStoreOperation, possibly from a different process.
  4453  func (c *metadataRESTClient) DeleteMetadataStoreOperation(name string) *DeleteMetadataStoreOperation {
  4454  	override := fmt.Sprintf("/ui/%s", name)
  4455  	return &DeleteMetadataStoreOperation{
  4456  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4457  		pollPath: override,
  4458  	}
  4459  }
  4460  
  4461  // PurgeArtifactsOperation returns a new PurgeArtifactsOperation from a given name.
  4462  // The name must be that of a previously created PurgeArtifactsOperation, possibly from a different process.
  4463  func (c *metadataGRPCClient) PurgeArtifactsOperation(name string) *PurgeArtifactsOperation {
  4464  	return &PurgeArtifactsOperation{
  4465  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4466  	}
  4467  }
  4468  
  4469  // PurgeArtifactsOperation returns a new PurgeArtifactsOperation from a given name.
  4470  // The name must be that of a previously created PurgeArtifactsOperation, possibly from a different process.
  4471  func (c *metadataRESTClient) PurgeArtifactsOperation(name string) *PurgeArtifactsOperation {
  4472  	override := fmt.Sprintf("/ui/%s", name)
  4473  	return &PurgeArtifactsOperation{
  4474  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4475  		pollPath: override,
  4476  	}
  4477  }
  4478  
  4479  // PurgeContextsOperation returns a new PurgeContextsOperation from a given name.
  4480  // The name must be that of a previously created PurgeContextsOperation, possibly from a different process.
  4481  func (c *metadataGRPCClient) PurgeContextsOperation(name string) *PurgeContextsOperation {
  4482  	return &PurgeContextsOperation{
  4483  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4484  	}
  4485  }
  4486  
  4487  // PurgeContextsOperation returns a new PurgeContextsOperation from a given name.
  4488  // The name must be that of a previously created PurgeContextsOperation, possibly from a different process.
  4489  func (c *metadataRESTClient) PurgeContextsOperation(name string) *PurgeContextsOperation {
  4490  	override := fmt.Sprintf("/ui/%s", name)
  4491  	return &PurgeContextsOperation{
  4492  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4493  		pollPath: override,
  4494  	}
  4495  }
  4496  
  4497  // PurgeExecutionsOperation returns a new PurgeExecutionsOperation from a given name.
  4498  // The name must be that of a previously created PurgeExecutionsOperation, possibly from a different process.
  4499  func (c *metadataGRPCClient) PurgeExecutionsOperation(name string) *PurgeExecutionsOperation {
  4500  	return &PurgeExecutionsOperation{
  4501  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4502  	}
  4503  }
  4504  
  4505  // PurgeExecutionsOperation returns a new PurgeExecutionsOperation from a given name.
  4506  // The name must be that of a previously created PurgeExecutionsOperation, possibly from a different process.
  4507  func (c *metadataRESTClient) PurgeExecutionsOperation(name string) *PurgeExecutionsOperation {
  4508  	override := fmt.Sprintf("/ui/%s", name)
  4509  	return &PurgeExecutionsOperation{
  4510  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  4511  		pollPath: override,
  4512  	}
  4513  }