cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/feature_online_store_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  	"errors"
    23  	"fmt"
    24  	"log/slog"
    25  	"math"
    26  	"net/http"
    27  	"net/url"
    28  
    29  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb"
    30  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    31  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    32  	gax "github.com/googleapis/gax-go/v2"
    33  	"google.golang.org/api/iterator"
    34  	"google.golang.org/api/option"
    35  	"google.golang.org/api/option/internaloption"
    36  	gtransport "google.golang.org/api/transport/grpc"
    37  	httptransport "google.golang.org/api/transport/http"
    38  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    39  	"google.golang.org/grpc"
    40  	"google.golang.org/protobuf/encoding/protojson"
    41  	"google.golang.org/protobuf/proto"
    42  )
    43  
    44  var newFeatureOnlineStoreClientHook clientHook
    45  
    46  // FeatureOnlineStoreCallOptions contains the retry settings for each method of FeatureOnlineStoreClient.
    47  type FeatureOnlineStoreCallOptions struct {
    48  	FetchFeatureValues          []gax.CallOption
    49  	StreamingFetchFeatureValues []gax.CallOption
    50  	SearchNearestEntities       []gax.CallOption
    51  	FeatureViewDirectWrite      []gax.CallOption
    52  	GenerateFetchAccessToken    []gax.CallOption
    53  	GetLocation                 []gax.CallOption
    54  	ListLocations               []gax.CallOption
    55  	GetIamPolicy                []gax.CallOption
    56  	SetIamPolicy                []gax.CallOption
    57  	TestIamPermissions          []gax.CallOption
    58  	CancelOperation             []gax.CallOption
    59  	DeleteOperation             []gax.CallOption
    60  	GetOperation                []gax.CallOption
    61  	ListOperations              []gax.CallOption
    62  	WaitOperation               []gax.CallOption
    63  }
    64  
    65  func defaultFeatureOnlineStoreGRPCClientOptions() []option.ClientOption {
    66  	return []option.ClientOption{
    67  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    68  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    69  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    70  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    71  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    72  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    73  		internaloption.EnableJwtWithScope(),
    74  		internaloption.EnableNewAuthLibrary(),
    75  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    76  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    77  	}
    78  }
    79  
    80  func defaultFeatureOnlineStoreCallOptions() *FeatureOnlineStoreCallOptions {
    81  	return &FeatureOnlineStoreCallOptions{
    82  		FetchFeatureValues:          []gax.CallOption{},
    83  		StreamingFetchFeatureValues: []gax.CallOption{},
    84  		SearchNearestEntities:       []gax.CallOption{},
    85  		FeatureViewDirectWrite:      []gax.CallOption{},
    86  		GenerateFetchAccessToken:    []gax.CallOption{},
    87  		GetLocation:                 []gax.CallOption{},
    88  		ListLocations:               []gax.CallOption{},
    89  		GetIamPolicy:                []gax.CallOption{},
    90  		SetIamPolicy:                []gax.CallOption{},
    91  		TestIamPermissions:          []gax.CallOption{},
    92  		CancelOperation:             []gax.CallOption{},
    93  		DeleteOperation:             []gax.CallOption{},
    94  		GetOperation:                []gax.CallOption{},
    95  		ListOperations:              []gax.CallOption{},
    96  		WaitOperation:               []gax.CallOption{},
    97  	}
    98  }
    99  
   100  func defaultFeatureOnlineStoreRESTCallOptions() *FeatureOnlineStoreCallOptions {
   101  	return &FeatureOnlineStoreCallOptions{
   102  		FetchFeatureValues:          []gax.CallOption{},
   103  		StreamingFetchFeatureValues: []gax.CallOption{},
   104  		SearchNearestEntities:       []gax.CallOption{},
   105  		FeatureViewDirectWrite:      []gax.CallOption{},
   106  		GenerateFetchAccessToken:    []gax.CallOption{},
   107  		GetLocation:                 []gax.CallOption{},
   108  		ListLocations:               []gax.CallOption{},
   109  		GetIamPolicy:                []gax.CallOption{},
   110  		SetIamPolicy:                []gax.CallOption{},
   111  		TestIamPermissions:          []gax.CallOption{},
   112  		CancelOperation:             []gax.CallOption{},
   113  		DeleteOperation:             []gax.CallOption{},
   114  		GetOperation:                []gax.CallOption{},
   115  		ListOperations:              []gax.CallOption{},
   116  		WaitOperation:               []gax.CallOption{},
   117  	}
   118  }
   119  
   120  // internalFeatureOnlineStoreClient is an interface that defines the methods available from Vertex AI API.
   121  type internalFeatureOnlineStoreClient interface {
   122  	Close() error
   123  	setGoogleClientInfo(...string)
   124  	Connection() *grpc.ClientConn
   125  	FetchFeatureValues(context.Context, *aiplatformpb.FetchFeatureValuesRequest, ...gax.CallOption) (*aiplatformpb.FetchFeatureValuesResponse, error)
   126  	StreamingFetchFeatureValues(context.Context, ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_StreamingFetchFeatureValuesClient, error)
   127  	SearchNearestEntities(context.Context, *aiplatformpb.SearchNearestEntitiesRequest, ...gax.CallOption) (*aiplatformpb.SearchNearestEntitiesResponse, error)
   128  	FeatureViewDirectWrite(context.Context, ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_FeatureViewDirectWriteClient, error)
   129  	GenerateFetchAccessToken(context.Context, *aiplatformpb.GenerateFetchAccessTokenRequest, ...gax.CallOption) (*aiplatformpb.GenerateFetchAccessTokenResponse, error)
   130  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   131  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   132  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   133  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   134  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   135  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   136  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   137  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   138  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   139  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   140  }
   141  
   142  // FeatureOnlineStoreClient is a client for interacting with Vertex AI API.
   143  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   144  //
   145  // A service for fetching feature values from the online store.
   146  type FeatureOnlineStoreClient struct {
   147  	// The internal transport-dependent client.
   148  	internalClient internalFeatureOnlineStoreClient
   149  
   150  	// The call options for this service.
   151  	CallOptions *FeatureOnlineStoreCallOptions
   152  }
   153  
   154  // Wrapper methods routed to the internal client.
   155  
   156  // Close closes the connection to the API service. The user should invoke this when
   157  // the client is no longer required.
   158  func (c *FeatureOnlineStoreClient) Close() error {
   159  	return c.internalClient.Close()
   160  }
   161  
   162  // setGoogleClientInfo sets the name and version of the application in
   163  // the `x-goog-api-client` header passed on each request. Intended for
   164  // use by Google-written clients.
   165  func (c *FeatureOnlineStoreClient) setGoogleClientInfo(keyval ...string) {
   166  	c.internalClient.setGoogleClientInfo(keyval...)
   167  }
   168  
   169  // Connection returns a connection to the API service.
   170  //
   171  // Deprecated: Connections are now pooled so this method does not always
   172  // return the same resource.
   173  func (c *FeatureOnlineStoreClient) Connection() *grpc.ClientConn {
   174  	return c.internalClient.Connection()
   175  }
   176  
   177  // FetchFeatureValues fetch feature values under a FeatureView.
   178  func (c *FeatureOnlineStoreClient) FetchFeatureValues(ctx context.Context, req *aiplatformpb.FetchFeatureValuesRequest, opts ...gax.CallOption) (*aiplatformpb.FetchFeatureValuesResponse, error) {
   179  	return c.internalClient.FetchFeatureValues(ctx, req, opts...)
   180  }
   181  
   182  // StreamingFetchFeatureValues bidirectional streaming RPC to fetch feature values under a FeatureView.
   183  // Requests may not have a one-to-one mapping to responses and responses may
   184  // be returned out-of-order to reduce latency.
   185  //
   186  // This method is not supported for the REST transport.
   187  func (c *FeatureOnlineStoreClient) StreamingFetchFeatureValues(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_StreamingFetchFeatureValuesClient, error) {
   188  	return c.internalClient.StreamingFetchFeatureValues(ctx, opts...)
   189  }
   190  
   191  // SearchNearestEntities search the nearest entities under a FeatureView.
   192  // Search only works for indexable feature view; if a feature view isn’t
   193  // indexable, returns Invalid argument response.
   194  func (c *FeatureOnlineStoreClient) SearchNearestEntities(ctx context.Context, req *aiplatformpb.SearchNearestEntitiesRequest, opts ...gax.CallOption) (*aiplatformpb.SearchNearestEntitiesResponse, error) {
   195  	return c.internalClient.SearchNearestEntities(ctx, req, opts...)
   196  }
   197  
   198  // FeatureViewDirectWrite bidirectional streaming RPC to directly write to feature values in a
   199  // feature view. Requests may not have a one-to-one mapping to responses and
   200  // responses may be returned out-of-order to reduce latency.
   201  //
   202  // This method is not supported for the REST transport.
   203  func (c *FeatureOnlineStoreClient) FeatureViewDirectWrite(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_FeatureViewDirectWriteClient, error) {
   204  	return c.internalClient.FeatureViewDirectWrite(ctx, opts...)
   205  }
   206  
   207  // GenerateFetchAccessToken rPC to generate an access token for the given feature view. FeatureViews
   208  // under the same FeatureOnlineStore share the same access token.
   209  func (c *FeatureOnlineStoreClient) GenerateFetchAccessToken(ctx context.Context, req *aiplatformpb.GenerateFetchAccessTokenRequest, opts ...gax.CallOption) (*aiplatformpb.GenerateFetchAccessTokenResponse, error) {
   210  	return c.internalClient.GenerateFetchAccessToken(ctx, req, opts...)
   211  }
   212  
   213  // GetLocation gets information about a location.
   214  func (c *FeatureOnlineStoreClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   215  	return c.internalClient.GetLocation(ctx, req, opts...)
   216  }
   217  
   218  // ListLocations lists information about the supported locations for this service.
   219  func (c *FeatureOnlineStoreClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   220  	return c.internalClient.ListLocations(ctx, req, opts...)
   221  }
   222  
   223  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   224  // if the resource exists and does not have a policy set.
   225  func (c *FeatureOnlineStoreClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   226  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   227  }
   228  
   229  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   230  // any existing policy.
   231  //
   232  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   233  // errors.
   234  func (c *FeatureOnlineStoreClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   235  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   236  }
   237  
   238  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   239  // resource does not exist, this will return an empty set of
   240  // permissions, not a NOT_FOUND error.
   241  //
   242  // Note: This operation is designed to be used for building
   243  // permission-aware UIs and command-line tools, not for authorization
   244  // checking. This operation may “fail open” without warning.
   245  func (c *FeatureOnlineStoreClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   246  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   247  }
   248  
   249  // CancelOperation is a utility method from google.longrunning.Operations.
   250  func (c *FeatureOnlineStoreClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   251  	return c.internalClient.CancelOperation(ctx, req, opts...)
   252  }
   253  
   254  // DeleteOperation is a utility method from google.longrunning.Operations.
   255  func (c *FeatureOnlineStoreClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   256  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   257  }
   258  
   259  // GetOperation is a utility method from google.longrunning.Operations.
   260  func (c *FeatureOnlineStoreClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   261  	return c.internalClient.GetOperation(ctx, req, opts...)
   262  }
   263  
   264  // ListOperations is a utility method from google.longrunning.Operations.
   265  func (c *FeatureOnlineStoreClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   266  	return c.internalClient.ListOperations(ctx, req, opts...)
   267  }
   268  
   269  // WaitOperation is a utility method from google.longrunning.Operations.
   270  func (c *FeatureOnlineStoreClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   271  	return c.internalClient.WaitOperation(ctx, req, opts...)
   272  }
   273  
   274  // featureOnlineStoreGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   275  //
   276  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   277  type featureOnlineStoreGRPCClient struct {
   278  	// Connection pool of gRPC connections to the service.
   279  	connPool gtransport.ConnPool
   280  
   281  	// Points back to the CallOptions field of the containing FeatureOnlineStoreClient
   282  	CallOptions **FeatureOnlineStoreCallOptions
   283  
   284  	// The gRPC API client.
   285  	featureOnlineStoreClient aiplatformpb.FeatureOnlineStoreServiceClient
   286  
   287  	operationsClient longrunningpb.OperationsClient
   288  
   289  	iamPolicyClient iampb.IAMPolicyClient
   290  
   291  	locationsClient locationpb.LocationsClient
   292  
   293  	// The x-goog-* metadata to be sent with each request.
   294  	xGoogHeaders []string
   295  
   296  	logger *slog.Logger
   297  }
   298  
   299  // NewFeatureOnlineStoreClient creates a new feature online store service client based on gRPC.
   300  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   301  //
   302  // A service for fetching feature values from the online store.
   303  func NewFeatureOnlineStoreClient(ctx context.Context, opts ...option.ClientOption) (*FeatureOnlineStoreClient, error) {
   304  	clientOpts := defaultFeatureOnlineStoreGRPCClientOptions()
   305  	if newFeatureOnlineStoreClientHook != nil {
   306  		hookOpts, err := newFeatureOnlineStoreClientHook(ctx, clientHookParams{})
   307  		if err != nil {
   308  			return nil, err
   309  		}
   310  		clientOpts = append(clientOpts, hookOpts...)
   311  	}
   312  
   313  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   314  	if err != nil {
   315  		return nil, err
   316  	}
   317  	client := FeatureOnlineStoreClient{CallOptions: defaultFeatureOnlineStoreCallOptions()}
   318  
   319  	c := &featureOnlineStoreGRPCClient{
   320  		connPool:                 connPool,
   321  		featureOnlineStoreClient: aiplatformpb.NewFeatureOnlineStoreServiceClient(connPool),
   322  		CallOptions:              &client.CallOptions,
   323  		logger:                   internaloption.GetLogger(opts),
   324  		operationsClient:         longrunningpb.NewOperationsClient(connPool),
   325  		iamPolicyClient:          iampb.NewIAMPolicyClient(connPool),
   326  		locationsClient:          locationpb.NewLocationsClient(connPool),
   327  	}
   328  	c.setGoogleClientInfo()
   329  
   330  	client.internalClient = c
   331  
   332  	return &client, nil
   333  }
   334  
   335  // Connection returns a connection to the API service.
   336  //
   337  // Deprecated: Connections are now pooled so this method does not always
   338  // return the same resource.
   339  func (c *featureOnlineStoreGRPCClient) Connection() *grpc.ClientConn {
   340  	return c.connPool.Conn()
   341  }
   342  
   343  // setGoogleClientInfo sets the name and version of the application in
   344  // the `x-goog-api-client` header passed on each request. Intended for
   345  // use by Google-written clients.
   346  func (c *featureOnlineStoreGRPCClient) setGoogleClientInfo(keyval ...string) {
   347  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   348  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   349  	c.xGoogHeaders = []string{
   350  		"x-goog-api-client", gax.XGoogHeader(kv...),
   351  	}
   352  }
   353  
   354  // Close closes the connection to the API service. The user should invoke this when
   355  // the client is no longer required.
   356  func (c *featureOnlineStoreGRPCClient) Close() error {
   357  	return c.connPool.Close()
   358  }
   359  
   360  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   361  type featureOnlineStoreRESTClient struct {
   362  	// The http endpoint to connect to.
   363  	endpoint string
   364  
   365  	// The http client.
   366  	httpClient *http.Client
   367  
   368  	// The x-goog-* headers to be sent with each request.
   369  	xGoogHeaders []string
   370  
   371  	// Points back to the CallOptions field of the containing FeatureOnlineStoreClient
   372  	CallOptions **FeatureOnlineStoreCallOptions
   373  
   374  	logger *slog.Logger
   375  }
   376  
   377  // NewFeatureOnlineStoreRESTClient creates a new feature online store service rest client.
   378  //
   379  // A service for fetching feature values from the online store.
   380  func NewFeatureOnlineStoreRESTClient(ctx context.Context, opts ...option.ClientOption) (*FeatureOnlineStoreClient, error) {
   381  	clientOpts := append(defaultFeatureOnlineStoreRESTClientOptions(), opts...)
   382  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   383  	if err != nil {
   384  		return nil, err
   385  	}
   386  
   387  	callOpts := defaultFeatureOnlineStoreRESTCallOptions()
   388  	c := &featureOnlineStoreRESTClient{
   389  		endpoint:    endpoint,
   390  		httpClient:  httpClient,
   391  		CallOptions: &callOpts,
   392  		logger:      internaloption.GetLogger(opts),
   393  	}
   394  	c.setGoogleClientInfo()
   395  
   396  	return &FeatureOnlineStoreClient{internalClient: c, CallOptions: callOpts}, nil
   397  }
   398  
   399  func defaultFeatureOnlineStoreRESTClientOptions() []option.ClientOption {
   400  	return []option.ClientOption{
   401  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   402  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   403  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   404  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   405  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   406  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   407  		internaloption.EnableNewAuthLibrary(),
   408  	}
   409  }
   410  
   411  // setGoogleClientInfo sets the name and version of the application in
   412  // the `x-goog-api-client` header passed on each request. Intended for
   413  // use by Google-written clients.
   414  func (c *featureOnlineStoreRESTClient) setGoogleClientInfo(keyval ...string) {
   415  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   416  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   417  	c.xGoogHeaders = []string{
   418  		"x-goog-api-client", gax.XGoogHeader(kv...),
   419  	}
   420  }
   421  
   422  // Close closes the connection to the API service. The user should invoke this when
   423  // the client is no longer required.
   424  func (c *featureOnlineStoreRESTClient) Close() error {
   425  	// Replace httpClient with nil to force cleanup.
   426  	c.httpClient = nil
   427  	return nil
   428  }
   429  
   430  // Connection returns a connection to the API service.
   431  //
   432  // Deprecated: This method always returns nil.
   433  func (c *featureOnlineStoreRESTClient) Connection() *grpc.ClientConn {
   434  	return nil
   435  }
   436  func (c *featureOnlineStoreGRPCClient) FetchFeatureValues(ctx context.Context, req *aiplatformpb.FetchFeatureValuesRequest, opts ...gax.CallOption) (*aiplatformpb.FetchFeatureValuesResponse, error) {
   437  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_view", url.QueryEscape(req.GetFeatureView()))}
   438  
   439  	hds = append(c.xGoogHeaders, hds...)
   440  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   441  	opts = append((*c.CallOptions).FetchFeatureValues[0:len((*c.CallOptions).FetchFeatureValues):len((*c.CallOptions).FetchFeatureValues)], opts...)
   442  	var resp *aiplatformpb.FetchFeatureValuesResponse
   443  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   444  		var err error
   445  		resp, err = executeRPC(ctx, c.featureOnlineStoreClient.FetchFeatureValues, req, settings.GRPC, c.logger, "FetchFeatureValues")
   446  		return err
   447  	}, opts...)
   448  	if err != nil {
   449  		return nil, err
   450  	}
   451  	return resp, nil
   452  }
   453  
   454  func (c *featureOnlineStoreGRPCClient) StreamingFetchFeatureValues(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_StreamingFetchFeatureValuesClient, error) {
   455  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
   456  	var resp aiplatformpb.FeatureOnlineStoreService_StreamingFetchFeatureValuesClient
   457  	opts = append((*c.CallOptions).StreamingFetchFeatureValues[0:len((*c.CallOptions).StreamingFetchFeatureValues):len((*c.CallOptions).StreamingFetchFeatureValues)], opts...)
   458  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   459  		var err error
   460  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamingFetchFeatureValues")
   461  		resp, err = c.featureOnlineStoreClient.StreamingFetchFeatureValues(ctx, settings.GRPC...)
   462  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamingFetchFeatureValues")
   463  		return err
   464  	}, opts...)
   465  	if err != nil {
   466  		return nil, err
   467  	}
   468  	return resp, nil
   469  }
   470  
   471  func (c *featureOnlineStoreGRPCClient) SearchNearestEntities(ctx context.Context, req *aiplatformpb.SearchNearestEntitiesRequest, opts ...gax.CallOption) (*aiplatformpb.SearchNearestEntitiesResponse, error) {
   472  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_view", url.QueryEscape(req.GetFeatureView()))}
   473  
   474  	hds = append(c.xGoogHeaders, hds...)
   475  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   476  	opts = append((*c.CallOptions).SearchNearestEntities[0:len((*c.CallOptions).SearchNearestEntities):len((*c.CallOptions).SearchNearestEntities)], opts...)
   477  	var resp *aiplatformpb.SearchNearestEntitiesResponse
   478  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   479  		var err error
   480  		resp, err = executeRPC(ctx, c.featureOnlineStoreClient.SearchNearestEntities, req, settings.GRPC, c.logger, "SearchNearestEntities")
   481  		return err
   482  	}, opts...)
   483  	if err != nil {
   484  		return nil, err
   485  	}
   486  	return resp, nil
   487  }
   488  
   489  func (c *featureOnlineStoreGRPCClient) FeatureViewDirectWrite(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_FeatureViewDirectWriteClient, error) {
   490  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, c.xGoogHeaders...)
   491  	var resp aiplatformpb.FeatureOnlineStoreService_FeatureViewDirectWriteClient
   492  	opts = append((*c.CallOptions).FeatureViewDirectWrite[0:len((*c.CallOptions).FeatureViewDirectWrite):len((*c.CallOptions).FeatureViewDirectWrite)], opts...)
   493  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   494  		var err error
   495  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "FeatureViewDirectWrite")
   496  		resp, err = c.featureOnlineStoreClient.FeatureViewDirectWrite(ctx, settings.GRPC...)
   497  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "FeatureViewDirectWrite")
   498  		return err
   499  	}, opts...)
   500  	if err != nil {
   501  		return nil, err
   502  	}
   503  	return resp, nil
   504  }
   505  
   506  func (c *featureOnlineStoreGRPCClient) GenerateFetchAccessToken(ctx context.Context, req *aiplatformpb.GenerateFetchAccessTokenRequest, opts ...gax.CallOption) (*aiplatformpb.GenerateFetchAccessTokenResponse, error) {
   507  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_view", url.QueryEscape(req.GetFeatureView()))}
   508  
   509  	hds = append(c.xGoogHeaders, hds...)
   510  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   511  	opts = append((*c.CallOptions).GenerateFetchAccessToken[0:len((*c.CallOptions).GenerateFetchAccessToken):len((*c.CallOptions).GenerateFetchAccessToken)], opts...)
   512  	var resp *aiplatformpb.GenerateFetchAccessTokenResponse
   513  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   514  		var err error
   515  		resp, err = executeRPC(ctx, c.featureOnlineStoreClient.GenerateFetchAccessToken, req, settings.GRPC, c.logger, "GenerateFetchAccessToken")
   516  		return err
   517  	}, opts...)
   518  	if err != nil {
   519  		return nil, err
   520  	}
   521  	return resp, nil
   522  }
   523  
   524  func (c *featureOnlineStoreGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   525  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   526  
   527  	hds = append(c.xGoogHeaders, hds...)
   528  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   529  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
   530  	var resp *locationpb.Location
   531  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   532  		var err error
   533  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
   534  		return err
   535  	}, opts...)
   536  	if err != nil {
   537  		return nil, err
   538  	}
   539  	return resp, nil
   540  }
   541  
   542  func (c *featureOnlineStoreGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   543  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   544  
   545  	hds = append(c.xGoogHeaders, hds...)
   546  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   547  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
   548  	it := &LocationIterator{}
   549  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
   550  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
   551  		resp := &locationpb.ListLocationsResponse{}
   552  		if pageToken != "" {
   553  			req.PageToken = pageToken
   554  		}
   555  		if pageSize > math.MaxInt32 {
   556  			req.PageSize = math.MaxInt32
   557  		} else if pageSize != 0 {
   558  			req.PageSize = int32(pageSize)
   559  		}
   560  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   561  			var err error
   562  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
   563  			return err
   564  		}, opts...)
   565  		if err != nil {
   566  			return nil, "", err
   567  		}
   568  
   569  		it.Response = resp
   570  		return resp.GetLocations(), resp.GetNextPageToken(), nil
   571  	}
   572  	fetch := func(pageSize int, pageToken string) (string, error) {
   573  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   574  		if err != nil {
   575  			return "", err
   576  		}
   577  		it.items = append(it.items, items...)
   578  		return nextPageToken, nil
   579  	}
   580  
   581  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   582  	it.pageInfo.MaxSize = int(req.GetPageSize())
   583  	it.pageInfo.Token = req.GetPageToken()
   584  
   585  	return it
   586  }
   587  
   588  func (c *featureOnlineStoreGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   589  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   590  
   591  	hds = append(c.xGoogHeaders, hds...)
   592  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   593  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
   594  	var resp *iampb.Policy
   595  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   596  		var err error
   597  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
   598  		return err
   599  	}, opts...)
   600  	if err != nil {
   601  		return nil, err
   602  	}
   603  	return resp, nil
   604  }
   605  
   606  func (c *featureOnlineStoreGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   607  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   608  
   609  	hds = append(c.xGoogHeaders, hds...)
   610  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   611  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
   612  	var resp *iampb.Policy
   613  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   614  		var err error
   615  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
   616  		return err
   617  	}, opts...)
   618  	if err != nil {
   619  		return nil, err
   620  	}
   621  	return resp, nil
   622  }
   623  
   624  func (c *featureOnlineStoreGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   625  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   626  
   627  	hds = append(c.xGoogHeaders, hds...)
   628  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   629  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
   630  	var resp *iampb.TestIamPermissionsResponse
   631  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   632  		var err error
   633  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
   634  		return err
   635  	}, opts...)
   636  	if err != nil {
   637  		return nil, err
   638  	}
   639  	return resp, nil
   640  }
   641  
   642  func (c *featureOnlineStoreGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   643  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   644  
   645  	hds = append(c.xGoogHeaders, hds...)
   646  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   647  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
   648  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   649  		var err error
   650  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
   651  		return err
   652  	}, opts...)
   653  	return err
   654  }
   655  
   656  func (c *featureOnlineStoreGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   657  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   658  
   659  	hds = append(c.xGoogHeaders, hds...)
   660  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   661  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
   662  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   663  		var err error
   664  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
   665  		return err
   666  	}, opts...)
   667  	return err
   668  }
   669  
   670  func (c *featureOnlineStoreGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, 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).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
   676  	var resp *longrunningpb.Operation
   677  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   678  		var err error
   679  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
   680  		return err
   681  	}, opts...)
   682  	if err != nil {
   683  		return nil, err
   684  	}
   685  	return resp, nil
   686  }
   687  
   688  func (c *featureOnlineStoreGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   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).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
   694  	it := &OperationIterator{}
   695  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
   696  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
   697  		resp := &longrunningpb.ListOperationsResponse{}
   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.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
   709  			return err
   710  		}, opts...)
   711  		if err != nil {
   712  			return nil, "", err
   713  		}
   714  
   715  		it.Response = resp
   716  		return resp.GetOperations(), 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 *featureOnlineStoreGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   735  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   736  
   737  	hds = append(c.xGoogHeaders, hds...)
   738  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   739  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
   740  	var resp *longrunningpb.Operation
   741  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   742  		var err error
   743  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
   744  		return err
   745  	}, opts...)
   746  	if err != nil {
   747  		return nil, err
   748  	}
   749  	return resp, nil
   750  }
   751  
   752  // FetchFeatureValues fetch feature values under a FeatureView.
   753  func (c *featureOnlineStoreRESTClient) FetchFeatureValues(ctx context.Context, req *aiplatformpb.FetchFeatureValuesRequest, opts ...gax.CallOption) (*aiplatformpb.FetchFeatureValuesResponse, error) {
   754  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
   755  	jsonReq, err := m.Marshal(req)
   756  	if err != nil {
   757  		return nil, err
   758  	}
   759  
   760  	baseUrl, err := url.Parse(c.endpoint)
   761  	if err != nil {
   762  		return nil, err
   763  	}
   764  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:fetchFeatureValues", req.GetFeatureView())
   765  
   766  	params := url.Values{}
   767  	params.Add("$alt", "json;enum-encoding=int")
   768  
   769  	baseUrl.RawQuery = params.Encode()
   770  
   771  	// Build HTTP headers from client and context metadata.
   772  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_view", url.QueryEscape(req.GetFeatureView()))}
   773  
   774  	hds = append(c.xGoogHeaders, hds...)
   775  	hds = append(hds, "Content-Type", "application/json")
   776  	headers := gax.BuildHeaders(ctx, hds...)
   777  	opts = append((*c.CallOptions).FetchFeatureValues[0:len((*c.CallOptions).FetchFeatureValues):len((*c.CallOptions).FetchFeatureValues)], opts...)
   778  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   779  	resp := &aiplatformpb.FetchFeatureValuesResponse{}
   780  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   781  		if settings.Path != "" {
   782  			baseUrl.Path = settings.Path
   783  		}
   784  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
   785  		if err != nil {
   786  			return err
   787  		}
   788  		httpReq = httpReq.WithContext(ctx)
   789  		httpReq.Header = headers
   790  
   791  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "FetchFeatureValues")
   792  		if err != nil {
   793  			return err
   794  		}
   795  
   796  		if err := unm.Unmarshal(buf, resp); err != nil {
   797  			return err
   798  		}
   799  
   800  		return nil
   801  	}, opts...)
   802  	if e != nil {
   803  		return nil, e
   804  	}
   805  	return resp, nil
   806  }
   807  
   808  // StreamingFetchFeatureValues bidirectional streaming RPC to fetch feature values under a FeatureView.
   809  // Requests may not have a one-to-one mapping to responses and responses may
   810  // be returned out-of-order to reduce latency.
   811  //
   812  // This method is not supported for the REST transport.
   813  func (c *featureOnlineStoreRESTClient) StreamingFetchFeatureValues(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_StreamingFetchFeatureValuesClient, error) {
   814  	return nil, errors.New("StreamingFetchFeatureValues not yet supported for REST clients")
   815  }
   816  
   817  // SearchNearestEntities search the nearest entities under a FeatureView.
   818  // Search only works for indexable feature view; if a feature view isn’t
   819  // indexable, returns Invalid argument response.
   820  func (c *featureOnlineStoreRESTClient) SearchNearestEntities(ctx context.Context, req *aiplatformpb.SearchNearestEntitiesRequest, opts ...gax.CallOption) (*aiplatformpb.SearchNearestEntitiesResponse, error) {
   821  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
   822  	jsonReq, err := m.Marshal(req)
   823  	if err != nil {
   824  		return nil, err
   825  	}
   826  
   827  	baseUrl, err := url.Parse(c.endpoint)
   828  	if err != nil {
   829  		return nil, err
   830  	}
   831  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:searchNearestEntities", req.GetFeatureView())
   832  
   833  	params := url.Values{}
   834  	params.Add("$alt", "json;enum-encoding=int")
   835  
   836  	baseUrl.RawQuery = params.Encode()
   837  
   838  	// Build HTTP headers from client and context metadata.
   839  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_view", url.QueryEscape(req.GetFeatureView()))}
   840  
   841  	hds = append(c.xGoogHeaders, hds...)
   842  	hds = append(hds, "Content-Type", "application/json")
   843  	headers := gax.BuildHeaders(ctx, hds...)
   844  	opts = append((*c.CallOptions).SearchNearestEntities[0:len((*c.CallOptions).SearchNearestEntities):len((*c.CallOptions).SearchNearestEntities)], opts...)
   845  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   846  	resp := &aiplatformpb.SearchNearestEntitiesResponse{}
   847  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   848  		if settings.Path != "" {
   849  			baseUrl.Path = settings.Path
   850  		}
   851  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
   852  		if err != nil {
   853  			return err
   854  		}
   855  		httpReq = httpReq.WithContext(ctx)
   856  		httpReq.Header = headers
   857  
   858  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SearchNearestEntities")
   859  		if err != nil {
   860  			return err
   861  		}
   862  
   863  		if err := unm.Unmarshal(buf, resp); err != nil {
   864  			return err
   865  		}
   866  
   867  		return nil
   868  	}, opts...)
   869  	if e != nil {
   870  		return nil, e
   871  	}
   872  	return resp, nil
   873  }
   874  
   875  // FeatureViewDirectWrite bidirectional streaming RPC to directly write to feature values in a
   876  // feature view. Requests may not have a one-to-one mapping to responses and
   877  // responses may be returned out-of-order to reduce latency.
   878  //
   879  // This method is not supported for the REST transport.
   880  func (c *featureOnlineStoreRESTClient) FeatureViewDirectWrite(ctx context.Context, opts ...gax.CallOption) (aiplatformpb.FeatureOnlineStoreService_FeatureViewDirectWriteClient, error) {
   881  	return nil, errors.New("FeatureViewDirectWrite not yet supported for REST clients")
   882  }
   883  
   884  // GenerateFetchAccessToken rPC to generate an access token for the given feature view. FeatureViews
   885  // under the same FeatureOnlineStore share the same access token.
   886  func (c *featureOnlineStoreRESTClient) GenerateFetchAccessToken(ctx context.Context, req *aiplatformpb.GenerateFetchAccessTokenRequest, opts ...gax.CallOption) (*aiplatformpb.GenerateFetchAccessTokenResponse, error) {
   887  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
   888  	jsonReq, err := m.Marshal(req)
   889  	if err != nil {
   890  		return nil, err
   891  	}
   892  
   893  	baseUrl, err := url.Parse(c.endpoint)
   894  	if err != nil {
   895  		return nil, err
   896  	}
   897  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:generateFetchAccessToken", req.GetFeatureView())
   898  
   899  	params := url.Values{}
   900  	params.Add("$alt", "json;enum-encoding=int")
   901  
   902  	baseUrl.RawQuery = params.Encode()
   903  
   904  	// Build HTTP headers from client and context metadata.
   905  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "feature_view", url.QueryEscape(req.GetFeatureView()))}
   906  
   907  	hds = append(c.xGoogHeaders, hds...)
   908  	hds = append(hds, "Content-Type", "application/json")
   909  	headers := gax.BuildHeaders(ctx, hds...)
   910  	opts = append((*c.CallOptions).GenerateFetchAccessToken[0:len((*c.CallOptions).GenerateFetchAccessToken):len((*c.CallOptions).GenerateFetchAccessToken)], opts...)
   911  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   912  	resp := &aiplatformpb.GenerateFetchAccessTokenResponse{}
   913  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   914  		if settings.Path != "" {
   915  			baseUrl.Path = settings.Path
   916  		}
   917  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
   918  		if err != nil {
   919  			return err
   920  		}
   921  		httpReq = httpReq.WithContext(ctx)
   922  		httpReq.Header = headers
   923  
   924  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GenerateFetchAccessToken")
   925  		if err != nil {
   926  			return err
   927  		}
   928  
   929  		if err := unm.Unmarshal(buf, resp); err != nil {
   930  			return err
   931  		}
   932  
   933  		return nil
   934  	}, opts...)
   935  	if e != nil {
   936  		return nil, e
   937  	}
   938  	return resp, nil
   939  }
   940  
   941  // GetLocation gets information about a location.
   942  func (c *featureOnlineStoreRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   943  	baseUrl, err := url.Parse(c.endpoint)
   944  	if err != nil {
   945  		return nil, err
   946  	}
   947  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
   948  
   949  	params := url.Values{}
   950  	params.Add("$alt", "json;enum-encoding=int")
   951  
   952  	baseUrl.RawQuery = params.Encode()
   953  
   954  	// Build HTTP headers from client and context metadata.
   955  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   956  
   957  	hds = append(c.xGoogHeaders, hds...)
   958  	hds = append(hds, "Content-Type", "application/json")
   959  	headers := gax.BuildHeaders(ctx, hds...)
   960  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
   961  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   962  	resp := &locationpb.Location{}
   963  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   964  		if settings.Path != "" {
   965  			baseUrl.Path = settings.Path
   966  		}
   967  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
   968  		if err != nil {
   969  			return err
   970  		}
   971  		httpReq = httpReq.WithContext(ctx)
   972  		httpReq.Header = headers
   973  
   974  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
   975  		if err != nil {
   976  			return err
   977  		}
   978  
   979  		if err := unm.Unmarshal(buf, resp); err != nil {
   980  			return err
   981  		}
   982  
   983  		return nil
   984  	}, opts...)
   985  	if e != nil {
   986  		return nil, e
   987  	}
   988  	return resp, nil
   989  }
   990  
   991  // ListLocations lists information about the supported locations for this service.
   992  func (c *featureOnlineStoreRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   993  	it := &LocationIterator{}
   994  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
   995  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
   996  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
   997  		resp := &locationpb.ListLocationsResponse{}
   998  		if pageToken != "" {
   999  			req.PageToken = pageToken
  1000  		}
  1001  		if pageSize > math.MaxInt32 {
  1002  			req.PageSize = math.MaxInt32
  1003  		} else if pageSize != 0 {
  1004  			req.PageSize = int32(pageSize)
  1005  		}
  1006  		baseUrl, err := url.Parse(c.endpoint)
  1007  		if err != nil {
  1008  			return nil, "", err
  1009  		}
  1010  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  1011  
  1012  		params := url.Values{}
  1013  		params.Add("$alt", "json;enum-encoding=int")
  1014  		if req.GetFilter() != "" {
  1015  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1016  		}
  1017  		if req.GetPageSize() != 0 {
  1018  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1019  		}
  1020  		if req.GetPageToken() != "" {
  1021  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1022  		}
  1023  
  1024  		baseUrl.RawQuery = params.Encode()
  1025  
  1026  		// Build HTTP headers from client and context metadata.
  1027  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1028  		headers := gax.BuildHeaders(ctx, hds...)
  1029  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1030  			if settings.Path != "" {
  1031  				baseUrl.Path = settings.Path
  1032  			}
  1033  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1034  			if err != nil {
  1035  				return err
  1036  			}
  1037  			httpReq.Header = headers
  1038  
  1039  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  1040  			if err != nil {
  1041  				return err
  1042  			}
  1043  			if err := unm.Unmarshal(buf, resp); err != nil {
  1044  				return err
  1045  			}
  1046  
  1047  			return nil
  1048  		}, opts...)
  1049  		if e != nil {
  1050  			return nil, "", e
  1051  		}
  1052  		it.Response = resp
  1053  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1054  	}
  1055  
  1056  	fetch := func(pageSize int, pageToken string) (string, error) {
  1057  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1058  		if err != nil {
  1059  			return "", err
  1060  		}
  1061  		it.items = append(it.items, items...)
  1062  		return nextPageToken, nil
  1063  	}
  1064  
  1065  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1066  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1067  	it.pageInfo.Token = req.GetPageToken()
  1068  
  1069  	return it
  1070  }
  1071  
  1072  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  1073  // if the resource exists and does not have a policy set.
  1074  func (c *featureOnlineStoreRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1075  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1076  	jsonReq, err := m.Marshal(req)
  1077  	if err != nil {
  1078  		return nil, err
  1079  	}
  1080  
  1081  	baseUrl, err := url.Parse(c.endpoint)
  1082  	if err != nil {
  1083  		return nil, err
  1084  	}
  1085  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  1086  
  1087  	params := url.Values{}
  1088  	params.Add("$alt", "json;enum-encoding=int")
  1089  
  1090  	baseUrl.RawQuery = params.Encode()
  1091  
  1092  	// Build HTTP headers from client and context metadata.
  1093  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1094  
  1095  	hds = append(c.xGoogHeaders, hds...)
  1096  	hds = append(hds, "Content-Type", "application/json")
  1097  	headers := gax.BuildHeaders(ctx, hds...)
  1098  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1099  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1100  	resp := &iampb.Policy{}
  1101  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1102  		if settings.Path != "" {
  1103  			baseUrl.Path = settings.Path
  1104  		}
  1105  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1106  		if err != nil {
  1107  			return err
  1108  		}
  1109  		httpReq = httpReq.WithContext(ctx)
  1110  		httpReq.Header = headers
  1111  
  1112  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  1113  		if err != nil {
  1114  			return err
  1115  		}
  1116  
  1117  		if err := unm.Unmarshal(buf, resp); err != nil {
  1118  			return err
  1119  		}
  1120  
  1121  		return nil
  1122  	}, opts...)
  1123  	if e != nil {
  1124  		return nil, e
  1125  	}
  1126  	return resp, nil
  1127  }
  1128  
  1129  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  1130  // any existing policy.
  1131  //
  1132  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  1133  // errors.
  1134  func (c *featureOnlineStoreRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1135  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1136  	jsonReq, err := m.Marshal(req)
  1137  	if err != nil {
  1138  		return nil, err
  1139  	}
  1140  
  1141  	baseUrl, err := url.Parse(c.endpoint)
  1142  	if err != nil {
  1143  		return nil, err
  1144  	}
  1145  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  1146  
  1147  	params := url.Values{}
  1148  	params.Add("$alt", "json;enum-encoding=int")
  1149  
  1150  	baseUrl.RawQuery = params.Encode()
  1151  
  1152  	// Build HTTP headers from client and context metadata.
  1153  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1154  
  1155  	hds = append(c.xGoogHeaders, hds...)
  1156  	hds = append(hds, "Content-Type", "application/json")
  1157  	headers := gax.BuildHeaders(ctx, hds...)
  1158  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1159  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1160  	resp := &iampb.Policy{}
  1161  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1162  		if settings.Path != "" {
  1163  			baseUrl.Path = settings.Path
  1164  		}
  1165  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1166  		if err != nil {
  1167  			return err
  1168  		}
  1169  		httpReq = httpReq.WithContext(ctx)
  1170  		httpReq.Header = headers
  1171  
  1172  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  1173  		if err != nil {
  1174  			return err
  1175  		}
  1176  
  1177  		if err := unm.Unmarshal(buf, resp); err != nil {
  1178  			return err
  1179  		}
  1180  
  1181  		return nil
  1182  	}, opts...)
  1183  	if e != nil {
  1184  		return nil, e
  1185  	}
  1186  	return resp, nil
  1187  }
  1188  
  1189  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  1190  // resource does not exist, this will return an empty set of
  1191  // permissions, not a NOT_FOUND error.
  1192  //
  1193  // Note: This operation is designed to be used for building
  1194  // permission-aware UIs and command-line tools, not for authorization
  1195  // checking. This operation may “fail open” without warning.
  1196  func (c *featureOnlineStoreRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1197  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1198  	jsonReq, err := m.Marshal(req)
  1199  	if err != nil {
  1200  		return nil, err
  1201  	}
  1202  
  1203  	baseUrl, err := url.Parse(c.endpoint)
  1204  	if err != nil {
  1205  		return nil, err
  1206  	}
  1207  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  1208  
  1209  	params := url.Values{}
  1210  	params.Add("$alt", "json;enum-encoding=int")
  1211  
  1212  	baseUrl.RawQuery = params.Encode()
  1213  
  1214  	// Build HTTP headers from client and context metadata.
  1215  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1216  
  1217  	hds = append(c.xGoogHeaders, hds...)
  1218  	hds = append(hds, "Content-Type", "application/json")
  1219  	headers := gax.BuildHeaders(ctx, hds...)
  1220  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1221  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1222  	resp := &iampb.TestIamPermissionsResponse{}
  1223  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1224  		if settings.Path != "" {
  1225  			baseUrl.Path = settings.Path
  1226  		}
  1227  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1228  		if err != nil {
  1229  			return err
  1230  		}
  1231  		httpReq = httpReq.WithContext(ctx)
  1232  		httpReq.Header = headers
  1233  
  1234  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  1235  		if err != nil {
  1236  			return err
  1237  		}
  1238  
  1239  		if err := unm.Unmarshal(buf, resp); err != nil {
  1240  			return err
  1241  		}
  1242  
  1243  		return nil
  1244  	}, opts...)
  1245  	if e != nil {
  1246  		return nil, e
  1247  	}
  1248  	return resp, nil
  1249  }
  1250  
  1251  // CancelOperation is a utility method from google.longrunning.Operations.
  1252  func (c *featureOnlineStoreRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1253  	baseUrl, err := url.Parse(c.endpoint)
  1254  	if err != nil {
  1255  		return err
  1256  	}
  1257  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  1258  
  1259  	params := url.Values{}
  1260  	params.Add("$alt", "json;enum-encoding=int")
  1261  
  1262  	baseUrl.RawQuery = params.Encode()
  1263  
  1264  	// Build HTTP headers from client and context metadata.
  1265  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1266  
  1267  	hds = append(c.xGoogHeaders, hds...)
  1268  	hds = append(hds, "Content-Type", "application/json")
  1269  	headers := gax.BuildHeaders(ctx, hds...)
  1270  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1271  		if settings.Path != "" {
  1272  			baseUrl.Path = settings.Path
  1273  		}
  1274  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  1275  		if err != nil {
  1276  			return err
  1277  		}
  1278  		httpReq = httpReq.WithContext(ctx)
  1279  		httpReq.Header = headers
  1280  
  1281  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  1282  		return err
  1283  	}, opts...)
  1284  }
  1285  
  1286  // DeleteOperation is a utility method from google.longrunning.Operations.
  1287  func (c *featureOnlineStoreRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1288  	baseUrl, err := url.Parse(c.endpoint)
  1289  	if err != nil {
  1290  		return err
  1291  	}
  1292  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  1293  
  1294  	params := url.Values{}
  1295  	params.Add("$alt", "json;enum-encoding=int")
  1296  
  1297  	baseUrl.RawQuery = params.Encode()
  1298  
  1299  	// Build HTTP headers from client and context metadata.
  1300  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1301  
  1302  	hds = append(c.xGoogHeaders, hds...)
  1303  	hds = append(hds, "Content-Type", "application/json")
  1304  	headers := gax.BuildHeaders(ctx, hds...)
  1305  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1306  		if settings.Path != "" {
  1307  			baseUrl.Path = settings.Path
  1308  		}
  1309  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1310  		if err != nil {
  1311  			return err
  1312  		}
  1313  		httpReq = httpReq.WithContext(ctx)
  1314  		httpReq.Header = headers
  1315  
  1316  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  1317  		return err
  1318  	}, opts...)
  1319  }
  1320  
  1321  // GetOperation is a utility method from google.longrunning.Operations.
  1322  func (c *featureOnlineStoreRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1323  	baseUrl, err := url.Parse(c.endpoint)
  1324  	if err != nil {
  1325  		return nil, err
  1326  	}
  1327  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  1328  
  1329  	params := url.Values{}
  1330  	params.Add("$alt", "json;enum-encoding=int")
  1331  
  1332  	baseUrl.RawQuery = params.Encode()
  1333  
  1334  	// Build HTTP headers from client and context metadata.
  1335  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1336  
  1337  	hds = append(c.xGoogHeaders, hds...)
  1338  	hds = append(hds, "Content-Type", "application/json")
  1339  	headers := gax.BuildHeaders(ctx, hds...)
  1340  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1341  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1342  	resp := &longrunningpb.Operation{}
  1343  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1344  		if settings.Path != "" {
  1345  			baseUrl.Path = settings.Path
  1346  		}
  1347  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1348  		if err != nil {
  1349  			return err
  1350  		}
  1351  		httpReq = httpReq.WithContext(ctx)
  1352  		httpReq.Header = headers
  1353  
  1354  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  1355  		if err != nil {
  1356  			return err
  1357  		}
  1358  
  1359  		if err := unm.Unmarshal(buf, resp); err != nil {
  1360  			return err
  1361  		}
  1362  
  1363  		return nil
  1364  	}, opts...)
  1365  	if e != nil {
  1366  		return nil, e
  1367  	}
  1368  	return resp, nil
  1369  }
  1370  
  1371  // ListOperations is a utility method from google.longrunning.Operations.
  1372  func (c *featureOnlineStoreRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1373  	it := &OperationIterator{}
  1374  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1375  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1376  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1377  		resp := &longrunningpb.ListOperationsResponse{}
  1378  		if pageToken != "" {
  1379  			req.PageToken = pageToken
  1380  		}
  1381  		if pageSize > math.MaxInt32 {
  1382  			req.PageSize = math.MaxInt32
  1383  		} else if pageSize != 0 {
  1384  			req.PageSize = int32(pageSize)
  1385  		}
  1386  		baseUrl, err := url.Parse(c.endpoint)
  1387  		if err != nil {
  1388  			return nil, "", err
  1389  		}
  1390  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  1391  
  1392  		params := url.Values{}
  1393  		params.Add("$alt", "json;enum-encoding=int")
  1394  		if req.GetFilter() != "" {
  1395  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1396  		}
  1397  		if req.GetPageSize() != 0 {
  1398  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1399  		}
  1400  		if req.GetPageToken() != "" {
  1401  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1402  		}
  1403  
  1404  		baseUrl.RawQuery = params.Encode()
  1405  
  1406  		// Build HTTP headers from client and context metadata.
  1407  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1408  		headers := gax.BuildHeaders(ctx, hds...)
  1409  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1410  			if settings.Path != "" {
  1411  				baseUrl.Path = settings.Path
  1412  			}
  1413  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1414  			if err != nil {
  1415  				return err
  1416  			}
  1417  			httpReq.Header = headers
  1418  
  1419  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  1420  			if err != nil {
  1421  				return err
  1422  			}
  1423  			if err := unm.Unmarshal(buf, resp); err != nil {
  1424  				return err
  1425  			}
  1426  
  1427  			return nil
  1428  		}, opts...)
  1429  		if e != nil {
  1430  			return nil, "", e
  1431  		}
  1432  		it.Response = resp
  1433  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1434  	}
  1435  
  1436  	fetch := func(pageSize int, pageToken string) (string, error) {
  1437  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1438  		if err != nil {
  1439  			return "", err
  1440  		}
  1441  		it.items = append(it.items, items...)
  1442  		return nextPageToken, nil
  1443  	}
  1444  
  1445  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1446  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1447  	it.pageInfo.Token = req.GetPageToken()
  1448  
  1449  	return it
  1450  }
  1451  
  1452  // WaitOperation is a utility method from google.longrunning.Operations.
  1453  func (c *featureOnlineStoreRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1454  	baseUrl, err := url.Parse(c.endpoint)
  1455  	if err != nil {
  1456  		return nil, err
  1457  	}
  1458  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  1459  
  1460  	params := url.Values{}
  1461  	params.Add("$alt", "json;enum-encoding=int")
  1462  	if req.GetTimeout() != nil {
  1463  		field, err := protojson.Marshal(req.GetTimeout())
  1464  		if err != nil {
  1465  			return nil, err
  1466  		}
  1467  		params.Add("timeout", string(field[1:len(field)-1]))
  1468  	}
  1469  
  1470  	baseUrl.RawQuery = params.Encode()
  1471  
  1472  	// Build HTTP headers from client and context metadata.
  1473  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1474  
  1475  	hds = append(c.xGoogHeaders, hds...)
  1476  	hds = append(hds, "Content-Type", "application/json")
  1477  	headers := gax.BuildHeaders(ctx, hds...)
  1478  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1479  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1480  	resp := &longrunningpb.Operation{}
  1481  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1482  		if settings.Path != "" {
  1483  			baseUrl.Path = settings.Path
  1484  		}
  1485  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  1486  		if err != nil {
  1487  			return err
  1488  		}
  1489  		httpReq = httpReq.WithContext(ctx)
  1490  		httpReq.Header = headers
  1491  
  1492  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  1493  		if err != nil {
  1494  			return err
  1495  		}
  1496  
  1497  		if err := unm.Unmarshal(buf, resp); err != nil {
  1498  			return err
  1499  		}
  1500  
  1501  		return nil
  1502  	}, opts...)
  1503  	if e != nil {
  1504  		return nil, e
  1505  	}
  1506  	return resp, nil
  1507  }