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