cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/memory_bank_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  
    28  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
    29  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    30  	"cloud.google.com/go/longrunning"
    31  	lroauto "cloud.google.com/go/longrunning/autogen"
    32  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    33  	gax "github.com/googleapis/gax-go/v2"
    34  	"google.golang.org/api/iterator"
    35  	"google.golang.org/api/option"
    36  	"google.golang.org/api/option/internaloption"
    37  	gtransport "google.golang.org/api/transport/grpc"
    38  	httptransport "google.golang.org/api/transport/http"
    39  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    40  	"google.golang.org/grpc"
    41  	"google.golang.org/protobuf/encoding/protojson"
    42  	"google.golang.org/protobuf/proto"
    43  )
    44  
    45  var newMemoryBankClientHook clientHook
    46  
    47  // MemoryBankCallOptions contains the retry settings for each method of MemoryBankClient.
    48  type MemoryBankCallOptions struct {
    49  	CreateMemory       []gax.CallOption
    50  	GetMemory          []gax.CallOption
    51  	UpdateMemory       []gax.CallOption
    52  	ListMemories       []gax.CallOption
    53  	DeleteMemory       []gax.CallOption
    54  	GenerateMemories   []gax.CallOption
    55  	RetrieveMemories   []gax.CallOption
    56  	GetLocation        []gax.CallOption
    57  	ListLocations      []gax.CallOption
    58  	GetIamPolicy       []gax.CallOption
    59  	SetIamPolicy       []gax.CallOption
    60  	TestIamPermissions []gax.CallOption
    61  	CancelOperation    []gax.CallOption
    62  	DeleteOperation    []gax.CallOption
    63  	GetOperation       []gax.CallOption
    64  	ListOperations     []gax.CallOption
    65  	WaitOperation      []gax.CallOption
    66  }
    67  
    68  func defaultMemoryBankGRPCClientOptions() []option.ClientOption {
    69  	return []option.ClientOption{
    70  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    71  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    72  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    73  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    74  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    75  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    76  		internaloption.EnableJwtWithScope(),
    77  		internaloption.EnableNewAuthLibrary(),
    78  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    79  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    80  	}
    81  }
    82  
    83  func defaultMemoryBankCallOptions() *MemoryBankCallOptions {
    84  	return &MemoryBankCallOptions{
    85  		CreateMemory:       []gax.CallOption{},
    86  		GetMemory:          []gax.CallOption{},
    87  		UpdateMemory:       []gax.CallOption{},
    88  		ListMemories:       []gax.CallOption{},
    89  		DeleteMemory:       []gax.CallOption{},
    90  		GenerateMemories:   []gax.CallOption{},
    91  		RetrieveMemories:   []gax.CallOption{},
    92  		GetLocation:        []gax.CallOption{},
    93  		ListLocations:      []gax.CallOption{},
    94  		GetIamPolicy:       []gax.CallOption{},
    95  		SetIamPolicy:       []gax.CallOption{},
    96  		TestIamPermissions: []gax.CallOption{},
    97  		CancelOperation:    []gax.CallOption{},
    98  		DeleteOperation:    []gax.CallOption{},
    99  		GetOperation:       []gax.CallOption{},
   100  		ListOperations:     []gax.CallOption{},
   101  		WaitOperation:      []gax.CallOption{},
   102  	}
   103  }
   104  
   105  func defaultMemoryBankRESTCallOptions() *MemoryBankCallOptions {
   106  	return &MemoryBankCallOptions{
   107  		CreateMemory:       []gax.CallOption{},
   108  		GetMemory:          []gax.CallOption{},
   109  		UpdateMemory:       []gax.CallOption{},
   110  		ListMemories:       []gax.CallOption{},
   111  		DeleteMemory:       []gax.CallOption{},
   112  		GenerateMemories:   []gax.CallOption{},
   113  		RetrieveMemories:   []gax.CallOption{},
   114  		GetLocation:        []gax.CallOption{},
   115  		ListLocations:      []gax.CallOption{},
   116  		GetIamPolicy:       []gax.CallOption{},
   117  		SetIamPolicy:       []gax.CallOption{},
   118  		TestIamPermissions: []gax.CallOption{},
   119  		CancelOperation:    []gax.CallOption{},
   120  		DeleteOperation:    []gax.CallOption{},
   121  		GetOperation:       []gax.CallOption{},
   122  		ListOperations:     []gax.CallOption{},
   123  		WaitOperation:      []gax.CallOption{},
   124  	}
   125  }
   126  
   127  // internalMemoryBankClient is an interface that defines the methods available from Vertex AI API.
   128  type internalMemoryBankClient interface {
   129  	Close() error
   130  	setGoogleClientInfo(...string)
   131  	Connection() *grpc.ClientConn
   132  	CreateMemory(context.Context, *aiplatformpb.CreateMemoryRequest, ...gax.CallOption) (*CreateMemoryOperation, error)
   133  	CreateMemoryOperation(name string) *CreateMemoryOperation
   134  	GetMemory(context.Context, *aiplatformpb.GetMemoryRequest, ...gax.CallOption) (*aiplatformpb.Memory, error)
   135  	UpdateMemory(context.Context, *aiplatformpb.UpdateMemoryRequest, ...gax.CallOption) (*UpdateMemoryOperation, error)
   136  	UpdateMemoryOperation(name string) *UpdateMemoryOperation
   137  	ListMemories(context.Context, *aiplatformpb.ListMemoriesRequest, ...gax.CallOption) *MemoryIterator
   138  	DeleteMemory(context.Context, *aiplatformpb.DeleteMemoryRequest, ...gax.CallOption) (*DeleteMemoryOperation, error)
   139  	DeleteMemoryOperation(name string) *DeleteMemoryOperation
   140  	GenerateMemories(context.Context, *aiplatformpb.GenerateMemoriesRequest, ...gax.CallOption) (*GenerateMemoriesOperation, error)
   141  	GenerateMemoriesOperation(name string) *GenerateMemoriesOperation
   142  	RetrieveMemories(context.Context, *aiplatformpb.RetrieveMemoriesRequest, ...gax.CallOption) (*aiplatformpb.RetrieveMemoriesResponse, error)
   143  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   144  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   145  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   146  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   147  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   148  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   149  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   150  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   151  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   152  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   153  }
   154  
   155  // MemoryBankClient is a client for interacting with Vertex AI API.
   156  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   157  //
   158  // A service for managing memories for LLM applications.
   159  type MemoryBankClient struct {
   160  	// The internal transport-dependent client.
   161  	internalClient internalMemoryBankClient
   162  
   163  	// The call options for this service.
   164  	CallOptions *MemoryBankCallOptions
   165  
   166  	// LROClient is used internally to handle long-running operations.
   167  	// It is exposed so that its CallOptions can be modified if required.
   168  	// Users should not Close this client.
   169  	LROClient *lroauto.OperationsClient
   170  }
   171  
   172  // Wrapper methods routed to the internal client.
   173  
   174  // Close closes the connection to the API service. The user should invoke this when
   175  // the client is no longer required.
   176  func (c *MemoryBankClient) Close() error {
   177  	return c.internalClient.Close()
   178  }
   179  
   180  // setGoogleClientInfo sets the name and version of the application in
   181  // the `x-goog-api-client` header passed on each request. Intended for
   182  // use by Google-written clients.
   183  func (c *MemoryBankClient) setGoogleClientInfo(keyval ...string) {
   184  	c.internalClient.setGoogleClientInfo(keyval...)
   185  }
   186  
   187  // Connection returns a connection to the API service.
   188  //
   189  // Deprecated: Connections are now pooled so this method does not always
   190  // return the same resource.
   191  func (c *MemoryBankClient) Connection() *grpc.ClientConn {
   192  	return c.internalClient.Connection()
   193  }
   194  
   195  // CreateMemory create a Memory.
   196  func (c *MemoryBankClient) CreateMemory(ctx context.Context, req *aiplatformpb.CreateMemoryRequest, opts ...gax.CallOption) (*CreateMemoryOperation, error) {
   197  	return c.internalClient.CreateMemory(ctx, req, opts...)
   198  }
   199  
   200  // CreateMemoryOperation returns a new CreateMemoryOperation from a given name.
   201  // The name must be that of a previously created CreateMemoryOperation, possibly from a different process.
   202  func (c *MemoryBankClient) CreateMemoryOperation(name string) *CreateMemoryOperation {
   203  	return c.internalClient.CreateMemoryOperation(name)
   204  }
   205  
   206  // GetMemory get a Memory.
   207  func (c *MemoryBankClient) GetMemory(ctx context.Context, req *aiplatformpb.GetMemoryRequest, opts ...gax.CallOption) (*aiplatformpb.Memory, error) {
   208  	return c.internalClient.GetMemory(ctx, req, opts...)
   209  }
   210  
   211  // UpdateMemory update a Memory.
   212  func (c *MemoryBankClient) UpdateMemory(ctx context.Context, req *aiplatformpb.UpdateMemoryRequest, opts ...gax.CallOption) (*UpdateMemoryOperation, error) {
   213  	return c.internalClient.UpdateMemory(ctx, req, opts...)
   214  }
   215  
   216  // UpdateMemoryOperation returns a new UpdateMemoryOperation from a given name.
   217  // The name must be that of a previously created UpdateMemoryOperation, possibly from a different process.
   218  func (c *MemoryBankClient) UpdateMemoryOperation(name string) *UpdateMemoryOperation {
   219  	return c.internalClient.UpdateMemoryOperation(name)
   220  }
   221  
   222  // ListMemories list Memories.
   223  func (c *MemoryBankClient) ListMemories(ctx context.Context, req *aiplatformpb.ListMemoriesRequest, opts ...gax.CallOption) *MemoryIterator {
   224  	return c.internalClient.ListMemories(ctx, req, opts...)
   225  }
   226  
   227  // DeleteMemory delete a Memory.
   228  func (c *MemoryBankClient) DeleteMemory(ctx context.Context, req *aiplatformpb.DeleteMemoryRequest, opts ...gax.CallOption) (*DeleteMemoryOperation, error) {
   229  	return c.internalClient.DeleteMemory(ctx, req, opts...)
   230  }
   231  
   232  // DeleteMemoryOperation returns a new DeleteMemoryOperation from a given name.
   233  // The name must be that of a previously created DeleteMemoryOperation, possibly from a different process.
   234  func (c *MemoryBankClient) DeleteMemoryOperation(name string) *DeleteMemoryOperation {
   235  	return c.internalClient.DeleteMemoryOperation(name)
   236  }
   237  
   238  // GenerateMemories generate memories.
   239  func (c *MemoryBankClient) GenerateMemories(ctx context.Context, req *aiplatformpb.GenerateMemoriesRequest, opts ...gax.CallOption) (*GenerateMemoriesOperation, error) {
   240  	return c.internalClient.GenerateMemories(ctx, req, opts...)
   241  }
   242  
   243  // GenerateMemoriesOperation returns a new GenerateMemoriesOperation from a given name.
   244  // The name must be that of a previously created GenerateMemoriesOperation, possibly from a different process.
   245  func (c *MemoryBankClient) GenerateMemoriesOperation(name string) *GenerateMemoriesOperation {
   246  	return c.internalClient.GenerateMemoriesOperation(name)
   247  }
   248  
   249  // RetrieveMemories retrieve memories.
   250  func (c *MemoryBankClient) RetrieveMemories(ctx context.Context, req *aiplatformpb.RetrieveMemoriesRequest, opts ...gax.CallOption) (*aiplatformpb.RetrieveMemoriesResponse, error) {
   251  	return c.internalClient.RetrieveMemories(ctx, req, opts...)
   252  }
   253  
   254  // GetLocation gets information about a location.
   255  func (c *MemoryBankClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   256  	return c.internalClient.GetLocation(ctx, req, opts...)
   257  }
   258  
   259  // ListLocations lists information about the supported locations for this service.
   260  func (c *MemoryBankClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   261  	return c.internalClient.ListLocations(ctx, req, opts...)
   262  }
   263  
   264  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   265  // if the resource exists and does not have a policy set.
   266  func (c *MemoryBankClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   267  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   268  }
   269  
   270  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   271  // any existing policy.
   272  //
   273  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   274  // errors.
   275  func (c *MemoryBankClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   276  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   277  }
   278  
   279  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   280  // resource does not exist, this will return an empty set of
   281  // permissions, not a NOT_FOUND error.
   282  //
   283  // Note: This operation is designed to be used for building
   284  // permission-aware UIs and command-line tools, not for authorization
   285  // checking. This operation may “fail open” without warning.
   286  func (c *MemoryBankClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   287  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   288  }
   289  
   290  // CancelOperation is a utility method from google.longrunning.Operations.
   291  func (c *MemoryBankClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   292  	return c.internalClient.CancelOperation(ctx, req, opts...)
   293  }
   294  
   295  // DeleteOperation is a utility method from google.longrunning.Operations.
   296  func (c *MemoryBankClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   297  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   298  }
   299  
   300  // GetOperation is a utility method from google.longrunning.Operations.
   301  func (c *MemoryBankClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   302  	return c.internalClient.GetOperation(ctx, req, opts...)
   303  }
   304  
   305  // ListOperations is a utility method from google.longrunning.Operations.
   306  func (c *MemoryBankClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   307  	return c.internalClient.ListOperations(ctx, req, opts...)
   308  }
   309  
   310  // WaitOperation is a utility method from google.longrunning.Operations.
   311  func (c *MemoryBankClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   312  	return c.internalClient.WaitOperation(ctx, req, opts...)
   313  }
   314  
   315  // memoryBankGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   316  //
   317  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   318  type memoryBankGRPCClient struct {
   319  	// Connection pool of gRPC connections to the service.
   320  	connPool gtransport.ConnPool
   321  
   322  	// Points back to the CallOptions field of the containing MemoryBankClient
   323  	CallOptions **MemoryBankCallOptions
   324  
   325  	// The gRPC API client.
   326  	memoryBankClient aiplatformpb.MemoryBankServiceClient
   327  
   328  	// LROClient is used internally to handle long-running operations.
   329  	// It is exposed so that its CallOptions can be modified if required.
   330  	// Users should not Close this client.
   331  	LROClient **lroauto.OperationsClient
   332  
   333  	operationsClient longrunningpb.OperationsClient
   334  
   335  	iamPolicyClient iampb.IAMPolicyClient
   336  
   337  	locationsClient locationpb.LocationsClient
   338  
   339  	// The x-goog-* metadata to be sent with each request.
   340  	xGoogHeaders []string
   341  
   342  	logger *slog.Logger
   343  }
   344  
   345  // NewMemoryBankClient creates a new memory bank service client based on gRPC.
   346  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   347  //
   348  // A service for managing memories for LLM applications.
   349  func NewMemoryBankClient(ctx context.Context, opts ...option.ClientOption) (*MemoryBankClient, error) {
   350  	clientOpts := defaultMemoryBankGRPCClientOptions()
   351  	if newMemoryBankClientHook != nil {
   352  		hookOpts, err := newMemoryBankClientHook(ctx, clientHookParams{})
   353  		if err != nil {
   354  			return nil, err
   355  		}
   356  		clientOpts = append(clientOpts, hookOpts...)
   357  	}
   358  
   359  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   360  	if err != nil {
   361  		return nil, err
   362  	}
   363  	client := MemoryBankClient{CallOptions: defaultMemoryBankCallOptions()}
   364  
   365  	c := &memoryBankGRPCClient{
   366  		connPool:         connPool,
   367  		memoryBankClient: aiplatformpb.NewMemoryBankServiceClient(connPool),
   368  		CallOptions:      &client.CallOptions,
   369  		logger:           internaloption.GetLogger(opts),
   370  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   371  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   372  		locationsClient:  locationpb.NewLocationsClient(connPool),
   373  	}
   374  	c.setGoogleClientInfo()
   375  
   376  	client.internalClient = c
   377  
   378  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   379  	if err != nil {
   380  		// This error "should not happen", since we are just reusing old connection pool
   381  		// and never actually need to dial.
   382  		// If this does happen, we could leak connp. However, we cannot close conn:
   383  		// If the user invoked the constructor with option.WithGRPCConn,
   384  		// we would close a connection that's still in use.
   385  		// TODO: investigate error conditions.
   386  		return nil, err
   387  	}
   388  	c.LROClient = &client.LROClient
   389  	return &client, nil
   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 *memoryBankGRPCClient) Connection() *grpc.ClientConn {
   397  	return c.connPool.Conn()
   398  }
   399  
   400  // setGoogleClientInfo sets the name and version of the application in
   401  // the `x-goog-api-client` header passed on each request. Intended for
   402  // use by Google-written clients.
   403  func (c *memoryBankGRPCClient) setGoogleClientInfo(keyval ...string) {
   404  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   405  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   406  	c.xGoogHeaders = []string{
   407  		"x-goog-api-client", gax.XGoogHeader(kv...),
   408  	}
   409  }
   410  
   411  // Close closes the connection to the API service. The user should invoke this when
   412  // the client is no longer required.
   413  func (c *memoryBankGRPCClient) Close() error {
   414  	return c.connPool.Close()
   415  }
   416  
   417  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   418  type memoryBankRESTClient struct {
   419  	// The http endpoint to connect to.
   420  	endpoint string
   421  
   422  	// The http client.
   423  	httpClient *http.Client
   424  
   425  	// LROClient is used internally to handle long-running operations.
   426  	// It is exposed so that its CallOptions can be modified if required.
   427  	// Users should not Close this client.
   428  	LROClient **lroauto.OperationsClient
   429  
   430  	// The x-goog-* headers to be sent with each request.
   431  	xGoogHeaders []string
   432  
   433  	// Points back to the CallOptions field of the containing MemoryBankClient
   434  	CallOptions **MemoryBankCallOptions
   435  
   436  	logger *slog.Logger
   437  }
   438  
   439  // NewMemoryBankRESTClient creates a new memory bank service rest client.
   440  //
   441  // A service for managing memories for LLM applications.
   442  func NewMemoryBankRESTClient(ctx context.Context, opts ...option.ClientOption) (*MemoryBankClient, error) {
   443  	clientOpts := append(defaultMemoryBankRESTClientOptions(), opts...)
   444  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   445  	if err != nil {
   446  		return nil, err
   447  	}
   448  
   449  	callOpts := defaultMemoryBankRESTCallOptions()
   450  	c := &memoryBankRESTClient{
   451  		endpoint:    endpoint,
   452  		httpClient:  httpClient,
   453  		CallOptions: &callOpts,
   454  		logger:      internaloption.GetLogger(opts),
   455  	}
   456  	c.setGoogleClientInfo()
   457  
   458  	lroOpts := []option.ClientOption{
   459  		option.WithHTTPClient(httpClient),
   460  		option.WithEndpoint(endpoint),
   461  	}
   462  	opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
   463  	if err != nil {
   464  		return nil, err
   465  	}
   466  	c.LROClient = &opClient
   467  
   468  	return &MemoryBankClient{internalClient: c, CallOptions: callOpts}, nil
   469  }
   470  
   471  func defaultMemoryBankRESTClientOptions() []option.ClientOption {
   472  	return []option.ClientOption{
   473  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   474  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   475  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   476  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   477  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   478  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   479  		internaloption.EnableNewAuthLibrary(),
   480  	}
   481  }
   482  
   483  // setGoogleClientInfo sets the name and version of the application in
   484  // the `x-goog-api-client` header passed on each request. Intended for
   485  // use by Google-written clients.
   486  func (c *memoryBankRESTClient) setGoogleClientInfo(keyval ...string) {
   487  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   488  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   489  	c.xGoogHeaders = []string{
   490  		"x-goog-api-client", gax.XGoogHeader(kv...),
   491  	}
   492  }
   493  
   494  // Close closes the connection to the API service. The user should invoke this when
   495  // the client is no longer required.
   496  func (c *memoryBankRESTClient) Close() error {
   497  	// Replace httpClient with nil to force cleanup.
   498  	c.httpClient = nil
   499  	return nil
   500  }
   501  
   502  // Connection returns a connection to the API service.
   503  //
   504  // Deprecated: This method always returns nil.
   505  func (c *memoryBankRESTClient) Connection() *grpc.ClientConn {
   506  	return nil
   507  }
   508  func (c *memoryBankGRPCClient) CreateMemory(ctx context.Context, req *aiplatformpb.CreateMemoryRequest, opts ...gax.CallOption) (*CreateMemoryOperation, error) {
   509  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   510  
   511  	hds = append(c.xGoogHeaders, hds...)
   512  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   513  	opts = append((*c.CallOptions).CreateMemory[0:len((*c.CallOptions).CreateMemory):len((*c.CallOptions).CreateMemory)], opts...)
   514  	var resp *longrunningpb.Operation
   515  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   516  		var err error
   517  		resp, err = executeRPC(ctx, c.memoryBankClient.CreateMemory, req, settings.GRPC, c.logger, "CreateMemory")
   518  		return err
   519  	}, opts...)
   520  	if err != nil {
   521  		return nil, err
   522  	}
   523  	return &CreateMemoryOperation{
   524  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   525  	}, nil
   526  }
   527  
   528  func (c *memoryBankGRPCClient) GetMemory(ctx context.Context, req *aiplatformpb.GetMemoryRequest, opts ...gax.CallOption) (*aiplatformpb.Memory, error) {
   529  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   530  
   531  	hds = append(c.xGoogHeaders, hds...)
   532  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   533  	opts = append((*c.CallOptions).GetMemory[0:len((*c.CallOptions).GetMemory):len((*c.CallOptions).GetMemory)], opts...)
   534  	var resp *aiplatformpb.Memory
   535  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   536  		var err error
   537  		resp, err = executeRPC(ctx, c.memoryBankClient.GetMemory, req, settings.GRPC, c.logger, "GetMemory")
   538  		return err
   539  	}, opts...)
   540  	if err != nil {
   541  		return nil, err
   542  	}
   543  	return resp, nil
   544  }
   545  
   546  func (c *memoryBankGRPCClient) UpdateMemory(ctx context.Context, req *aiplatformpb.UpdateMemoryRequest, opts ...gax.CallOption) (*UpdateMemoryOperation, error) {
   547  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "memory.name", url.QueryEscape(req.GetMemory().GetName()))}
   548  
   549  	hds = append(c.xGoogHeaders, hds...)
   550  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   551  	opts = append((*c.CallOptions).UpdateMemory[0:len((*c.CallOptions).UpdateMemory):len((*c.CallOptions).UpdateMemory)], opts...)
   552  	var resp *longrunningpb.Operation
   553  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   554  		var err error
   555  		resp, err = executeRPC(ctx, c.memoryBankClient.UpdateMemory, req, settings.GRPC, c.logger, "UpdateMemory")
   556  		return err
   557  	}, opts...)
   558  	if err != nil {
   559  		return nil, err
   560  	}
   561  	return &UpdateMemoryOperation{
   562  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   563  	}, nil
   564  }
   565  
   566  func (c *memoryBankGRPCClient) ListMemories(ctx context.Context, req *aiplatformpb.ListMemoriesRequest, opts ...gax.CallOption) *MemoryIterator {
   567  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   568  
   569  	hds = append(c.xGoogHeaders, hds...)
   570  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   571  	opts = append((*c.CallOptions).ListMemories[0:len((*c.CallOptions).ListMemories):len((*c.CallOptions).ListMemories)], opts...)
   572  	it := &MemoryIterator{}
   573  	req = proto.Clone(req).(*aiplatformpb.ListMemoriesRequest)
   574  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Memory, string, error) {
   575  		resp := &aiplatformpb.ListMemoriesResponse{}
   576  		if pageToken != "" {
   577  			req.PageToken = pageToken
   578  		}
   579  		if pageSize > math.MaxInt32 {
   580  			req.PageSize = math.MaxInt32
   581  		} else if pageSize != 0 {
   582  			req.PageSize = int32(pageSize)
   583  		}
   584  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   585  			var err error
   586  			resp, err = executeRPC(ctx, c.memoryBankClient.ListMemories, req, settings.GRPC, c.logger, "ListMemories")
   587  			return err
   588  		}, opts...)
   589  		if err != nil {
   590  			return nil, "", err
   591  		}
   592  
   593  		it.Response = resp
   594  		return resp.GetMemories(), resp.GetNextPageToken(), nil
   595  	}
   596  	fetch := func(pageSize int, pageToken string) (string, error) {
   597  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   598  		if err != nil {
   599  			return "", err
   600  		}
   601  		it.items = append(it.items, items...)
   602  		return nextPageToken, nil
   603  	}
   604  
   605  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   606  	it.pageInfo.MaxSize = int(req.GetPageSize())
   607  	it.pageInfo.Token = req.GetPageToken()
   608  
   609  	return it
   610  }
   611  
   612  func (c *memoryBankGRPCClient) DeleteMemory(ctx context.Context, req *aiplatformpb.DeleteMemoryRequest, opts ...gax.CallOption) (*DeleteMemoryOperation, error) {
   613  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   614  
   615  	hds = append(c.xGoogHeaders, hds...)
   616  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   617  	opts = append((*c.CallOptions).DeleteMemory[0:len((*c.CallOptions).DeleteMemory):len((*c.CallOptions).DeleteMemory)], opts...)
   618  	var resp *longrunningpb.Operation
   619  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   620  		var err error
   621  		resp, err = executeRPC(ctx, c.memoryBankClient.DeleteMemory, req, settings.GRPC, c.logger, "DeleteMemory")
   622  		return err
   623  	}, opts...)
   624  	if err != nil {
   625  		return nil, err
   626  	}
   627  	return &DeleteMemoryOperation{
   628  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   629  	}, nil
   630  }
   631  
   632  func (c *memoryBankGRPCClient) GenerateMemories(ctx context.Context, req *aiplatformpb.GenerateMemoriesRequest, opts ...gax.CallOption) (*GenerateMemoriesOperation, error) {
   633  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   634  
   635  	hds = append(c.xGoogHeaders, hds...)
   636  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   637  	opts = append((*c.CallOptions).GenerateMemories[0:len((*c.CallOptions).GenerateMemories):len((*c.CallOptions).GenerateMemories)], opts...)
   638  	var resp *longrunningpb.Operation
   639  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   640  		var err error
   641  		resp, err = executeRPC(ctx, c.memoryBankClient.GenerateMemories, req, settings.GRPC, c.logger, "GenerateMemories")
   642  		return err
   643  	}, opts...)
   644  	if err != nil {
   645  		return nil, err
   646  	}
   647  	return &GenerateMemoriesOperation{
   648  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   649  	}, nil
   650  }
   651  
   652  func (c *memoryBankGRPCClient) RetrieveMemories(ctx context.Context, req *aiplatformpb.RetrieveMemoriesRequest, opts ...gax.CallOption) (*aiplatformpb.RetrieveMemoriesResponse, error) {
   653  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   654  
   655  	hds = append(c.xGoogHeaders, hds...)
   656  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   657  	opts = append((*c.CallOptions).RetrieveMemories[0:len((*c.CallOptions).RetrieveMemories):len((*c.CallOptions).RetrieveMemories)], opts...)
   658  	var resp *aiplatformpb.RetrieveMemoriesResponse
   659  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   660  		var err error
   661  		resp, err = executeRPC(ctx, c.memoryBankClient.RetrieveMemories, req, settings.GRPC, c.logger, "RetrieveMemories")
   662  		return err
   663  	}, opts...)
   664  	if err != nil {
   665  		return nil, err
   666  	}
   667  	return resp, nil
   668  }
   669  
   670  func (c *memoryBankGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   671  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   672  
   673  	hds = append(c.xGoogHeaders, hds...)
   674  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   675  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
   676  	var resp *locationpb.Location
   677  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   678  		var err error
   679  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
   680  		return err
   681  	}, opts...)
   682  	if err != nil {
   683  		return nil, err
   684  	}
   685  	return resp, nil
   686  }
   687  
   688  func (c *memoryBankGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   689  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   690  
   691  	hds = append(c.xGoogHeaders, hds...)
   692  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   693  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
   694  	it := &LocationIterator{}
   695  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
   696  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
   697  		resp := &locationpb.ListLocationsResponse{}
   698  		if pageToken != "" {
   699  			req.PageToken = pageToken
   700  		}
   701  		if pageSize > math.MaxInt32 {
   702  			req.PageSize = math.MaxInt32
   703  		} else if pageSize != 0 {
   704  			req.PageSize = int32(pageSize)
   705  		}
   706  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   707  			var err error
   708  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
   709  			return err
   710  		}, opts...)
   711  		if err != nil {
   712  			return nil, "", err
   713  		}
   714  
   715  		it.Response = resp
   716  		return resp.GetLocations(), resp.GetNextPageToken(), nil
   717  	}
   718  	fetch := func(pageSize int, pageToken string) (string, error) {
   719  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   720  		if err != nil {
   721  			return "", err
   722  		}
   723  		it.items = append(it.items, items...)
   724  		return nextPageToken, nil
   725  	}
   726  
   727  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   728  	it.pageInfo.MaxSize = int(req.GetPageSize())
   729  	it.pageInfo.Token = req.GetPageToken()
   730  
   731  	return it
   732  }
   733  
   734  func (c *memoryBankGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   735  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   736  
   737  	hds = append(c.xGoogHeaders, hds...)
   738  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   739  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
   740  	var resp *iampb.Policy
   741  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   742  		var err error
   743  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
   744  		return err
   745  	}, opts...)
   746  	if err != nil {
   747  		return nil, err
   748  	}
   749  	return resp, nil
   750  }
   751  
   752  func (c *memoryBankGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   753  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   754  
   755  	hds = append(c.xGoogHeaders, hds...)
   756  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   757  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
   758  	var resp *iampb.Policy
   759  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   760  		var err error
   761  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
   762  		return err
   763  	}, opts...)
   764  	if err != nil {
   765  		return nil, err
   766  	}
   767  	return resp, nil
   768  }
   769  
   770  func (c *memoryBankGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   771  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   772  
   773  	hds = append(c.xGoogHeaders, hds...)
   774  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   775  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
   776  	var resp *iampb.TestIamPermissionsResponse
   777  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   778  		var err error
   779  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
   780  		return err
   781  	}, opts...)
   782  	if err != nil {
   783  		return nil, err
   784  	}
   785  	return resp, nil
   786  }
   787  
   788  func (c *memoryBankGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   789  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   790  
   791  	hds = append(c.xGoogHeaders, hds...)
   792  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   793  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
   794  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   795  		var err error
   796  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
   797  		return err
   798  	}, opts...)
   799  	return err
   800  }
   801  
   802  func (c *memoryBankGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   803  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   804  
   805  	hds = append(c.xGoogHeaders, hds...)
   806  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   807  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
   808  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   809  		var err error
   810  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
   811  		return err
   812  	}, opts...)
   813  	return err
   814  }
   815  
   816  func (c *memoryBankGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   817  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   818  
   819  	hds = append(c.xGoogHeaders, hds...)
   820  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   821  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
   822  	var resp *longrunningpb.Operation
   823  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   824  		var err error
   825  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
   826  		return err
   827  	}, opts...)
   828  	if err != nil {
   829  		return nil, err
   830  	}
   831  	return resp, nil
   832  }
   833  
   834  func (c *memoryBankGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   835  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   836  
   837  	hds = append(c.xGoogHeaders, hds...)
   838  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   839  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
   840  	it := &OperationIterator{}
   841  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
   842  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
   843  		resp := &longrunningpb.ListOperationsResponse{}
   844  		if pageToken != "" {
   845  			req.PageToken = pageToken
   846  		}
   847  		if pageSize > math.MaxInt32 {
   848  			req.PageSize = math.MaxInt32
   849  		} else if pageSize != 0 {
   850  			req.PageSize = int32(pageSize)
   851  		}
   852  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   853  			var err error
   854  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
   855  			return err
   856  		}, opts...)
   857  		if err != nil {
   858  			return nil, "", err
   859  		}
   860  
   861  		it.Response = resp
   862  		return resp.GetOperations(), resp.GetNextPageToken(), nil
   863  	}
   864  	fetch := func(pageSize int, pageToken string) (string, error) {
   865  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   866  		if err != nil {
   867  			return "", err
   868  		}
   869  		it.items = append(it.items, items...)
   870  		return nextPageToken, nil
   871  	}
   872  
   873  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   874  	it.pageInfo.MaxSize = int(req.GetPageSize())
   875  	it.pageInfo.Token = req.GetPageToken()
   876  
   877  	return it
   878  }
   879  
   880  func (c *memoryBankGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   881  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   882  
   883  	hds = append(c.xGoogHeaders, hds...)
   884  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   885  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
   886  	var resp *longrunningpb.Operation
   887  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   888  		var err error
   889  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
   890  		return err
   891  	}, opts...)
   892  	if err != nil {
   893  		return nil, err
   894  	}
   895  	return resp, nil
   896  }
   897  
   898  // CreateMemory create a Memory.
   899  func (c *memoryBankRESTClient) CreateMemory(ctx context.Context, req *aiplatformpb.CreateMemoryRequest, opts ...gax.CallOption) (*CreateMemoryOperation, error) {
   900  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
   901  	body := req.GetMemory()
   902  	jsonReq, err := m.Marshal(body)
   903  	if err != nil {
   904  		return nil, err
   905  	}
   906  
   907  	baseUrl, err := url.Parse(c.endpoint)
   908  	if err != nil {
   909  		return nil, err
   910  	}
   911  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/memories", req.GetParent())
   912  
   913  	params := url.Values{}
   914  	params.Add("$alt", "json;enum-encoding=int")
   915  
   916  	baseUrl.RawQuery = params.Encode()
   917  
   918  	// Build HTTP headers from client and context metadata.
   919  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   920  
   921  	hds = append(c.xGoogHeaders, hds...)
   922  	hds = append(hds, "Content-Type", "application/json")
   923  	headers := gax.BuildHeaders(ctx, hds...)
   924  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   925  	resp := &longrunningpb.Operation{}
   926  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   927  		if settings.Path != "" {
   928  			baseUrl.Path = settings.Path
   929  		}
   930  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
   931  		if err != nil {
   932  			return err
   933  		}
   934  		httpReq = httpReq.WithContext(ctx)
   935  		httpReq.Header = headers
   936  
   937  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateMemory")
   938  		if err != nil {
   939  			return err
   940  		}
   941  		if err := unm.Unmarshal(buf, resp); err != nil {
   942  			return err
   943  		}
   944  
   945  		return nil
   946  	}, opts...)
   947  	if e != nil {
   948  		return nil, e
   949  	}
   950  
   951  	override := fmt.Sprintf("/ui/%s", resp.GetName())
   952  	return &CreateMemoryOperation{
   953  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
   954  		pollPath: override,
   955  	}, nil
   956  }
   957  
   958  // GetMemory get a Memory.
   959  func (c *memoryBankRESTClient) GetMemory(ctx context.Context, req *aiplatformpb.GetMemoryRequest, opts ...gax.CallOption) (*aiplatformpb.Memory, error) {
   960  	baseUrl, err := url.Parse(c.endpoint)
   961  	if err != nil {
   962  		return nil, err
   963  	}
   964  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
   965  
   966  	params := url.Values{}
   967  	params.Add("$alt", "json;enum-encoding=int")
   968  
   969  	baseUrl.RawQuery = params.Encode()
   970  
   971  	// Build HTTP headers from client and context metadata.
   972  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   973  
   974  	hds = append(c.xGoogHeaders, hds...)
   975  	hds = append(hds, "Content-Type", "application/json")
   976  	headers := gax.BuildHeaders(ctx, hds...)
   977  	opts = append((*c.CallOptions).GetMemory[0:len((*c.CallOptions).GetMemory):len((*c.CallOptions).GetMemory)], opts...)
   978  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   979  	resp := &aiplatformpb.Memory{}
   980  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   981  		if settings.Path != "" {
   982  			baseUrl.Path = settings.Path
   983  		}
   984  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
   985  		if err != nil {
   986  			return err
   987  		}
   988  		httpReq = httpReq.WithContext(ctx)
   989  		httpReq.Header = headers
   990  
   991  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetMemory")
   992  		if err != nil {
   993  			return err
   994  		}
   995  
   996  		if err := unm.Unmarshal(buf, resp); err != nil {
   997  			return err
   998  		}
   999  
  1000  		return nil
  1001  	}, opts...)
  1002  	if e != nil {
  1003  		return nil, e
  1004  	}
  1005  	return resp, nil
  1006  }
  1007  
  1008  // UpdateMemory update a Memory.
  1009  func (c *memoryBankRESTClient) UpdateMemory(ctx context.Context, req *aiplatformpb.UpdateMemoryRequest, opts ...gax.CallOption) (*UpdateMemoryOperation, error) {
  1010  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1011  	body := req.GetMemory()
  1012  	jsonReq, err := m.Marshal(body)
  1013  	if err != nil {
  1014  		return nil, err
  1015  	}
  1016  
  1017  	baseUrl, err := url.Parse(c.endpoint)
  1018  	if err != nil {
  1019  		return nil, err
  1020  	}
  1021  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetMemory().GetName())
  1022  
  1023  	params := url.Values{}
  1024  	params.Add("$alt", "json;enum-encoding=int")
  1025  	if req.GetUpdateMask() != nil {
  1026  		field, err := protojson.Marshal(req.GetUpdateMask())
  1027  		if err != nil {
  1028  			return nil, err
  1029  		}
  1030  		params.Add("updateMask", string(field[1:len(field)-1]))
  1031  	}
  1032  
  1033  	baseUrl.RawQuery = params.Encode()
  1034  
  1035  	// Build HTTP headers from client and context metadata.
  1036  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "memory.name", url.QueryEscape(req.GetMemory().GetName()))}
  1037  
  1038  	hds = append(c.xGoogHeaders, hds...)
  1039  	hds = append(hds, "Content-Type", "application/json")
  1040  	headers := gax.BuildHeaders(ctx, hds...)
  1041  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1042  	resp := &longrunningpb.Operation{}
  1043  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1044  		if settings.Path != "" {
  1045  			baseUrl.Path = settings.Path
  1046  		}
  1047  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  1048  		if err != nil {
  1049  			return err
  1050  		}
  1051  		httpReq = httpReq.WithContext(ctx)
  1052  		httpReq.Header = headers
  1053  
  1054  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateMemory")
  1055  		if err != nil {
  1056  			return err
  1057  		}
  1058  		if err := unm.Unmarshal(buf, resp); err != nil {
  1059  			return err
  1060  		}
  1061  
  1062  		return nil
  1063  	}, opts...)
  1064  	if e != nil {
  1065  		return nil, e
  1066  	}
  1067  
  1068  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1069  	return &UpdateMemoryOperation{
  1070  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1071  		pollPath: override,
  1072  	}, nil
  1073  }
  1074  
  1075  // ListMemories list Memories.
  1076  func (c *memoryBankRESTClient) ListMemories(ctx context.Context, req *aiplatformpb.ListMemoriesRequest, opts ...gax.CallOption) *MemoryIterator {
  1077  	it := &MemoryIterator{}
  1078  	req = proto.Clone(req).(*aiplatformpb.ListMemoriesRequest)
  1079  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1080  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.Memory, string, error) {
  1081  		resp := &aiplatformpb.ListMemoriesResponse{}
  1082  		if pageToken != "" {
  1083  			req.PageToken = pageToken
  1084  		}
  1085  		if pageSize > math.MaxInt32 {
  1086  			req.PageSize = math.MaxInt32
  1087  		} else if pageSize != 0 {
  1088  			req.PageSize = int32(pageSize)
  1089  		}
  1090  		baseUrl, err := url.Parse(c.endpoint)
  1091  		if err != nil {
  1092  			return nil, "", err
  1093  		}
  1094  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/memories", req.GetParent())
  1095  
  1096  		params := url.Values{}
  1097  		params.Add("$alt", "json;enum-encoding=int")
  1098  		if req.GetFilter() != "" {
  1099  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1100  		}
  1101  		if req.GetPageSize() != 0 {
  1102  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1103  		}
  1104  		if req.GetPageToken() != "" {
  1105  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1106  		}
  1107  
  1108  		baseUrl.RawQuery = params.Encode()
  1109  
  1110  		// Build HTTP headers from client and context metadata.
  1111  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1112  		headers := gax.BuildHeaders(ctx, hds...)
  1113  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1114  			if settings.Path != "" {
  1115  				baseUrl.Path = settings.Path
  1116  			}
  1117  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1118  			if err != nil {
  1119  				return err
  1120  			}
  1121  			httpReq.Header = headers
  1122  
  1123  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListMemories")
  1124  			if err != nil {
  1125  				return err
  1126  			}
  1127  			if err := unm.Unmarshal(buf, resp); err != nil {
  1128  				return err
  1129  			}
  1130  
  1131  			return nil
  1132  		}, opts...)
  1133  		if e != nil {
  1134  			return nil, "", e
  1135  		}
  1136  		it.Response = resp
  1137  		return resp.GetMemories(), resp.GetNextPageToken(), nil
  1138  	}
  1139  
  1140  	fetch := func(pageSize int, pageToken string) (string, error) {
  1141  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1142  		if err != nil {
  1143  			return "", err
  1144  		}
  1145  		it.items = append(it.items, items...)
  1146  		return nextPageToken, nil
  1147  	}
  1148  
  1149  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1150  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1151  	it.pageInfo.Token = req.GetPageToken()
  1152  
  1153  	return it
  1154  }
  1155  
  1156  // DeleteMemory delete a Memory.
  1157  func (c *memoryBankRESTClient) DeleteMemory(ctx context.Context, req *aiplatformpb.DeleteMemoryRequest, opts ...gax.CallOption) (*DeleteMemoryOperation, error) {
  1158  	baseUrl, err := url.Parse(c.endpoint)
  1159  	if err != nil {
  1160  		return nil, err
  1161  	}
  1162  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1163  
  1164  	params := url.Values{}
  1165  	params.Add("$alt", "json;enum-encoding=int")
  1166  
  1167  	baseUrl.RawQuery = params.Encode()
  1168  
  1169  	// Build HTTP headers from client and context metadata.
  1170  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1171  
  1172  	hds = append(c.xGoogHeaders, hds...)
  1173  	hds = append(hds, "Content-Type", "application/json")
  1174  	headers := gax.BuildHeaders(ctx, hds...)
  1175  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1176  	resp := &longrunningpb.Operation{}
  1177  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1178  		if settings.Path != "" {
  1179  			baseUrl.Path = settings.Path
  1180  		}
  1181  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1182  		if err != nil {
  1183  			return err
  1184  		}
  1185  		httpReq = httpReq.WithContext(ctx)
  1186  		httpReq.Header = headers
  1187  
  1188  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteMemory")
  1189  		if err != nil {
  1190  			return err
  1191  		}
  1192  		if err := unm.Unmarshal(buf, resp); err != nil {
  1193  			return err
  1194  		}
  1195  
  1196  		return nil
  1197  	}, opts...)
  1198  	if e != nil {
  1199  		return nil, e
  1200  	}
  1201  
  1202  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1203  	return &DeleteMemoryOperation{
  1204  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1205  		pollPath: override,
  1206  	}, nil
  1207  }
  1208  
  1209  // GenerateMemories generate memories.
  1210  func (c *memoryBankRESTClient) GenerateMemories(ctx context.Context, req *aiplatformpb.GenerateMemoriesRequest, opts ...gax.CallOption) (*GenerateMemoriesOperation, error) {
  1211  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1212  	jsonReq, err := m.Marshal(req)
  1213  	if err != nil {
  1214  		return nil, err
  1215  	}
  1216  
  1217  	baseUrl, err := url.Parse(c.endpoint)
  1218  	if err != nil {
  1219  		return nil, err
  1220  	}
  1221  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/memories:generate", req.GetParent())
  1222  
  1223  	params := url.Values{}
  1224  	params.Add("$alt", "json;enum-encoding=int")
  1225  
  1226  	baseUrl.RawQuery = params.Encode()
  1227  
  1228  	// Build HTTP headers from client and context metadata.
  1229  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1230  
  1231  	hds = append(c.xGoogHeaders, hds...)
  1232  	hds = append(hds, "Content-Type", "application/json")
  1233  	headers := gax.BuildHeaders(ctx, hds...)
  1234  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1235  	resp := &longrunningpb.Operation{}
  1236  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1237  		if settings.Path != "" {
  1238  			baseUrl.Path = settings.Path
  1239  		}
  1240  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1241  		if err != nil {
  1242  			return err
  1243  		}
  1244  		httpReq = httpReq.WithContext(ctx)
  1245  		httpReq.Header = headers
  1246  
  1247  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GenerateMemories")
  1248  		if err != nil {
  1249  			return err
  1250  		}
  1251  		if err := unm.Unmarshal(buf, resp); err != nil {
  1252  			return err
  1253  		}
  1254  
  1255  		return nil
  1256  	}, opts...)
  1257  	if e != nil {
  1258  		return nil, e
  1259  	}
  1260  
  1261  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1262  	return &GenerateMemoriesOperation{
  1263  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1264  		pollPath: override,
  1265  	}, nil
  1266  }
  1267  
  1268  // RetrieveMemories retrieve memories.
  1269  func (c *memoryBankRESTClient) RetrieveMemories(ctx context.Context, req *aiplatformpb.RetrieveMemoriesRequest, opts ...gax.CallOption) (*aiplatformpb.RetrieveMemoriesResponse, error) {
  1270  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1271  	jsonReq, err := m.Marshal(req)
  1272  	if err != nil {
  1273  		return nil, err
  1274  	}
  1275  
  1276  	baseUrl, err := url.Parse(c.endpoint)
  1277  	if err != nil {
  1278  		return nil, err
  1279  	}
  1280  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/memories:retrieve", req.GetParent())
  1281  
  1282  	params := url.Values{}
  1283  	params.Add("$alt", "json;enum-encoding=int")
  1284  
  1285  	baseUrl.RawQuery = params.Encode()
  1286  
  1287  	// Build HTTP headers from client and context metadata.
  1288  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1289  
  1290  	hds = append(c.xGoogHeaders, hds...)
  1291  	hds = append(hds, "Content-Type", "application/json")
  1292  	headers := gax.BuildHeaders(ctx, hds...)
  1293  	opts = append((*c.CallOptions).RetrieveMemories[0:len((*c.CallOptions).RetrieveMemories):len((*c.CallOptions).RetrieveMemories)], opts...)
  1294  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1295  	resp := &aiplatformpb.RetrieveMemoriesResponse{}
  1296  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1297  		if settings.Path != "" {
  1298  			baseUrl.Path = settings.Path
  1299  		}
  1300  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1301  		if err != nil {
  1302  			return err
  1303  		}
  1304  		httpReq = httpReq.WithContext(ctx)
  1305  		httpReq.Header = headers
  1306  
  1307  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RetrieveMemories")
  1308  		if err != nil {
  1309  			return err
  1310  		}
  1311  
  1312  		if err := unm.Unmarshal(buf, resp); err != nil {
  1313  			return err
  1314  		}
  1315  
  1316  		return nil
  1317  	}, opts...)
  1318  	if e != nil {
  1319  		return nil, e
  1320  	}
  1321  	return resp, nil
  1322  }
  1323  
  1324  // GetLocation gets information about a location.
  1325  func (c *memoryBankRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1326  	baseUrl, err := url.Parse(c.endpoint)
  1327  	if err != nil {
  1328  		return nil, err
  1329  	}
  1330  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  1331  
  1332  	params := url.Values{}
  1333  	params.Add("$alt", "json;enum-encoding=int")
  1334  
  1335  	baseUrl.RawQuery = params.Encode()
  1336  
  1337  	// Build HTTP headers from client and context metadata.
  1338  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1339  
  1340  	hds = append(c.xGoogHeaders, hds...)
  1341  	hds = append(hds, "Content-Type", "application/json")
  1342  	headers := gax.BuildHeaders(ctx, hds...)
  1343  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1344  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1345  	resp := &locationpb.Location{}
  1346  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1347  		if settings.Path != "" {
  1348  			baseUrl.Path = settings.Path
  1349  		}
  1350  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1351  		if err != nil {
  1352  			return err
  1353  		}
  1354  		httpReq = httpReq.WithContext(ctx)
  1355  		httpReq.Header = headers
  1356  
  1357  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
  1358  		if err != nil {
  1359  			return err
  1360  		}
  1361  
  1362  		if err := unm.Unmarshal(buf, resp); err != nil {
  1363  			return err
  1364  		}
  1365  
  1366  		return nil
  1367  	}, opts...)
  1368  	if e != nil {
  1369  		return nil, e
  1370  	}
  1371  	return resp, nil
  1372  }
  1373  
  1374  // ListLocations lists information about the supported locations for this service.
  1375  func (c *memoryBankRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1376  	it := &LocationIterator{}
  1377  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1378  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1379  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1380  		resp := &locationpb.ListLocationsResponse{}
  1381  		if pageToken != "" {
  1382  			req.PageToken = pageToken
  1383  		}
  1384  		if pageSize > math.MaxInt32 {
  1385  			req.PageSize = math.MaxInt32
  1386  		} else if pageSize != 0 {
  1387  			req.PageSize = int32(pageSize)
  1388  		}
  1389  		baseUrl, err := url.Parse(c.endpoint)
  1390  		if err != nil {
  1391  			return nil, "", err
  1392  		}
  1393  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  1394  
  1395  		params := url.Values{}
  1396  		params.Add("$alt", "json;enum-encoding=int")
  1397  		if req.GetFilter() != "" {
  1398  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1399  		}
  1400  		if req.GetPageSize() != 0 {
  1401  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1402  		}
  1403  		if req.GetPageToken() != "" {
  1404  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1405  		}
  1406  
  1407  		baseUrl.RawQuery = params.Encode()
  1408  
  1409  		// Build HTTP headers from client and context metadata.
  1410  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1411  		headers := gax.BuildHeaders(ctx, hds...)
  1412  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1413  			if settings.Path != "" {
  1414  				baseUrl.Path = settings.Path
  1415  			}
  1416  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1417  			if err != nil {
  1418  				return err
  1419  			}
  1420  			httpReq.Header = headers
  1421  
  1422  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  1423  			if err != nil {
  1424  				return err
  1425  			}
  1426  			if err := unm.Unmarshal(buf, resp); err != nil {
  1427  				return err
  1428  			}
  1429  
  1430  			return nil
  1431  		}, opts...)
  1432  		if e != nil {
  1433  			return nil, "", e
  1434  		}
  1435  		it.Response = resp
  1436  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1437  	}
  1438  
  1439  	fetch := func(pageSize int, pageToken string) (string, error) {
  1440  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1441  		if err != nil {
  1442  			return "", err
  1443  		}
  1444  		it.items = append(it.items, items...)
  1445  		return nextPageToken, nil
  1446  	}
  1447  
  1448  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1449  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1450  	it.pageInfo.Token = req.GetPageToken()
  1451  
  1452  	return it
  1453  }
  1454  
  1455  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  1456  // if the resource exists and does not have a policy set.
  1457  func (c *memoryBankRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1458  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1459  	jsonReq, err := m.Marshal(req)
  1460  	if err != nil {
  1461  		return nil, err
  1462  	}
  1463  
  1464  	baseUrl, err := url.Parse(c.endpoint)
  1465  	if err != nil {
  1466  		return nil, err
  1467  	}
  1468  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  1469  
  1470  	params := url.Values{}
  1471  	params.Add("$alt", "json;enum-encoding=int")
  1472  
  1473  	baseUrl.RawQuery = params.Encode()
  1474  
  1475  	// Build HTTP headers from client and context metadata.
  1476  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1477  
  1478  	hds = append(c.xGoogHeaders, hds...)
  1479  	hds = append(hds, "Content-Type", "application/json")
  1480  	headers := gax.BuildHeaders(ctx, hds...)
  1481  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1482  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1483  	resp := &iampb.Policy{}
  1484  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1485  		if settings.Path != "" {
  1486  			baseUrl.Path = settings.Path
  1487  		}
  1488  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1489  		if err != nil {
  1490  			return err
  1491  		}
  1492  		httpReq = httpReq.WithContext(ctx)
  1493  		httpReq.Header = headers
  1494  
  1495  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  1496  		if err != nil {
  1497  			return err
  1498  		}
  1499  
  1500  		if err := unm.Unmarshal(buf, resp); err != nil {
  1501  			return err
  1502  		}
  1503  
  1504  		return nil
  1505  	}, opts...)
  1506  	if e != nil {
  1507  		return nil, e
  1508  	}
  1509  	return resp, nil
  1510  }
  1511  
  1512  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  1513  // any existing policy.
  1514  //
  1515  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  1516  // errors.
  1517  func (c *memoryBankRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1518  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1519  	jsonReq, err := m.Marshal(req)
  1520  	if err != nil {
  1521  		return nil, err
  1522  	}
  1523  
  1524  	baseUrl, err := url.Parse(c.endpoint)
  1525  	if err != nil {
  1526  		return nil, err
  1527  	}
  1528  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  1529  
  1530  	params := url.Values{}
  1531  	params.Add("$alt", "json;enum-encoding=int")
  1532  
  1533  	baseUrl.RawQuery = params.Encode()
  1534  
  1535  	// Build HTTP headers from client and context metadata.
  1536  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1537  
  1538  	hds = append(c.xGoogHeaders, hds...)
  1539  	hds = append(hds, "Content-Type", "application/json")
  1540  	headers := gax.BuildHeaders(ctx, hds...)
  1541  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1542  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1543  	resp := &iampb.Policy{}
  1544  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1545  		if settings.Path != "" {
  1546  			baseUrl.Path = settings.Path
  1547  		}
  1548  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1549  		if err != nil {
  1550  			return err
  1551  		}
  1552  		httpReq = httpReq.WithContext(ctx)
  1553  		httpReq.Header = headers
  1554  
  1555  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  1556  		if err != nil {
  1557  			return err
  1558  		}
  1559  
  1560  		if err := unm.Unmarshal(buf, resp); err != nil {
  1561  			return err
  1562  		}
  1563  
  1564  		return nil
  1565  	}, opts...)
  1566  	if e != nil {
  1567  		return nil, e
  1568  	}
  1569  	return resp, nil
  1570  }
  1571  
  1572  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  1573  // resource does not exist, this will return an empty set of
  1574  // permissions, not a NOT_FOUND error.
  1575  //
  1576  // Note: This operation is designed to be used for building
  1577  // permission-aware UIs and command-line tools, not for authorization
  1578  // checking. This operation may “fail open” without warning.
  1579  func (c *memoryBankRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1580  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1581  	jsonReq, err := m.Marshal(req)
  1582  	if err != nil {
  1583  		return nil, err
  1584  	}
  1585  
  1586  	baseUrl, err := url.Parse(c.endpoint)
  1587  	if err != nil {
  1588  		return nil, err
  1589  	}
  1590  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  1591  
  1592  	params := url.Values{}
  1593  	params.Add("$alt", "json;enum-encoding=int")
  1594  
  1595  	baseUrl.RawQuery = params.Encode()
  1596  
  1597  	// Build HTTP headers from client and context metadata.
  1598  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1599  
  1600  	hds = append(c.xGoogHeaders, hds...)
  1601  	hds = append(hds, "Content-Type", "application/json")
  1602  	headers := gax.BuildHeaders(ctx, hds...)
  1603  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1604  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1605  	resp := &iampb.TestIamPermissionsResponse{}
  1606  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1607  		if settings.Path != "" {
  1608  			baseUrl.Path = settings.Path
  1609  		}
  1610  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1611  		if err != nil {
  1612  			return err
  1613  		}
  1614  		httpReq = httpReq.WithContext(ctx)
  1615  		httpReq.Header = headers
  1616  
  1617  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  1618  		if err != nil {
  1619  			return err
  1620  		}
  1621  
  1622  		if err := unm.Unmarshal(buf, resp); err != nil {
  1623  			return err
  1624  		}
  1625  
  1626  		return nil
  1627  	}, opts...)
  1628  	if e != nil {
  1629  		return nil, e
  1630  	}
  1631  	return resp, nil
  1632  }
  1633  
  1634  // CancelOperation is a utility method from google.longrunning.Operations.
  1635  func (c *memoryBankRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1636  	baseUrl, err := url.Parse(c.endpoint)
  1637  	if err != nil {
  1638  		return err
  1639  	}
  1640  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  1641  
  1642  	params := url.Values{}
  1643  	params.Add("$alt", "json;enum-encoding=int")
  1644  
  1645  	baseUrl.RawQuery = params.Encode()
  1646  
  1647  	// Build HTTP headers from client and context metadata.
  1648  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1649  
  1650  	hds = append(c.xGoogHeaders, hds...)
  1651  	hds = append(hds, "Content-Type", "application/json")
  1652  	headers := gax.BuildHeaders(ctx, hds...)
  1653  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1654  		if settings.Path != "" {
  1655  			baseUrl.Path = settings.Path
  1656  		}
  1657  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  1658  		if err != nil {
  1659  			return err
  1660  		}
  1661  		httpReq = httpReq.WithContext(ctx)
  1662  		httpReq.Header = headers
  1663  
  1664  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  1665  		return err
  1666  	}, opts...)
  1667  }
  1668  
  1669  // DeleteOperation is a utility method from google.longrunning.Operations.
  1670  func (c *memoryBankRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1671  	baseUrl, err := url.Parse(c.endpoint)
  1672  	if err != nil {
  1673  		return err
  1674  	}
  1675  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  1676  
  1677  	params := url.Values{}
  1678  	params.Add("$alt", "json;enum-encoding=int")
  1679  
  1680  	baseUrl.RawQuery = params.Encode()
  1681  
  1682  	// Build HTTP headers from client and context metadata.
  1683  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1684  
  1685  	hds = append(c.xGoogHeaders, hds...)
  1686  	hds = append(hds, "Content-Type", "application/json")
  1687  	headers := gax.BuildHeaders(ctx, hds...)
  1688  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1689  		if settings.Path != "" {
  1690  			baseUrl.Path = settings.Path
  1691  		}
  1692  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1693  		if err != nil {
  1694  			return err
  1695  		}
  1696  		httpReq = httpReq.WithContext(ctx)
  1697  		httpReq.Header = headers
  1698  
  1699  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  1700  		return err
  1701  	}, opts...)
  1702  }
  1703  
  1704  // GetOperation is a utility method from google.longrunning.Operations.
  1705  func (c *memoryBankRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1706  	baseUrl, err := url.Parse(c.endpoint)
  1707  	if err != nil {
  1708  		return nil, err
  1709  	}
  1710  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  1711  
  1712  	params := url.Values{}
  1713  	params.Add("$alt", "json;enum-encoding=int")
  1714  
  1715  	baseUrl.RawQuery = params.Encode()
  1716  
  1717  	// Build HTTP headers from client and context metadata.
  1718  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1719  
  1720  	hds = append(c.xGoogHeaders, hds...)
  1721  	hds = append(hds, "Content-Type", "application/json")
  1722  	headers := gax.BuildHeaders(ctx, hds...)
  1723  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1724  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1725  	resp := &longrunningpb.Operation{}
  1726  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1727  		if settings.Path != "" {
  1728  			baseUrl.Path = settings.Path
  1729  		}
  1730  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1731  		if err != nil {
  1732  			return err
  1733  		}
  1734  		httpReq = httpReq.WithContext(ctx)
  1735  		httpReq.Header = headers
  1736  
  1737  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  1738  		if err != nil {
  1739  			return err
  1740  		}
  1741  
  1742  		if err := unm.Unmarshal(buf, resp); err != nil {
  1743  			return err
  1744  		}
  1745  
  1746  		return nil
  1747  	}, opts...)
  1748  	if e != nil {
  1749  		return nil, e
  1750  	}
  1751  	return resp, nil
  1752  }
  1753  
  1754  // ListOperations is a utility method from google.longrunning.Operations.
  1755  func (c *memoryBankRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1756  	it := &OperationIterator{}
  1757  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1758  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1759  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1760  		resp := &longrunningpb.ListOperationsResponse{}
  1761  		if pageToken != "" {
  1762  			req.PageToken = pageToken
  1763  		}
  1764  		if pageSize > math.MaxInt32 {
  1765  			req.PageSize = math.MaxInt32
  1766  		} else if pageSize != 0 {
  1767  			req.PageSize = int32(pageSize)
  1768  		}
  1769  		baseUrl, err := url.Parse(c.endpoint)
  1770  		if err != nil {
  1771  			return nil, "", err
  1772  		}
  1773  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  1774  
  1775  		params := url.Values{}
  1776  		params.Add("$alt", "json;enum-encoding=int")
  1777  		if req.GetFilter() != "" {
  1778  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1779  		}
  1780  		if req.GetPageSize() != 0 {
  1781  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1782  		}
  1783  		if req.GetPageToken() != "" {
  1784  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1785  		}
  1786  
  1787  		baseUrl.RawQuery = params.Encode()
  1788  
  1789  		// Build HTTP headers from client and context metadata.
  1790  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1791  		headers := gax.BuildHeaders(ctx, hds...)
  1792  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1793  			if settings.Path != "" {
  1794  				baseUrl.Path = settings.Path
  1795  			}
  1796  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1797  			if err != nil {
  1798  				return err
  1799  			}
  1800  			httpReq.Header = headers
  1801  
  1802  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  1803  			if err != nil {
  1804  				return err
  1805  			}
  1806  			if err := unm.Unmarshal(buf, resp); err != nil {
  1807  				return err
  1808  			}
  1809  
  1810  			return nil
  1811  		}, opts...)
  1812  		if e != nil {
  1813  			return nil, "", e
  1814  		}
  1815  		it.Response = resp
  1816  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1817  	}
  1818  
  1819  	fetch := func(pageSize int, pageToken string) (string, error) {
  1820  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1821  		if err != nil {
  1822  			return "", err
  1823  		}
  1824  		it.items = append(it.items, items...)
  1825  		return nextPageToken, nil
  1826  	}
  1827  
  1828  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1829  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1830  	it.pageInfo.Token = req.GetPageToken()
  1831  
  1832  	return it
  1833  }
  1834  
  1835  // WaitOperation is a utility method from google.longrunning.Operations.
  1836  func (c *memoryBankRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1837  	baseUrl, err := url.Parse(c.endpoint)
  1838  	if err != nil {
  1839  		return nil, err
  1840  	}
  1841  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  1842  
  1843  	params := url.Values{}
  1844  	params.Add("$alt", "json;enum-encoding=int")
  1845  	if req.GetTimeout() != nil {
  1846  		field, err := protojson.Marshal(req.GetTimeout())
  1847  		if err != nil {
  1848  			return nil, err
  1849  		}
  1850  		params.Add("timeout", string(field[1:len(field)-1]))
  1851  	}
  1852  
  1853  	baseUrl.RawQuery = params.Encode()
  1854  
  1855  	// Build HTTP headers from client and context metadata.
  1856  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1857  
  1858  	hds = append(c.xGoogHeaders, hds...)
  1859  	hds = append(hds, "Content-Type", "application/json")
  1860  	headers := gax.BuildHeaders(ctx, hds...)
  1861  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1862  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1863  	resp := &longrunningpb.Operation{}
  1864  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1865  		if settings.Path != "" {
  1866  			baseUrl.Path = settings.Path
  1867  		}
  1868  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  1869  		if err != nil {
  1870  			return err
  1871  		}
  1872  		httpReq = httpReq.WithContext(ctx)
  1873  		httpReq.Header = headers
  1874  
  1875  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  1876  		if err != nil {
  1877  			return err
  1878  		}
  1879  
  1880  		if err := unm.Unmarshal(buf, resp); err != nil {
  1881  			return err
  1882  		}
  1883  
  1884  		return nil
  1885  	}, opts...)
  1886  	if e != nil {
  1887  		return nil, e
  1888  	}
  1889  	return resp, nil
  1890  }
  1891  
  1892  // CreateMemoryOperation returns a new CreateMemoryOperation from a given name.
  1893  // The name must be that of a previously created CreateMemoryOperation, possibly from a different process.
  1894  func (c *memoryBankGRPCClient) CreateMemoryOperation(name string) *CreateMemoryOperation {
  1895  	return &CreateMemoryOperation{
  1896  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1897  	}
  1898  }
  1899  
  1900  // CreateMemoryOperation returns a new CreateMemoryOperation from a given name.
  1901  // The name must be that of a previously created CreateMemoryOperation, possibly from a different process.
  1902  func (c *memoryBankRESTClient) CreateMemoryOperation(name string) *CreateMemoryOperation {
  1903  	override := fmt.Sprintf("/ui/%s", name)
  1904  	return &CreateMemoryOperation{
  1905  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1906  		pollPath: override,
  1907  	}
  1908  }
  1909  
  1910  // DeleteMemoryOperation returns a new DeleteMemoryOperation from a given name.
  1911  // The name must be that of a previously created DeleteMemoryOperation, possibly from a different process.
  1912  func (c *memoryBankGRPCClient) DeleteMemoryOperation(name string) *DeleteMemoryOperation {
  1913  	return &DeleteMemoryOperation{
  1914  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1915  	}
  1916  }
  1917  
  1918  // DeleteMemoryOperation returns a new DeleteMemoryOperation from a given name.
  1919  // The name must be that of a previously created DeleteMemoryOperation, possibly from a different process.
  1920  func (c *memoryBankRESTClient) DeleteMemoryOperation(name string) *DeleteMemoryOperation {
  1921  	override := fmt.Sprintf("/ui/%s", name)
  1922  	return &DeleteMemoryOperation{
  1923  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1924  		pollPath: override,
  1925  	}
  1926  }
  1927  
  1928  // GenerateMemoriesOperation returns a new GenerateMemoriesOperation from a given name.
  1929  // The name must be that of a previously created GenerateMemoriesOperation, possibly from a different process.
  1930  func (c *memoryBankGRPCClient) GenerateMemoriesOperation(name string) *GenerateMemoriesOperation {
  1931  	return &GenerateMemoriesOperation{
  1932  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1933  	}
  1934  }
  1935  
  1936  // GenerateMemoriesOperation returns a new GenerateMemoriesOperation from a given name.
  1937  // The name must be that of a previously created GenerateMemoriesOperation, possibly from a different process.
  1938  func (c *memoryBankRESTClient) GenerateMemoriesOperation(name string) *GenerateMemoriesOperation {
  1939  	override := fmt.Sprintf("/ui/%s", name)
  1940  	return &GenerateMemoriesOperation{
  1941  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1942  		pollPath: override,
  1943  	}
  1944  }
  1945  
  1946  // UpdateMemoryOperation returns a new UpdateMemoryOperation from a given name.
  1947  // The name must be that of a previously created UpdateMemoryOperation, possibly from a different process.
  1948  func (c *memoryBankGRPCClient) UpdateMemoryOperation(name string) *UpdateMemoryOperation {
  1949  	return &UpdateMemoryOperation{
  1950  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1951  	}
  1952  }
  1953  
  1954  // UpdateMemoryOperation returns a new UpdateMemoryOperation from a given name.
  1955  // The name must be that of a previously created UpdateMemoryOperation, possibly from a different process.
  1956  func (c *memoryBankRESTClient) UpdateMemoryOperation(name string) *UpdateMemoryOperation {
  1957  	override := fmt.Sprintf("/ui/%s", name)
  1958  	return &UpdateMemoryOperation{
  1959  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  1960  		pollPath: override,
  1961  	}
  1962  }