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