cloud.google.com/go/aiplatform@v1.106.0/apiv1/reasoning_engine_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  	"cloud.google.com/go/longrunning"
    29  	lroauto "cloud.google.com/go/longrunning/autogen"
    30  	longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
    31  	gax "github.com/googleapis/gax-go/v2"
    32  	"google.golang.org/api/iterator"
    33  	"google.golang.org/api/option"
    34  	"google.golang.org/api/option/internaloption"
    35  	gtransport "google.golang.org/api/transport/grpc"
    36  	locationpb "google.golang.org/genproto/googleapis/cloud/location"
    37  	"google.golang.org/grpc"
    38  	"google.golang.org/protobuf/proto"
    39  )
    40  
    41  var newReasoningEngineClientHook clientHook
    42  
    43  // ReasoningEngineCallOptions contains the retry settings for each method of ReasoningEngineClient.
    44  type ReasoningEngineCallOptions struct {
    45  	CreateReasoningEngine []gax.CallOption
    46  	GetReasoningEngine    []gax.CallOption
    47  	ListReasoningEngines  []gax.CallOption
    48  	UpdateReasoningEngine []gax.CallOption
    49  	DeleteReasoningEngine []gax.CallOption
    50  	GetLocation           []gax.CallOption
    51  	ListLocations         []gax.CallOption
    52  	GetIamPolicy          []gax.CallOption
    53  	SetIamPolicy          []gax.CallOption
    54  	TestIamPermissions    []gax.CallOption
    55  	CancelOperation       []gax.CallOption
    56  	DeleteOperation       []gax.CallOption
    57  	GetOperation          []gax.CallOption
    58  	ListOperations        []gax.CallOption
    59  	WaitOperation         []gax.CallOption
    60  }
    61  
    62  func defaultReasoningEngineGRPCClientOptions() []option.ClientOption {
    63  	return []option.ClientOption{
    64  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    65  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    66  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    67  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    68  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    69  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    70  		internaloption.EnableJwtWithScope(),
    71  		internaloption.EnableNewAuthLibrary(),
    72  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    73  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    74  	}
    75  }
    76  
    77  func defaultReasoningEngineCallOptions() *ReasoningEngineCallOptions {
    78  	return &ReasoningEngineCallOptions{
    79  		CreateReasoningEngine: []gax.CallOption{},
    80  		GetReasoningEngine:    []gax.CallOption{},
    81  		ListReasoningEngines:  []gax.CallOption{},
    82  		UpdateReasoningEngine: []gax.CallOption{},
    83  		DeleteReasoningEngine: []gax.CallOption{},
    84  		GetLocation:           []gax.CallOption{},
    85  		ListLocations:         []gax.CallOption{},
    86  		GetIamPolicy:          []gax.CallOption{},
    87  		SetIamPolicy:          []gax.CallOption{},
    88  		TestIamPermissions:    []gax.CallOption{},
    89  		CancelOperation:       []gax.CallOption{},
    90  		DeleteOperation:       []gax.CallOption{},
    91  		GetOperation:          []gax.CallOption{},
    92  		ListOperations:        []gax.CallOption{},
    93  		WaitOperation:         []gax.CallOption{},
    94  	}
    95  }
    96  
    97  // internalReasoningEngineClient is an interface that defines the methods available from Vertex AI API.
    98  type internalReasoningEngineClient interface {
    99  	Close() error
   100  	setGoogleClientInfo(...string)
   101  	Connection() *grpc.ClientConn
   102  	CreateReasoningEngine(context.Context, *aiplatformpb.CreateReasoningEngineRequest, ...gax.CallOption) (*CreateReasoningEngineOperation, error)
   103  	CreateReasoningEngineOperation(name string) *CreateReasoningEngineOperation
   104  	GetReasoningEngine(context.Context, *aiplatformpb.GetReasoningEngineRequest, ...gax.CallOption) (*aiplatformpb.ReasoningEngine, error)
   105  	ListReasoningEngines(context.Context, *aiplatformpb.ListReasoningEnginesRequest, ...gax.CallOption) *ReasoningEngineIterator
   106  	UpdateReasoningEngine(context.Context, *aiplatformpb.UpdateReasoningEngineRequest, ...gax.CallOption) (*UpdateReasoningEngineOperation, error)
   107  	UpdateReasoningEngineOperation(name string) *UpdateReasoningEngineOperation
   108  	DeleteReasoningEngine(context.Context, *aiplatformpb.DeleteReasoningEngineRequest, ...gax.CallOption) (*DeleteReasoningEngineOperation, error)
   109  	DeleteReasoningEngineOperation(name string) *DeleteReasoningEngineOperation
   110  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   111  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   112  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   113  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   114  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   115  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   116  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   117  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   118  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   119  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   120  }
   121  
   122  // ReasoningEngineClient is a client for interacting with Vertex AI API.
   123  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   124  //
   125  // A service for managing Vertex AI’s Reasoning Engines.
   126  type ReasoningEngineClient struct {
   127  	// The internal transport-dependent client.
   128  	internalClient internalReasoningEngineClient
   129  
   130  	// The call options for this service.
   131  	CallOptions *ReasoningEngineCallOptions
   132  
   133  	// LROClient is used internally to handle long-running operations.
   134  	// It is exposed so that its CallOptions can be modified if required.
   135  	// Users should not Close this client.
   136  	LROClient *lroauto.OperationsClient
   137  }
   138  
   139  // Wrapper methods routed to the internal client.
   140  
   141  // Close closes the connection to the API service. The user should invoke this when
   142  // the client is no longer required.
   143  func (c *ReasoningEngineClient) Close() error {
   144  	return c.internalClient.Close()
   145  }
   146  
   147  // setGoogleClientInfo sets the name and version of the application in
   148  // the `x-goog-api-client` header passed on each request. Intended for
   149  // use by Google-written clients.
   150  func (c *ReasoningEngineClient) setGoogleClientInfo(keyval ...string) {
   151  	c.internalClient.setGoogleClientInfo(keyval...)
   152  }
   153  
   154  // Connection returns a connection to the API service.
   155  //
   156  // Deprecated: Connections are now pooled so this method does not always
   157  // return the same resource.
   158  func (c *ReasoningEngineClient) Connection() *grpc.ClientConn {
   159  	return c.internalClient.Connection()
   160  }
   161  
   162  // CreateReasoningEngine creates a reasoning engine.
   163  func (c *ReasoningEngineClient) CreateReasoningEngine(ctx context.Context, req *aiplatformpb.CreateReasoningEngineRequest, opts ...gax.CallOption) (*CreateReasoningEngineOperation, error) {
   164  	return c.internalClient.CreateReasoningEngine(ctx, req, opts...)
   165  }
   166  
   167  // CreateReasoningEngineOperation returns a new CreateReasoningEngineOperation from a given name.
   168  // The name must be that of a previously created CreateReasoningEngineOperation, possibly from a different process.
   169  func (c *ReasoningEngineClient) CreateReasoningEngineOperation(name string) *CreateReasoningEngineOperation {
   170  	return c.internalClient.CreateReasoningEngineOperation(name)
   171  }
   172  
   173  // GetReasoningEngine gets a reasoning engine.
   174  func (c *ReasoningEngineClient) GetReasoningEngine(ctx context.Context, req *aiplatformpb.GetReasoningEngineRequest, opts ...gax.CallOption) (*aiplatformpb.ReasoningEngine, error) {
   175  	return c.internalClient.GetReasoningEngine(ctx, req, opts...)
   176  }
   177  
   178  // ListReasoningEngines lists reasoning engines in a location.
   179  func (c *ReasoningEngineClient) ListReasoningEngines(ctx context.Context, req *aiplatformpb.ListReasoningEnginesRequest, opts ...gax.CallOption) *ReasoningEngineIterator {
   180  	return c.internalClient.ListReasoningEngines(ctx, req, opts...)
   181  }
   182  
   183  // UpdateReasoningEngine updates a reasoning engine.
   184  func (c *ReasoningEngineClient) UpdateReasoningEngine(ctx context.Context, req *aiplatformpb.UpdateReasoningEngineRequest, opts ...gax.CallOption) (*UpdateReasoningEngineOperation, error) {
   185  	return c.internalClient.UpdateReasoningEngine(ctx, req, opts...)
   186  }
   187  
   188  // UpdateReasoningEngineOperation returns a new UpdateReasoningEngineOperation from a given name.
   189  // The name must be that of a previously created UpdateReasoningEngineOperation, possibly from a different process.
   190  func (c *ReasoningEngineClient) UpdateReasoningEngineOperation(name string) *UpdateReasoningEngineOperation {
   191  	return c.internalClient.UpdateReasoningEngineOperation(name)
   192  }
   193  
   194  // DeleteReasoningEngine deletes a reasoning engine.
   195  func (c *ReasoningEngineClient) DeleteReasoningEngine(ctx context.Context, req *aiplatformpb.DeleteReasoningEngineRequest, opts ...gax.CallOption) (*DeleteReasoningEngineOperation, error) {
   196  	return c.internalClient.DeleteReasoningEngine(ctx, req, opts...)
   197  }
   198  
   199  // DeleteReasoningEngineOperation returns a new DeleteReasoningEngineOperation from a given name.
   200  // The name must be that of a previously created DeleteReasoningEngineOperation, possibly from a different process.
   201  func (c *ReasoningEngineClient) DeleteReasoningEngineOperation(name string) *DeleteReasoningEngineOperation {
   202  	return c.internalClient.DeleteReasoningEngineOperation(name)
   203  }
   204  
   205  // GetLocation gets information about a location.
   206  func (c *ReasoningEngineClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   207  	return c.internalClient.GetLocation(ctx, req, opts...)
   208  }
   209  
   210  // ListLocations lists information about the supported locations for this service.
   211  func (c *ReasoningEngineClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   212  	return c.internalClient.ListLocations(ctx, req, opts...)
   213  }
   214  
   215  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   216  // if the resource exists and does not have a policy set.
   217  func (c *ReasoningEngineClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   218  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   219  }
   220  
   221  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   222  // any existing policy.
   223  //
   224  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   225  // errors.
   226  func (c *ReasoningEngineClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   227  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   228  }
   229  
   230  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   231  // resource does not exist, this will return an empty set of
   232  // permissions, not a NOT_FOUND error.
   233  //
   234  // Note: This operation is designed to be used for building
   235  // permission-aware UIs and command-line tools, not for authorization
   236  // checking. This operation may “fail open” without warning.
   237  func (c *ReasoningEngineClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   238  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   239  }
   240  
   241  // CancelOperation is a utility method from google.longrunning.Operations.
   242  func (c *ReasoningEngineClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   243  	return c.internalClient.CancelOperation(ctx, req, opts...)
   244  }
   245  
   246  // DeleteOperation is a utility method from google.longrunning.Operations.
   247  func (c *ReasoningEngineClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   248  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   249  }
   250  
   251  // GetOperation is a utility method from google.longrunning.Operations.
   252  func (c *ReasoningEngineClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   253  	return c.internalClient.GetOperation(ctx, req, opts...)
   254  }
   255  
   256  // ListOperations is a utility method from google.longrunning.Operations.
   257  func (c *ReasoningEngineClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   258  	return c.internalClient.ListOperations(ctx, req, opts...)
   259  }
   260  
   261  // WaitOperation is a utility method from google.longrunning.Operations.
   262  func (c *ReasoningEngineClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   263  	return c.internalClient.WaitOperation(ctx, req, opts...)
   264  }
   265  
   266  // reasoningEngineGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   267  //
   268  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   269  type reasoningEngineGRPCClient struct {
   270  	// Connection pool of gRPC connections to the service.
   271  	connPool gtransport.ConnPool
   272  
   273  	// Points back to the CallOptions field of the containing ReasoningEngineClient
   274  	CallOptions **ReasoningEngineCallOptions
   275  
   276  	// The gRPC API client.
   277  	reasoningEngineClient aiplatformpb.ReasoningEngineServiceClient
   278  
   279  	// LROClient is used internally to handle long-running operations.
   280  	// It is exposed so that its CallOptions can be modified if required.
   281  	// Users should not Close this client.
   282  	LROClient **lroauto.OperationsClient
   283  
   284  	operationsClient longrunningpb.OperationsClient
   285  
   286  	iamPolicyClient iampb.IAMPolicyClient
   287  
   288  	locationsClient locationpb.LocationsClient
   289  
   290  	// The x-goog-* metadata to be sent with each request.
   291  	xGoogHeaders []string
   292  
   293  	logger *slog.Logger
   294  }
   295  
   296  // NewReasoningEngineClient creates a new reasoning engine service client based on gRPC.
   297  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   298  //
   299  // A service for managing Vertex AI’s Reasoning Engines.
   300  func NewReasoningEngineClient(ctx context.Context, opts ...option.ClientOption) (*ReasoningEngineClient, error) {
   301  	clientOpts := defaultReasoningEngineGRPCClientOptions()
   302  	if newReasoningEngineClientHook != nil {
   303  		hookOpts, err := newReasoningEngineClientHook(ctx, clientHookParams{})
   304  		if err != nil {
   305  			return nil, err
   306  		}
   307  		clientOpts = append(clientOpts, hookOpts...)
   308  	}
   309  
   310  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   311  	if err != nil {
   312  		return nil, err
   313  	}
   314  	client := ReasoningEngineClient{CallOptions: defaultReasoningEngineCallOptions()}
   315  
   316  	c := &reasoningEngineGRPCClient{
   317  		connPool:              connPool,
   318  		reasoningEngineClient: aiplatformpb.NewReasoningEngineServiceClient(connPool),
   319  		CallOptions:           &client.CallOptions,
   320  		logger:                internaloption.GetLogger(opts),
   321  		operationsClient:      longrunningpb.NewOperationsClient(connPool),
   322  		iamPolicyClient:       iampb.NewIAMPolicyClient(connPool),
   323  		locationsClient:       locationpb.NewLocationsClient(connPool),
   324  	}
   325  	c.setGoogleClientInfo()
   326  
   327  	client.internalClient = c
   328  
   329  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   330  	if err != nil {
   331  		// This error "should not happen", since we are just reusing old connection pool
   332  		// and never actually need to dial.
   333  		// If this does happen, we could leak connp. However, we cannot close conn:
   334  		// If the user invoked the constructor with option.WithGRPCConn,
   335  		// we would close a connection that's still in use.
   336  		// TODO: investigate error conditions.
   337  		return nil, err
   338  	}
   339  	c.LROClient = &client.LROClient
   340  	return &client, nil
   341  }
   342  
   343  // Connection returns a connection to the API service.
   344  //
   345  // Deprecated: Connections are now pooled so this method does not always
   346  // return the same resource.
   347  func (c *reasoningEngineGRPCClient) Connection() *grpc.ClientConn {
   348  	return c.connPool.Conn()
   349  }
   350  
   351  // setGoogleClientInfo sets the name and version of the application in
   352  // the `x-goog-api-client` header passed on each request. Intended for
   353  // use by Google-written clients.
   354  func (c *reasoningEngineGRPCClient) setGoogleClientInfo(keyval ...string) {
   355  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   356  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   357  	c.xGoogHeaders = []string{
   358  		"x-goog-api-client", gax.XGoogHeader(kv...),
   359  	}
   360  }
   361  
   362  // Close closes the connection to the API service. The user should invoke this when
   363  // the client is no longer required.
   364  func (c *reasoningEngineGRPCClient) Close() error {
   365  	return c.connPool.Close()
   366  }
   367  
   368  func (c *reasoningEngineGRPCClient) CreateReasoningEngine(ctx context.Context, req *aiplatformpb.CreateReasoningEngineRequest, opts ...gax.CallOption) (*CreateReasoningEngineOperation, error) {
   369  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   370  
   371  	hds = append(c.xGoogHeaders, hds...)
   372  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   373  	opts = append((*c.CallOptions).CreateReasoningEngine[0:len((*c.CallOptions).CreateReasoningEngine):len((*c.CallOptions).CreateReasoningEngine)], opts...)
   374  	var resp *longrunningpb.Operation
   375  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   376  		var err error
   377  		resp, err = executeRPC(ctx, c.reasoningEngineClient.CreateReasoningEngine, req, settings.GRPC, c.logger, "CreateReasoningEngine")
   378  		return err
   379  	}, opts...)
   380  	if err != nil {
   381  		return nil, err
   382  	}
   383  	return &CreateReasoningEngineOperation{
   384  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   385  	}, nil
   386  }
   387  
   388  func (c *reasoningEngineGRPCClient) GetReasoningEngine(ctx context.Context, req *aiplatformpb.GetReasoningEngineRequest, opts ...gax.CallOption) (*aiplatformpb.ReasoningEngine, error) {
   389  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   390  
   391  	hds = append(c.xGoogHeaders, hds...)
   392  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   393  	opts = append((*c.CallOptions).GetReasoningEngine[0:len((*c.CallOptions).GetReasoningEngine):len((*c.CallOptions).GetReasoningEngine)], opts...)
   394  	var resp *aiplatformpb.ReasoningEngine
   395  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   396  		var err error
   397  		resp, err = executeRPC(ctx, c.reasoningEngineClient.GetReasoningEngine, req, settings.GRPC, c.logger, "GetReasoningEngine")
   398  		return err
   399  	}, opts...)
   400  	if err != nil {
   401  		return nil, err
   402  	}
   403  	return resp, nil
   404  }
   405  
   406  func (c *reasoningEngineGRPCClient) ListReasoningEngines(ctx context.Context, req *aiplatformpb.ListReasoningEnginesRequest, opts ...gax.CallOption) *ReasoningEngineIterator {
   407  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   408  
   409  	hds = append(c.xGoogHeaders, hds...)
   410  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   411  	opts = append((*c.CallOptions).ListReasoningEngines[0:len((*c.CallOptions).ListReasoningEngines):len((*c.CallOptions).ListReasoningEngines)], opts...)
   412  	it := &ReasoningEngineIterator{}
   413  	req = proto.Clone(req).(*aiplatformpb.ListReasoningEnginesRequest)
   414  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.ReasoningEngine, string, error) {
   415  		resp := &aiplatformpb.ListReasoningEnginesResponse{}
   416  		if pageToken != "" {
   417  			req.PageToken = pageToken
   418  		}
   419  		if pageSize > math.MaxInt32 {
   420  			req.PageSize = math.MaxInt32
   421  		} else if pageSize != 0 {
   422  			req.PageSize = int32(pageSize)
   423  		}
   424  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   425  			var err error
   426  			resp, err = executeRPC(ctx, c.reasoningEngineClient.ListReasoningEngines, req, settings.GRPC, c.logger, "ListReasoningEngines")
   427  			return err
   428  		}, opts...)
   429  		if err != nil {
   430  			return nil, "", err
   431  		}
   432  
   433  		it.Response = resp
   434  		return resp.GetReasoningEngines(), resp.GetNextPageToken(), nil
   435  	}
   436  	fetch := func(pageSize int, pageToken string) (string, error) {
   437  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   438  		if err != nil {
   439  			return "", err
   440  		}
   441  		it.items = append(it.items, items...)
   442  		return nextPageToken, nil
   443  	}
   444  
   445  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   446  	it.pageInfo.MaxSize = int(req.GetPageSize())
   447  	it.pageInfo.Token = req.GetPageToken()
   448  
   449  	return it
   450  }
   451  
   452  func (c *reasoningEngineGRPCClient) UpdateReasoningEngine(ctx context.Context, req *aiplatformpb.UpdateReasoningEngineRequest, opts ...gax.CallOption) (*UpdateReasoningEngineOperation, error) {
   453  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "reasoning_engine.name", url.QueryEscape(req.GetReasoningEngine().GetName()))}
   454  
   455  	hds = append(c.xGoogHeaders, hds...)
   456  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   457  	opts = append((*c.CallOptions).UpdateReasoningEngine[0:len((*c.CallOptions).UpdateReasoningEngine):len((*c.CallOptions).UpdateReasoningEngine)], opts...)
   458  	var resp *longrunningpb.Operation
   459  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   460  		var err error
   461  		resp, err = executeRPC(ctx, c.reasoningEngineClient.UpdateReasoningEngine, req, settings.GRPC, c.logger, "UpdateReasoningEngine")
   462  		return err
   463  	}, opts...)
   464  	if err != nil {
   465  		return nil, err
   466  	}
   467  	return &UpdateReasoningEngineOperation{
   468  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   469  	}, nil
   470  }
   471  
   472  func (c *reasoningEngineGRPCClient) DeleteReasoningEngine(ctx context.Context, req *aiplatformpb.DeleteReasoningEngineRequest, opts ...gax.CallOption) (*DeleteReasoningEngineOperation, error) {
   473  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   474  
   475  	hds = append(c.xGoogHeaders, hds...)
   476  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   477  	opts = append((*c.CallOptions).DeleteReasoningEngine[0:len((*c.CallOptions).DeleteReasoningEngine):len((*c.CallOptions).DeleteReasoningEngine)], opts...)
   478  	var resp *longrunningpb.Operation
   479  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   480  		var err error
   481  		resp, err = executeRPC(ctx, c.reasoningEngineClient.DeleteReasoningEngine, req, settings.GRPC, c.logger, "DeleteReasoningEngine")
   482  		return err
   483  	}, opts...)
   484  	if err != nil {
   485  		return nil, err
   486  	}
   487  	return &DeleteReasoningEngineOperation{
   488  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   489  	}, nil
   490  }
   491  
   492  func (c *reasoningEngineGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   493  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   494  
   495  	hds = append(c.xGoogHeaders, hds...)
   496  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   497  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
   498  	var resp *locationpb.Location
   499  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   500  		var err error
   501  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
   502  		return err
   503  	}, opts...)
   504  	if err != nil {
   505  		return nil, err
   506  	}
   507  	return resp, nil
   508  }
   509  
   510  func (c *reasoningEngineGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   511  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   512  
   513  	hds = append(c.xGoogHeaders, hds...)
   514  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   515  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
   516  	it := &LocationIterator{}
   517  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
   518  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
   519  		resp := &locationpb.ListLocationsResponse{}
   520  		if pageToken != "" {
   521  			req.PageToken = pageToken
   522  		}
   523  		if pageSize > math.MaxInt32 {
   524  			req.PageSize = math.MaxInt32
   525  		} else if pageSize != 0 {
   526  			req.PageSize = int32(pageSize)
   527  		}
   528  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   529  			var err error
   530  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
   531  			return err
   532  		}, opts...)
   533  		if err != nil {
   534  			return nil, "", err
   535  		}
   536  
   537  		it.Response = resp
   538  		return resp.GetLocations(), resp.GetNextPageToken(), nil
   539  	}
   540  	fetch := func(pageSize int, pageToken string) (string, error) {
   541  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   542  		if err != nil {
   543  			return "", err
   544  		}
   545  		it.items = append(it.items, items...)
   546  		return nextPageToken, nil
   547  	}
   548  
   549  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   550  	it.pageInfo.MaxSize = int(req.GetPageSize())
   551  	it.pageInfo.Token = req.GetPageToken()
   552  
   553  	return it
   554  }
   555  
   556  func (c *reasoningEngineGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   557  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   558  
   559  	hds = append(c.xGoogHeaders, hds...)
   560  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   561  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
   562  	var resp *iampb.Policy
   563  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   564  		var err error
   565  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
   566  		return err
   567  	}, opts...)
   568  	if err != nil {
   569  		return nil, err
   570  	}
   571  	return resp, nil
   572  }
   573  
   574  func (c *reasoningEngineGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   575  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   576  
   577  	hds = append(c.xGoogHeaders, hds...)
   578  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   579  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
   580  	var resp *iampb.Policy
   581  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   582  		var err error
   583  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
   584  		return err
   585  	}, opts...)
   586  	if err != nil {
   587  		return nil, err
   588  	}
   589  	return resp, nil
   590  }
   591  
   592  func (c *reasoningEngineGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   593  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
   594  
   595  	hds = append(c.xGoogHeaders, hds...)
   596  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   597  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
   598  	var resp *iampb.TestIamPermissionsResponse
   599  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   600  		var err error
   601  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
   602  		return err
   603  	}, opts...)
   604  	if err != nil {
   605  		return nil, err
   606  	}
   607  	return resp, nil
   608  }
   609  
   610  func (c *reasoningEngineGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   611  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   612  
   613  	hds = append(c.xGoogHeaders, hds...)
   614  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   615  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
   616  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   617  		var err error
   618  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
   619  		return err
   620  	}, opts...)
   621  	return err
   622  }
   623  
   624  func (c *reasoningEngineGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   625  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   626  
   627  	hds = append(c.xGoogHeaders, hds...)
   628  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   629  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
   630  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   631  		var err error
   632  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
   633  		return err
   634  	}, opts...)
   635  	return err
   636  }
   637  
   638  func (c *reasoningEngineGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   639  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   640  
   641  	hds = append(c.xGoogHeaders, hds...)
   642  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   643  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
   644  	var resp *longrunningpb.Operation
   645  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   646  		var err error
   647  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
   648  		return err
   649  	}, opts...)
   650  	if err != nil {
   651  		return nil, err
   652  	}
   653  	return resp, nil
   654  }
   655  
   656  func (c *reasoningEngineGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   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).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
   662  	it := &OperationIterator{}
   663  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
   664  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
   665  		resp := &longrunningpb.ListOperationsResponse{}
   666  		if pageToken != "" {
   667  			req.PageToken = pageToken
   668  		}
   669  		if pageSize > math.MaxInt32 {
   670  			req.PageSize = math.MaxInt32
   671  		} else if pageSize != 0 {
   672  			req.PageSize = int32(pageSize)
   673  		}
   674  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   675  			var err error
   676  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
   677  			return err
   678  		}, opts...)
   679  		if err != nil {
   680  			return nil, "", err
   681  		}
   682  
   683  		it.Response = resp
   684  		return resp.GetOperations(), resp.GetNextPageToken(), nil
   685  	}
   686  	fetch := func(pageSize int, pageToken string) (string, error) {
   687  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   688  		if err != nil {
   689  			return "", err
   690  		}
   691  		it.items = append(it.items, items...)
   692  		return nextPageToken, nil
   693  	}
   694  
   695  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   696  	it.pageInfo.MaxSize = int(req.GetPageSize())
   697  	it.pageInfo.Token = req.GetPageToken()
   698  
   699  	return it
   700  }
   701  
   702  func (c *reasoningEngineGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   703  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   704  
   705  	hds = append(c.xGoogHeaders, hds...)
   706  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   707  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
   708  	var resp *longrunningpb.Operation
   709  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   710  		var err error
   711  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
   712  		return err
   713  	}, opts...)
   714  	if err != nil {
   715  		return nil, err
   716  	}
   717  	return resp, nil
   718  }
   719  
   720  // CreateReasoningEngineOperation returns a new CreateReasoningEngineOperation from a given name.
   721  // The name must be that of a previously created CreateReasoningEngineOperation, possibly from a different process.
   722  func (c *reasoningEngineGRPCClient) CreateReasoningEngineOperation(name string) *CreateReasoningEngineOperation {
   723  	return &CreateReasoningEngineOperation{
   724  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
   725  	}
   726  }
   727  
   728  // DeleteReasoningEngineOperation returns a new DeleteReasoningEngineOperation from a given name.
   729  // The name must be that of a previously created DeleteReasoningEngineOperation, possibly from a different process.
   730  func (c *reasoningEngineGRPCClient) DeleteReasoningEngineOperation(name string) *DeleteReasoningEngineOperation {
   731  	return &DeleteReasoningEngineOperation{
   732  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
   733  	}
   734  }
   735  
   736  // UpdateReasoningEngineOperation returns a new UpdateReasoningEngineOperation from a given name.
   737  // The name must be that of a previously created UpdateReasoningEngineOperation, possibly from a different process.
   738  func (c *reasoningEngineGRPCClient) UpdateReasoningEngineOperation(name string) *UpdateReasoningEngineOperation {
   739  	return &UpdateReasoningEngineOperation{
   740  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
   741  	}
   742  }