cloud.google.com/go/aiplatform@v1.106.0/apiv1/reasoning_engine_execution_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  	"context"
    21  	"fmt"
    22  	"log/slog"
    23  	"math"
    24  	"net/url"
    25  
    26  	aiplatformpb "cloud.google.com/go/aiplatform/apiv1/aiplatformpb"
    27  	iampb "cloud.google.com/go/iam/apiv1/iampb"
    28  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    29  	gax "github.com/googleapis/gax-go/v2"
    30  	"google.golang.org/api/iterator"
    31  	"google.golang.org/api/option"
    32  	"google.golang.org/api/option/internaloption"
    33  	gtransport "google.golang.org/api/transport/grpc"
    34  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    35  	"google.golang.org/grpc"
    36  	"google.golang.org/protobuf/proto"
    37  )
    38  
    39  var newReasoningEngineExecutionClientHook clientHook
    40  
    41  // ReasoningEngineExecutionCallOptions contains the retry settings for each method of ReasoningEngineExecutionClient.
    42  type ReasoningEngineExecutionCallOptions struct {
    43  	QueryReasoningEngine       []gax.CallOption
    44  	StreamQueryReasoningEngine []gax.CallOption
    45  	GetLocation                []gax.CallOption
    46  	ListLocations              []gax.CallOption
    47  	GetIamPolicy               []gax.CallOption
    48  	SetIamPolicy               []gax.CallOption
    49  	TestIamPermissions         []gax.CallOption
    50  	CancelOperation            []gax.CallOption
    51  	DeleteOperation            []gax.CallOption
    52  	GetOperation               []gax.CallOption
    53  	ListOperations             []gax.CallOption
    54  	WaitOperation              []gax.CallOption
    55  }
    56  
    57  func defaultReasoningEngineExecutionGRPCClientOptions() []option.ClientOption {
    58  	return []option.ClientOption{
    59  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    60  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    61  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    62  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    63  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    64  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    65  		internaloption.EnableJwtWithScope(),
    66  		internaloption.EnableNewAuthLibrary(),
    67  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    68  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    69  	}
    70  }
    71  
    72  func defaultReasoningEngineExecutionCallOptions() *ReasoningEngineExecutionCallOptions {
    73  	return &ReasoningEngineExecutionCallOptions{
    74  		QueryReasoningEngine:       []gax.CallOption{},
    75  		StreamQueryReasoningEngine: []gax.CallOption{},
    76  		GetLocation:                []gax.CallOption{},
    77  		ListLocations:              []gax.CallOption{},
    78  		GetIamPolicy:               []gax.CallOption{},
    79  		SetIamPolicy:               []gax.CallOption{},
    80  		TestIamPermissions:         []gax.CallOption{},
    81  		CancelOperation:            []gax.CallOption{},
    82  		DeleteOperation:            []gax.CallOption{},
    83  		GetOperation:               []gax.CallOption{},
    84  		ListOperations:             []gax.CallOption{},
    85  		WaitOperation:              []gax.CallOption{},
    86  	}
    87  }
    88  
    89  // internalReasoningEngineExecutionClient is an interface that defines the methods available from Vertex AI API.
    90  type internalReasoningEngineExecutionClient interface {
    91  	Close() error
    92  	setGoogleClientInfo(...string)
    93  	Connection() *grpc.ClientConn
    94  	QueryReasoningEngine(context.Context, *aiplatformpb.QueryReasoningEngineRequest, ...gax.CallOption) (*aiplatformpb.QueryReasoningEngineResponse, error)
    95  	StreamQueryReasoningEngine(context.Context, *aiplatformpb.StreamQueryReasoningEngineRequest, ...gax.CallOption) (aiplatformpb.ReasoningEngineExecutionService_StreamQueryReasoningEngineClient, error)
    96  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
    97  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
    98  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
    99  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   100  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   101  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   102  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   103  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   104  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   105  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   106  }
   107  
   108  // ReasoningEngineExecutionClient is a client for interacting with Vertex AI API.
   109  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   110  //
   111  // A service for executing queries on Reasoning Engine.
   112  type ReasoningEngineExecutionClient struct {
   113  	// The internal transport-dependent client.
   114  	internalClient internalReasoningEngineExecutionClient
   115  
   116  	// The call options for this service.
   117  	CallOptions *ReasoningEngineExecutionCallOptions
   118  }
   119  
   120  // Wrapper methods routed to the internal client.
   121  
   122  // Close closes the connection to the API service. The user should invoke this when
   123  // the client is no longer required.
   124  func (c *ReasoningEngineExecutionClient) Close() error {
   125  	return c.internalClient.Close()
   126  }
   127  
   128  // setGoogleClientInfo sets the name and version of the application in
   129  // the `x-goog-api-client` header passed on each request. Intended for
   130  // use by Google-written clients.
   131  func (c *ReasoningEngineExecutionClient) setGoogleClientInfo(keyval ...string) {
   132  	c.internalClient.setGoogleClientInfo(keyval...)
   133  }
   134  
   135  // Connection returns a connection to the API service.
   136  //
   137  // Deprecated: Connections are now pooled so this method does not always
   138  // return the same resource.
   139  func (c *ReasoningEngineExecutionClient) Connection() *grpc.ClientConn {
   140  	return c.internalClient.Connection()
   141  }
   142  
   143  // QueryReasoningEngine queries using a reasoning engine.
   144  func (c *ReasoningEngineExecutionClient) QueryReasoningEngine(ctx context.Context, req *aiplatformpb.QueryReasoningEngineRequest, opts ...gax.CallOption) (*aiplatformpb.QueryReasoningEngineResponse, error) {
   145  	return c.internalClient.QueryReasoningEngine(ctx, req, opts...)
   146  }
   147  
   148  // StreamQueryReasoningEngine streams queries using a reasoning engine.
   149  func (c *ReasoningEngineExecutionClient) StreamQueryReasoningEngine(ctx context.Context, req *aiplatformpb.StreamQueryReasoningEngineRequest, opts ...gax.CallOption) (aiplatformpb.ReasoningEngineExecutionService_StreamQueryReasoningEngineClient, error) {
   150  	return c.internalClient.StreamQueryReasoningEngine(ctx, req, opts...)
   151  }
   152  
   153  // GetLocation gets information about a location.
   154  func (c *ReasoningEngineExecutionClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   155  	return c.internalClient.GetLocation(ctx, req, opts...)
   156  }
   157  
   158  // ListLocations lists information about the supported locations for this service.
   159  func (c *ReasoningEngineExecutionClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   160  	return c.internalClient.ListLocations(ctx, req, opts...)
   161  }
   162  
   163  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   164  // if the resource exists and does not have a policy set.
   165  func (c *ReasoningEngineExecutionClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   166  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   167  }
   168  
   169  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   170  // any existing policy.
   171  //
   172  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   173  // errors.
   174  func (c *ReasoningEngineExecutionClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   175  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   176  }
   177  
   178  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   179  // resource does not exist, this will return an empty set of
   180  // permissions, not a NOT_FOUND error.
   181  //
   182  // Note: This operation is designed to be used for building
   183  // permission-aware UIs and command-line tools, not for authorization
   184  // checking. This operation may “fail open” without warning.
   185  func (c *ReasoningEngineExecutionClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   186  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   187  }
   188  
   189  // CancelOperation is a utility method from google.longrunning.Operations.
   190  func (c *ReasoningEngineExecutionClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   191  	return c.internalClient.CancelOperation(ctx, req, opts...)
   192  }
   193  
   194  // DeleteOperation is a utility method from google.longrunning.Operations.
   195  func (c *ReasoningEngineExecutionClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   196  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   197  }
   198  
   199  // GetOperation is a utility method from google.longrunning.Operations.
   200  func (c *ReasoningEngineExecutionClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   201  	return c.internalClient.GetOperation(ctx, req, opts...)
   202  }
   203  
   204  // ListOperations is a utility method from google.longrunning.Operations.
   205  func (c *ReasoningEngineExecutionClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   206  	return c.internalClient.ListOperations(ctx, req, opts...)
   207  }
   208  
   209  // WaitOperation is a utility method from google.longrunning.Operations.
   210  func (c *ReasoningEngineExecutionClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   211  	return c.internalClient.WaitOperation(ctx, req, opts...)
   212  }
   213  
   214  // reasoningEngineExecutionGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   215  //
   216  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   217  type reasoningEngineExecutionGRPCClient struct {
   218  	// Connection pool of gRPC connections to the service.
   219  	connPool gtransport.ConnPool
   220  
   221  	// Points back to the CallOptions field of the containing ReasoningEngineExecutionClient
   222  	CallOptions **ReasoningEngineExecutionCallOptions
   223  
   224  	// The gRPC API client.
   225  	reasoningEngineExecutionClient aiplatformpb.ReasoningEngineExecutionServiceClient
   226  
   227  	operationsClient longrunningpb.OperationsClient
   228  
   229  	iamPolicyClient iampb.IAMPolicyClient
   230  
   231  	locationsClient locationpb.LocationsClient
   232  
   233  	// The x-goog-* metadata to be sent with each request.
   234  	xGoogHeaders []string
   235  
   236  	logger *slog.Logger
   237  }
   238  
   239  // NewReasoningEngineExecutionClient creates a new reasoning engine execution service client based on gRPC.
   240  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   241  //
   242  // A service for executing queries on Reasoning Engine.
   243  func NewReasoningEngineExecutionClient(ctx context.Context, opts ...option.ClientOption) (*ReasoningEngineExecutionClient, error) {
   244  	clientOpts := defaultReasoningEngineExecutionGRPCClientOptions()
   245  	if newReasoningEngineExecutionClientHook != nil {
   246  		hookOpts, err := newReasoningEngineExecutionClientHook(ctx, clientHookParams{})
   247  		if err != nil {
   248  			return nil, err
   249  		}
   250  		clientOpts = append(clientOpts, hookOpts...)
   251  	}
   252  
   253  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   254  	if err != nil {
   255  		return nil, err
   256  	}
   257  	client := ReasoningEngineExecutionClient{CallOptions: defaultReasoningEngineExecutionCallOptions()}
   258  
   259  	c := &reasoningEngineExecutionGRPCClient{
   260  		connPool:                       connPool,
   261  		reasoningEngineExecutionClient: aiplatformpb.NewReasoningEngineExecutionServiceClient(connPool),
   262  		CallOptions:                    &client.CallOptions,
   263  		logger:                         internaloption.GetLogger(opts),
   264  		operationsClient:               longrunningpb.NewOperationsClient(connPool),
   265  		iamPolicyClient:                iampb.NewIAMPolicyClient(connPool),
   266  		locationsClient:                locationpb.NewLocationsClient(connPool),
   267  	}
   268  	c.setGoogleClientInfo()
   269  
   270  	client.internalClient = c
   271  
   272  	return &client, nil
   273  }
   274  
   275  // Connection returns a connection to the API service.
   276  //
   277  // Deprecated: Connections are now pooled so this method does not always
   278  // return the same resource.
   279  func (c *reasoningEngineExecutionGRPCClient) Connection() *grpc.ClientConn {
   280  	return c.connPool.Conn()
   281  }
   282  
   283  // setGoogleClientInfo sets the name and version of the application in
   284  // the `x-goog-api-client` header passed on each request. Intended for
   285  // use by Google-written clients.
   286  func (c *reasoningEngineExecutionGRPCClient) setGoogleClientInfo(keyval ...string) {
   287  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   288  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   289  	c.xGoogHeaders = []string{
   290  		"x-goog-api-client", gax.XGoogHeader(kv...),
   291  	}
   292  }
   293  
   294  // Close closes the connection to the API service. The user should invoke this when
   295  // the client is no longer required.
   296  func (c *reasoningEngineExecutionGRPCClient) Close() error {
   297  	return c.connPool.Close()
   298  }
   299  
   300  func (c *reasoningEngineExecutionGRPCClient) QueryReasoningEngine(ctx context.Context, req *aiplatformpb.QueryReasoningEngineRequest, opts ...gax.CallOption) (*aiplatformpb.QueryReasoningEngineResponse, error) {
   301  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   302  
   303  	hds = append(c.xGoogHeaders, hds...)
   304  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   305  	opts = append((*c.CallOptions).QueryReasoningEngine[0:len((*c.CallOptions).QueryReasoningEngine):len((*c.CallOptions).QueryReasoningEngine)], opts...)
   306  	var resp *aiplatformpb.QueryReasoningEngineResponse
   307  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   308  		var err error
   309  		resp, err = executeRPC(ctx, c.reasoningEngineExecutionClient.QueryReasoningEngine, req, settings.GRPC, c.logger, "QueryReasoningEngine")
   310  		return err
   311  	}, opts...)
   312  	if err != nil {
   313  		return nil, err
   314  	}
   315  	return resp, nil
   316  }
   317  
   318  func (c *reasoningEngineExecutionGRPCClient) StreamQueryReasoningEngine(ctx context.Context, req *aiplatformpb.StreamQueryReasoningEngineRequest, opts ...gax.CallOption) (aiplatformpb.ReasoningEngineExecutionService_StreamQueryReasoningEngineClient, error) {
   319  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   320  
   321  	hds = append(c.xGoogHeaders, hds...)
   322  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   323  	opts = append((*c.CallOptions).StreamQueryReasoningEngine[0:len((*c.CallOptions).StreamQueryReasoningEngine):len((*c.CallOptions).StreamQueryReasoningEngine)], opts...)
   324  	var resp aiplatformpb.ReasoningEngineExecutionService_StreamQueryReasoningEngineClient
   325  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   326  		var err error
   327  		c.logger.DebugContext(ctx, "api streaming client request", "serviceName", serviceName, "rpcName", "StreamQueryReasoningEngine")
   328  		resp, err = c.reasoningEngineExecutionClient.StreamQueryReasoningEngine(ctx, req, settings.GRPC...)
   329  		c.logger.DebugContext(ctx, "api streaming client response", "serviceName", serviceName, "rpcName", "StreamQueryReasoningEngine")
   330  		return err
   331  	}, opts...)
   332  	if err != nil {
   333  		return nil, err
   334  	}
   335  	return resp, nil
   336  }
   337  
   338  func (c *reasoningEngineExecutionGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   339  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   340  
   341  	hds = append(c.xGoogHeaders, hds...)
   342  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   343  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
   344  	var resp *locationpb.Location
   345  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   346  		var err error
   347  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
   348  		return err
   349  	}, opts...)
   350  	if err != nil {
   351  		return nil, err
   352  	}
   353  	return resp, nil
   354  }
   355  
   356  func (c *reasoningEngineExecutionGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   357  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   358  
   359  	hds = append(c.xGoogHeaders, hds...)
   360  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   361  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
   362  	it := &LocationIterator{}
   363  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
   364  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
   365  		resp := &locationpb.ListLocationsResponse{}
   366  		if pageToken != "" {
   367  			req.PageToken = pageToken
   368  		}
   369  		if pageSize > math.MaxInt32 {
   370  			req.PageSize = math.MaxInt32
   371  		} else if pageSize != 0 {
   372  			req.PageSize = int32(pageSize)
   373  		}
   374  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   375  			var err error
   376  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
   377  			return err
   378  		}, opts...)
   379  		if err != nil {
   380  			return nil, "", err
   381  		}
   382  
   383  		it.Response = resp
   384  		return resp.GetLocations(), resp.GetNextPageToken(), nil
   385  	}
   386  	fetch := func(pageSize int, pageToken string) (string, error) {
   387  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   388  		if err != nil {
   389  			return "", err
   390  		}
   391  		it.items = append(it.items, items...)
   392  		return nextPageToken, nil
   393  	}
   394  
   395  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   396  	it.pageInfo.MaxSize = int(req.GetPageSize())
   397  	it.pageInfo.Token = req.GetPageToken()
   398  
   399  	return it
   400  }
   401  
   402  func (c *reasoningEngineExecutionGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   403  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   404  
   405  	hds = append(c.xGoogHeaders, hds...)
   406  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   407  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
   408  	var resp *iampb.Policy
   409  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   410  		var err error
   411  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
   412  		return err
   413  	}, opts...)
   414  	if err != nil {
   415  		return nil, err
   416  	}
   417  	return resp, nil
   418  }
   419  
   420  func (c *reasoningEngineExecutionGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   421  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   422  
   423  	hds = append(c.xGoogHeaders, hds...)
   424  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   425  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
   426  	var resp *iampb.Policy
   427  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   428  		var err error
   429  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
   430  		return err
   431  	}, opts...)
   432  	if err != nil {
   433  		return nil, err
   434  	}
   435  	return resp, nil
   436  }
   437  
   438  func (c *reasoningEngineExecutionGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   439  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   440  
   441  	hds = append(c.xGoogHeaders, hds...)
   442  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   443  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
   444  	var resp *iampb.TestIamPermissionsResponse
   445  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   446  		var err error
   447  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
   448  		return err
   449  	}, opts...)
   450  	if err != nil {
   451  		return nil, err
   452  	}
   453  	return resp, nil
   454  }
   455  
   456  func (c *reasoningEngineExecutionGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   457  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   458  
   459  	hds = append(c.xGoogHeaders, hds...)
   460  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   461  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
   462  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   463  		var err error
   464  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
   465  		return err
   466  	}, opts...)
   467  	return err
   468  }
   469  
   470  func (c *reasoningEngineExecutionGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   471  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   472  
   473  	hds = append(c.xGoogHeaders, hds...)
   474  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   475  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
   476  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   477  		var err error
   478  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
   479  		return err
   480  	}, opts...)
   481  	return err
   482  }
   483  
   484  func (c *reasoningEngineExecutionGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   485  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   486  
   487  	hds = append(c.xGoogHeaders, hds...)
   488  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   489  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
   490  	var resp *longrunningpb.Operation
   491  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   492  		var err error
   493  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
   494  		return err
   495  	}, opts...)
   496  	if err != nil {
   497  		return nil, err
   498  	}
   499  	return resp, nil
   500  }
   501  
   502  func (c *reasoningEngineExecutionGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   503  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   504  
   505  	hds = append(c.xGoogHeaders, hds...)
   506  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   507  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
   508  	it := &OperationIterator{}
   509  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
   510  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
   511  		resp := &longrunningpb.ListOperationsResponse{}
   512  		if pageToken != "" {
   513  			req.PageToken = pageToken
   514  		}
   515  		if pageSize > math.MaxInt32 {
   516  			req.PageSize = math.MaxInt32
   517  		} else if pageSize != 0 {
   518  			req.PageSize = int32(pageSize)
   519  		}
   520  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   521  			var err error
   522  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
   523  			return err
   524  		}, opts...)
   525  		if err != nil {
   526  			return nil, "", err
   527  		}
   528  
   529  		it.Response = resp
   530  		return resp.GetOperations(), resp.GetNextPageToken(), nil
   531  	}
   532  	fetch := func(pageSize int, pageToken string) (string, error) {
   533  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   534  		if err != nil {
   535  			return "", err
   536  		}
   537  		it.items = append(it.items, items...)
   538  		return nextPageToken, nil
   539  	}
   540  
   541  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   542  	it.pageInfo.MaxSize = int(req.GetPageSize())
   543  	it.pageInfo.Token = req.GetPageToken()
   544  
   545  	return it
   546  }
   547  
   548  func (c *reasoningEngineExecutionGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   549  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   550  
   551  	hds = append(c.xGoogHeaders, hds...)
   552  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   553  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
   554  	var resp *longrunningpb.Operation
   555  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   556  		var err error
   557  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
   558  		return err
   559  	}, opts...)
   560  	if err != nil {
   561  		return nil, err
   562  	}
   563  	return resp, nil
   564  }