cloud.google.com/go/aiplatform@v1.106.0/apiv1beta1/notebook_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 newNotebookClientHook clientHook
    46  
    47  // NotebookCallOptions contains the retry settings for each method of NotebookClient.
    48  type NotebookCallOptions struct {
    49  	CreateNotebookRuntimeTemplate []gax.CallOption
    50  	GetNotebookRuntimeTemplate    []gax.CallOption
    51  	ListNotebookRuntimeTemplates  []gax.CallOption
    52  	DeleteNotebookRuntimeTemplate []gax.CallOption
    53  	UpdateNotebookRuntimeTemplate []gax.CallOption
    54  	AssignNotebookRuntime         []gax.CallOption
    55  	GetNotebookRuntime            []gax.CallOption
    56  	ListNotebookRuntimes          []gax.CallOption
    57  	DeleteNotebookRuntime         []gax.CallOption
    58  	UpgradeNotebookRuntime        []gax.CallOption
    59  	StartNotebookRuntime          []gax.CallOption
    60  	StopNotebookRuntime           []gax.CallOption
    61  	CreateNotebookExecutionJob    []gax.CallOption
    62  	GetNotebookExecutionJob       []gax.CallOption
    63  	ListNotebookExecutionJobs     []gax.CallOption
    64  	DeleteNotebookExecutionJob    []gax.CallOption
    65  	GetLocation                   []gax.CallOption
    66  	ListLocations                 []gax.CallOption
    67  	GetIamPolicy                  []gax.CallOption
    68  	SetIamPolicy                  []gax.CallOption
    69  	TestIamPermissions            []gax.CallOption
    70  	CancelOperation               []gax.CallOption
    71  	DeleteOperation               []gax.CallOption
    72  	GetOperation                  []gax.CallOption
    73  	ListOperations                []gax.CallOption
    74  	WaitOperation                 []gax.CallOption
    75  }
    76  
    77  func defaultNotebookGRPCClientOptions() []option.ClientOption {
    78  	return []option.ClientOption{
    79  		internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"),
    80  		internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"),
    81  		internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"),
    82  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
    83  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
    84  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
    85  		internaloption.EnableJwtWithScope(),
    86  		internaloption.EnableNewAuthLibrary(),
    87  		option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
    88  			grpc.MaxCallRecvMsgSize(math.MaxInt32))),
    89  	}
    90  }
    91  
    92  func defaultNotebookCallOptions() *NotebookCallOptions {
    93  	return &NotebookCallOptions{
    94  		CreateNotebookRuntimeTemplate: []gax.CallOption{},
    95  		GetNotebookRuntimeTemplate:    []gax.CallOption{},
    96  		ListNotebookRuntimeTemplates:  []gax.CallOption{},
    97  		DeleteNotebookRuntimeTemplate: []gax.CallOption{},
    98  		UpdateNotebookRuntimeTemplate: []gax.CallOption{},
    99  		AssignNotebookRuntime:         []gax.CallOption{},
   100  		GetNotebookRuntime:            []gax.CallOption{},
   101  		ListNotebookRuntimes:          []gax.CallOption{},
   102  		DeleteNotebookRuntime:         []gax.CallOption{},
   103  		UpgradeNotebookRuntime:        []gax.CallOption{},
   104  		StartNotebookRuntime:          []gax.CallOption{},
   105  		StopNotebookRuntime:           []gax.CallOption{},
   106  		CreateNotebookExecutionJob:    []gax.CallOption{},
   107  		GetNotebookExecutionJob:       []gax.CallOption{},
   108  		ListNotebookExecutionJobs:     []gax.CallOption{},
   109  		DeleteNotebookExecutionJob:    []gax.CallOption{},
   110  		GetLocation:                   []gax.CallOption{},
   111  		ListLocations:                 []gax.CallOption{},
   112  		GetIamPolicy:                  []gax.CallOption{},
   113  		SetIamPolicy:                  []gax.CallOption{},
   114  		TestIamPermissions:            []gax.CallOption{},
   115  		CancelOperation:               []gax.CallOption{},
   116  		DeleteOperation:               []gax.CallOption{},
   117  		GetOperation:                  []gax.CallOption{},
   118  		ListOperations:                []gax.CallOption{},
   119  		WaitOperation:                 []gax.CallOption{},
   120  	}
   121  }
   122  
   123  func defaultNotebookRESTCallOptions() *NotebookCallOptions {
   124  	return &NotebookCallOptions{
   125  		CreateNotebookRuntimeTemplate: []gax.CallOption{},
   126  		GetNotebookRuntimeTemplate:    []gax.CallOption{},
   127  		ListNotebookRuntimeTemplates:  []gax.CallOption{},
   128  		DeleteNotebookRuntimeTemplate: []gax.CallOption{},
   129  		UpdateNotebookRuntimeTemplate: []gax.CallOption{},
   130  		AssignNotebookRuntime:         []gax.CallOption{},
   131  		GetNotebookRuntime:            []gax.CallOption{},
   132  		ListNotebookRuntimes:          []gax.CallOption{},
   133  		DeleteNotebookRuntime:         []gax.CallOption{},
   134  		UpgradeNotebookRuntime:        []gax.CallOption{},
   135  		StartNotebookRuntime:          []gax.CallOption{},
   136  		StopNotebookRuntime:           []gax.CallOption{},
   137  		CreateNotebookExecutionJob:    []gax.CallOption{},
   138  		GetNotebookExecutionJob:       []gax.CallOption{},
   139  		ListNotebookExecutionJobs:     []gax.CallOption{},
   140  		DeleteNotebookExecutionJob:    []gax.CallOption{},
   141  		GetLocation:                   []gax.CallOption{},
   142  		ListLocations:                 []gax.CallOption{},
   143  		GetIamPolicy:                  []gax.CallOption{},
   144  		SetIamPolicy:                  []gax.CallOption{},
   145  		TestIamPermissions:            []gax.CallOption{},
   146  		CancelOperation:               []gax.CallOption{},
   147  		DeleteOperation:               []gax.CallOption{},
   148  		GetOperation:                  []gax.CallOption{},
   149  		ListOperations:                []gax.CallOption{},
   150  		WaitOperation:                 []gax.CallOption{},
   151  	}
   152  }
   153  
   154  // internalNotebookClient is an interface that defines the methods available from Vertex AI API.
   155  type internalNotebookClient interface {
   156  	Close() error
   157  	setGoogleClientInfo(...string)
   158  	Connection() *grpc.ClientConn
   159  	CreateNotebookRuntimeTemplate(context.Context, *aiplatformpb.CreateNotebookRuntimeTemplateRequest, ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error)
   160  	CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation
   161  	GetNotebookRuntimeTemplate(context.Context, *aiplatformpb.GetNotebookRuntimeTemplateRequest, ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error)
   162  	ListNotebookRuntimeTemplates(context.Context, *aiplatformpb.ListNotebookRuntimeTemplatesRequest, ...gax.CallOption) *NotebookRuntimeTemplateIterator
   163  	DeleteNotebookRuntimeTemplate(context.Context, *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error)
   164  	DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation
   165  	UpdateNotebookRuntimeTemplate(context.Context, *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error)
   166  	AssignNotebookRuntime(context.Context, *aiplatformpb.AssignNotebookRuntimeRequest, ...gax.CallOption) (*AssignNotebookRuntimeOperation, error)
   167  	AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation
   168  	GetNotebookRuntime(context.Context, *aiplatformpb.GetNotebookRuntimeRequest, ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error)
   169  	ListNotebookRuntimes(context.Context, *aiplatformpb.ListNotebookRuntimesRequest, ...gax.CallOption) *NotebookRuntimeIterator
   170  	DeleteNotebookRuntime(context.Context, *aiplatformpb.DeleteNotebookRuntimeRequest, ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error)
   171  	DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation
   172  	UpgradeNotebookRuntime(context.Context, *aiplatformpb.UpgradeNotebookRuntimeRequest, ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error)
   173  	UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation
   174  	StartNotebookRuntime(context.Context, *aiplatformpb.StartNotebookRuntimeRequest, ...gax.CallOption) (*StartNotebookRuntimeOperation, error)
   175  	StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation
   176  	StopNotebookRuntime(context.Context, *aiplatformpb.StopNotebookRuntimeRequest, ...gax.CallOption) (*StopNotebookRuntimeOperation, error)
   177  	StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation
   178  	CreateNotebookExecutionJob(context.Context, *aiplatformpb.CreateNotebookExecutionJobRequest, ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error)
   179  	CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation
   180  	GetNotebookExecutionJob(context.Context, *aiplatformpb.GetNotebookExecutionJobRequest, ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error)
   181  	ListNotebookExecutionJobs(context.Context, *aiplatformpb.ListNotebookExecutionJobsRequest, ...gax.CallOption) *NotebookExecutionJobIterator
   182  	DeleteNotebookExecutionJob(context.Context, *aiplatformpb.DeleteNotebookExecutionJobRequest, ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error)
   183  	DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation
   184  	GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
   185  	ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
   186  	GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   187  	SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
   188  	TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
   189  	CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
   190  	DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
   191  	GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   192  	ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
   193  	WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
   194  }
   195  
   196  // NotebookClient is a client for interacting with Vertex AI API.
   197  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   198  //
   199  // The interface for Vertex Notebook service (a.k.a. Colab on Workbench).
   200  type NotebookClient struct {
   201  	// The internal transport-dependent client.
   202  	internalClient internalNotebookClient
   203  
   204  	// The call options for this service.
   205  	CallOptions *NotebookCallOptions
   206  
   207  	// LROClient is used internally to handle long-running operations.
   208  	// It is exposed so that its CallOptions can be modified if required.
   209  	// Users should not Close this client.
   210  	LROClient *lroauto.OperationsClient
   211  }
   212  
   213  // Wrapper methods routed to the internal client.
   214  
   215  // Close closes the connection to the API service. The user should invoke this when
   216  // the client is no longer required.
   217  func (c *NotebookClient) Close() error {
   218  	return c.internalClient.Close()
   219  }
   220  
   221  // setGoogleClientInfo sets the name and version of the application in
   222  // the `x-goog-api-client` header passed on each request. Intended for
   223  // use by Google-written clients.
   224  func (c *NotebookClient) setGoogleClientInfo(keyval ...string) {
   225  	c.internalClient.setGoogleClientInfo(keyval...)
   226  }
   227  
   228  // Connection returns a connection to the API service.
   229  //
   230  // Deprecated: Connections are now pooled so this method does not always
   231  // return the same resource.
   232  func (c *NotebookClient) Connection() *grpc.ClientConn {
   233  	return c.internalClient.Connection()
   234  }
   235  
   236  // CreateNotebookRuntimeTemplate creates a NotebookRuntimeTemplate.
   237  func (c *NotebookClient) CreateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.CreateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error) {
   238  	return c.internalClient.CreateNotebookRuntimeTemplate(ctx, req, opts...)
   239  }
   240  
   241  // CreateNotebookRuntimeTemplateOperation returns a new CreateNotebookRuntimeTemplateOperation from a given name.
   242  // The name must be that of a previously created CreateNotebookRuntimeTemplateOperation, possibly from a different process.
   243  func (c *NotebookClient) CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation {
   244  	return c.internalClient.CreateNotebookRuntimeTemplateOperation(name)
   245  }
   246  
   247  // GetNotebookRuntimeTemplate gets a NotebookRuntimeTemplate.
   248  func (c *NotebookClient) GetNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) {
   249  	return c.internalClient.GetNotebookRuntimeTemplate(ctx, req, opts...)
   250  }
   251  
   252  // ListNotebookRuntimeTemplates lists NotebookRuntimeTemplates in a Location.
   253  func (c *NotebookClient) ListNotebookRuntimeTemplates(ctx context.Context, req *aiplatformpb.ListNotebookRuntimeTemplatesRequest, opts ...gax.CallOption) *NotebookRuntimeTemplateIterator {
   254  	return c.internalClient.ListNotebookRuntimeTemplates(ctx, req, opts...)
   255  }
   256  
   257  // DeleteNotebookRuntimeTemplate deletes a NotebookRuntimeTemplate.
   258  func (c *NotebookClient) DeleteNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error) {
   259  	return c.internalClient.DeleteNotebookRuntimeTemplate(ctx, req, opts...)
   260  }
   261  
   262  // DeleteNotebookRuntimeTemplateOperation returns a new DeleteNotebookRuntimeTemplateOperation from a given name.
   263  // The name must be that of a previously created DeleteNotebookRuntimeTemplateOperation, possibly from a different process.
   264  func (c *NotebookClient) DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation {
   265  	return c.internalClient.DeleteNotebookRuntimeTemplateOperation(name)
   266  }
   267  
   268  // UpdateNotebookRuntimeTemplate updates a NotebookRuntimeTemplate.
   269  func (c *NotebookClient) UpdateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) {
   270  	return c.internalClient.UpdateNotebookRuntimeTemplate(ctx, req, opts...)
   271  }
   272  
   273  // AssignNotebookRuntime assigns a NotebookRuntime to a user for a particular Notebook file. This
   274  // method will either returns an existing assignment or generates a new one.
   275  func (c *NotebookClient) AssignNotebookRuntime(ctx context.Context, req *aiplatformpb.AssignNotebookRuntimeRequest, opts ...gax.CallOption) (*AssignNotebookRuntimeOperation, error) {
   276  	return c.internalClient.AssignNotebookRuntime(ctx, req, opts...)
   277  }
   278  
   279  // AssignNotebookRuntimeOperation returns a new AssignNotebookRuntimeOperation from a given name.
   280  // The name must be that of a previously created AssignNotebookRuntimeOperation, possibly from a different process.
   281  func (c *NotebookClient) AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation {
   282  	return c.internalClient.AssignNotebookRuntimeOperation(name)
   283  }
   284  
   285  // GetNotebookRuntime gets a NotebookRuntime.
   286  func (c *NotebookClient) GetNotebookRuntime(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error) {
   287  	return c.internalClient.GetNotebookRuntime(ctx, req, opts...)
   288  }
   289  
   290  // ListNotebookRuntimes lists NotebookRuntimes in a Location.
   291  func (c *NotebookClient) ListNotebookRuntimes(ctx context.Context, req *aiplatformpb.ListNotebookRuntimesRequest, opts ...gax.CallOption) *NotebookRuntimeIterator {
   292  	return c.internalClient.ListNotebookRuntimes(ctx, req, opts...)
   293  }
   294  
   295  // DeleteNotebookRuntime deletes a NotebookRuntime.
   296  func (c *NotebookClient) DeleteNotebookRuntime(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error) {
   297  	return c.internalClient.DeleteNotebookRuntime(ctx, req, opts...)
   298  }
   299  
   300  // DeleteNotebookRuntimeOperation returns a new DeleteNotebookRuntimeOperation from a given name.
   301  // The name must be that of a previously created DeleteNotebookRuntimeOperation, possibly from a different process.
   302  func (c *NotebookClient) DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation {
   303  	return c.internalClient.DeleteNotebookRuntimeOperation(name)
   304  }
   305  
   306  // UpgradeNotebookRuntime upgrades a NotebookRuntime.
   307  func (c *NotebookClient) UpgradeNotebookRuntime(ctx context.Context, req *aiplatformpb.UpgradeNotebookRuntimeRequest, opts ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error) {
   308  	return c.internalClient.UpgradeNotebookRuntime(ctx, req, opts...)
   309  }
   310  
   311  // UpgradeNotebookRuntimeOperation returns a new UpgradeNotebookRuntimeOperation from a given name.
   312  // The name must be that of a previously created UpgradeNotebookRuntimeOperation, possibly from a different process.
   313  func (c *NotebookClient) UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation {
   314  	return c.internalClient.UpgradeNotebookRuntimeOperation(name)
   315  }
   316  
   317  // StartNotebookRuntime starts a NotebookRuntime.
   318  func (c *NotebookClient) StartNotebookRuntime(ctx context.Context, req *aiplatformpb.StartNotebookRuntimeRequest, opts ...gax.CallOption) (*StartNotebookRuntimeOperation, error) {
   319  	return c.internalClient.StartNotebookRuntime(ctx, req, opts...)
   320  }
   321  
   322  // StartNotebookRuntimeOperation returns a new StartNotebookRuntimeOperation from a given name.
   323  // The name must be that of a previously created StartNotebookRuntimeOperation, possibly from a different process.
   324  func (c *NotebookClient) StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation {
   325  	return c.internalClient.StartNotebookRuntimeOperation(name)
   326  }
   327  
   328  // StopNotebookRuntime stops a NotebookRuntime.
   329  func (c *NotebookClient) StopNotebookRuntime(ctx context.Context, req *aiplatformpb.StopNotebookRuntimeRequest, opts ...gax.CallOption) (*StopNotebookRuntimeOperation, error) {
   330  	return c.internalClient.StopNotebookRuntime(ctx, req, opts...)
   331  }
   332  
   333  // StopNotebookRuntimeOperation returns a new StopNotebookRuntimeOperation from a given name.
   334  // The name must be that of a previously created StopNotebookRuntimeOperation, possibly from a different process.
   335  func (c *NotebookClient) StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation {
   336  	return c.internalClient.StopNotebookRuntimeOperation(name)
   337  }
   338  
   339  // CreateNotebookExecutionJob creates a NotebookExecutionJob.
   340  func (c *NotebookClient) CreateNotebookExecutionJob(ctx context.Context, req *aiplatformpb.CreateNotebookExecutionJobRequest, opts ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error) {
   341  	return c.internalClient.CreateNotebookExecutionJob(ctx, req, opts...)
   342  }
   343  
   344  // CreateNotebookExecutionJobOperation returns a new CreateNotebookExecutionJobOperation from a given name.
   345  // The name must be that of a previously created CreateNotebookExecutionJobOperation, possibly from a different process.
   346  func (c *NotebookClient) CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation {
   347  	return c.internalClient.CreateNotebookExecutionJobOperation(name)
   348  }
   349  
   350  // GetNotebookExecutionJob gets a NotebookExecutionJob.
   351  func (c *NotebookClient) GetNotebookExecutionJob(ctx context.Context, req *aiplatformpb.GetNotebookExecutionJobRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error) {
   352  	return c.internalClient.GetNotebookExecutionJob(ctx, req, opts...)
   353  }
   354  
   355  // ListNotebookExecutionJobs lists NotebookExecutionJobs in a Location.
   356  func (c *NotebookClient) ListNotebookExecutionJobs(ctx context.Context, req *aiplatformpb.ListNotebookExecutionJobsRequest, opts ...gax.CallOption) *NotebookExecutionJobIterator {
   357  	return c.internalClient.ListNotebookExecutionJobs(ctx, req, opts...)
   358  }
   359  
   360  // DeleteNotebookExecutionJob deletes a NotebookExecutionJob.
   361  func (c *NotebookClient) DeleteNotebookExecutionJob(ctx context.Context, req *aiplatformpb.DeleteNotebookExecutionJobRequest, opts ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error) {
   362  	return c.internalClient.DeleteNotebookExecutionJob(ctx, req, opts...)
   363  }
   364  
   365  // DeleteNotebookExecutionJobOperation returns a new DeleteNotebookExecutionJobOperation from a given name.
   366  // The name must be that of a previously created DeleteNotebookExecutionJobOperation, possibly from a different process.
   367  func (c *NotebookClient) DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation {
   368  	return c.internalClient.DeleteNotebookExecutionJobOperation(name)
   369  }
   370  
   371  // GetLocation gets information about a location.
   372  func (c *NotebookClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
   373  	return c.internalClient.GetLocation(ctx, req, opts...)
   374  }
   375  
   376  // ListLocations lists information about the supported locations for this service.
   377  func (c *NotebookClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
   378  	return c.internalClient.ListLocations(ctx, req, opts...)
   379  }
   380  
   381  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
   382  // if the resource exists and does not have a policy set.
   383  func (c *NotebookClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   384  	return c.internalClient.GetIamPolicy(ctx, req, opts...)
   385  }
   386  
   387  // SetIamPolicy sets the access control policy on the specified resource. Replaces
   388  // any existing policy.
   389  //
   390  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
   391  // errors.
   392  func (c *NotebookClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
   393  	return c.internalClient.SetIamPolicy(ctx, req, opts...)
   394  }
   395  
   396  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
   397  // resource does not exist, this will return an empty set of
   398  // permissions, not a NOT_FOUND error.
   399  //
   400  // Note: This operation is designed to be used for building
   401  // permission-aware UIs and command-line tools, not for authorization
   402  // checking. This operation may “fail open” without warning.
   403  func (c *NotebookClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
   404  	return c.internalClient.TestIamPermissions(ctx, req, opts...)
   405  }
   406  
   407  // CancelOperation is a utility method from google.longrunning.Operations.
   408  func (c *NotebookClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
   409  	return c.internalClient.CancelOperation(ctx, req, opts...)
   410  }
   411  
   412  // DeleteOperation is a utility method from google.longrunning.Operations.
   413  func (c *NotebookClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
   414  	return c.internalClient.DeleteOperation(ctx, req, opts...)
   415  }
   416  
   417  // GetOperation is a utility method from google.longrunning.Operations.
   418  func (c *NotebookClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   419  	return c.internalClient.GetOperation(ctx, req, opts...)
   420  }
   421  
   422  // ListOperations is a utility method from google.longrunning.Operations.
   423  func (c *NotebookClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
   424  	return c.internalClient.ListOperations(ctx, req, opts...)
   425  }
   426  
   427  // WaitOperation is a utility method from google.longrunning.Operations.
   428  func (c *NotebookClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
   429  	return c.internalClient.WaitOperation(ctx, req, opts...)
   430  }
   431  
   432  // notebookGRPCClient is a client for interacting with Vertex AI API over gRPC transport.
   433  //
   434  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   435  type notebookGRPCClient struct {
   436  	// Connection pool of gRPC connections to the service.
   437  	connPool gtransport.ConnPool
   438  
   439  	// Points back to the CallOptions field of the containing NotebookClient
   440  	CallOptions **NotebookCallOptions
   441  
   442  	// The gRPC API client.
   443  	notebookClient aiplatformpb.NotebookServiceClient
   444  
   445  	// LROClient is used internally to handle long-running operations.
   446  	// It is exposed so that its CallOptions can be modified if required.
   447  	// Users should not Close this client.
   448  	LROClient **lroauto.OperationsClient
   449  
   450  	operationsClient longrunningpb.OperationsClient
   451  
   452  	iamPolicyClient iampb.IAMPolicyClient
   453  
   454  	locationsClient locationpb.LocationsClient
   455  
   456  	// The x-goog-* metadata to be sent with each request.
   457  	xGoogHeaders []string
   458  
   459  	logger *slog.Logger
   460  }
   461  
   462  // NewNotebookClient creates a new notebook service client based on gRPC.
   463  // The returned client must be Closed when it is done being used to clean up its underlying connections.
   464  //
   465  // The interface for Vertex Notebook service (a.k.a. Colab on Workbench).
   466  func NewNotebookClient(ctx context.Context, opts ...option.ClientOption) (*NotebookClient, error) {
   467  	clientOpts := defaultNotebookGRPCClientOptions()
   468  	if newNotebookClientHook != nil {
   469  		hookOpts, err := newNotebookClientHook(ctx, clientHookParams{})
   470  		if err != nil {
   471  			return nil, err
   472  		}
   473  		clientOpts = append(clientOpts, hookOpts...)
   474  	}
   475  
   476  	connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
   477  	if err != nil {
   478  		return nil, err
   479  	}
   480  	client := NotebookClient{CallOptions: defaultNotebookCallOptions()}
   481  
   482  	c := &notebookGRPCClient{
   483  		connPool:         connPool,
   484  		notebookClient:   aiplatformpb.NewNotebookServiceClient(connPool),
   485  		CallOptions:      &client.CallOptions,
   486  		logger:           internaloption.GetLogger(opts),
   487  		operationsClient: longrunningpb.NewOperationsClient(connPool),
   488  		iamPolicyClient:  iampb.NewIAMPolicyClient(connPool),
   489  		locationsClient:  locationpb.NewLocationsClient(connPool),
   490  	}
   491  	c.setGoogleClientInfo()
   492  
   493  	client.internalClient = c
   494  
   495  	client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool))
   496  	if err != nil {
   497  		// This error "should not happen", since we are just reusing old connection pool
   498  		// and never actually need to dial.
   499  		// If this does happen, we could leak connp. However, we cannot close conn:
   500  		// If the user invoked the constructor with option.WithGRPCConn,
   501  		// we would close a connection that's still in use.
   502  		// TODO: investigate error conditions.
   503  		return nil, err
   504  	}
   505  	c.LROClient = &client.LROClient
   506  	return &client, nil
   507  }
   508  
   509  // Connection returns a connection to the API service.
   510  //
   511  // Deprecated: Connections are now pooled so this method does not always
   512  // return the same resource.
   513  func (c *notebookGRPCClient) Connection() *grpc.ClientConn {
   514  	return c.connPool.Conn()
   515  }
   516  
   517  // setGoogleClientInfo sets the name and version of the application in
   518  // the `x-goog-api-client` header passed on each request. Intended for
   519  // use by Google-written clients.
   520  func (c *notebookGRPCClient) setGoogleClientInfo(keyval ...string) {
   521  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   522  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
   523  	c.xGoogHeaders = []string{
   524  		"x-goog-api-client", gax.XGoogHeader(kv...),
   525  	}
   526  }
   527  
   528  // Close closes the connection to the API service. The user should invoke this when
   529  // the client is no longer required.
   530  func (c *notebookGRPCClient) Close() error {
   531  	return c.connPool.Close()
   532  }
   533  
   534  // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
   535  type notebookRESTClient struct {
   536  	// The http endpoint to connect to.
   537  	endpoint string
   538  
   539  	// The http client.
   540  	httpClient *http.Client
   541  
   542  	// LROClient is used internally to handle long-running operations.
   543  	// It is exposed so that its CallOptions can be modified if required.
   544  	// Users should not Close this client.
   545  	LROClient **lroauto.OperationsClient
   546  
   547  	// The x-goog-* headers to be sent with each request.
   548  	xGoogHeaders []string
   549  
   550  	// Points back to the CallOptions field of the containing NotebookClient
   551  	CallOptions **NotebookCallOptions
   552  
   553  	logger *slog.Logger
   554  }
   555  
   556  // NewNotebookRESTClient creates a new notebook service rest client.
   557  //
   558  // The interface for Vertex Notebook service (a.k.a. Colab on Workbench).
   559  func NewNotebookRESTClient(ctx context.Context, opts ...option.ClientOption) (*NotebookClient, error) {
   560  	clientOpts := append(defaultNotebookRESTClientOptions(), opts...)
   561  	httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
   562  	if err != nil {
   563  		return nil, err
   564  	}
   565  
   566  	callOpts := defaultNotebookRESTCallOptions()
   567  	c := &notebookRESTClient{
   568  		endpoint:    endpoint,
   569  		httpClient:  httpClient,
   570  		CallOptions: &callOpts,
   571  		logger:      internaloption.GetLogger(opts),
   572  	}
   573  	c.setGoogleClientInfo()
   574  
   575  	lroOpts := []option.ClientOption{
   576  		option.WithHTTPClient(httpClient),
   577  		option.WithEndpoint(endpoint),
   578  	}
   579  	opClient, err := lroauto.NewOperationsRESTClient(ctx, lroOpts...)
   580  	if err != nil {
   581  		return nil, err
   582  	}
   583  	c.LROClient = &opClient
   584  
   585  	return &NotebookClient{internalClient: c, CallOptions: callOpts}, nil
   586  }
   587  
   588  func defaultNotebookRESTClientOptions() []option.ClientOption {
   589  	return []option.ClientOption{
   590  		internaloption.WithDefaultEndpoint("https://aiplatform.googleapis.com"),
   591  		internaloption.WithDefaultEndpointTemplate("https://aiplatform.UNIVERSE_DOMAIN"),
   592  		internaloption.WithDefaultMTLSEndpoint("https://aiplatform.mtls.googleapis.com"),
   593  		internaloption.WithDefaultUniverseDomain("googleapis.com"),
   594  		internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"),
   595  		internaloption.WithDefaultScopes(DefaultAuthScopes()...),
   596  		internaloption.EnableNewAuthLibrary(),
   597  	}
   598  }
   599  
   600  // setGoogleClientInfo sets the name and version of the application in
   601  // the `x-goog-api-client` header passed on each request. Intended for
   602  // use by Google-written clients.
   603  func (c *notebookRESTClient) setGoogleClientInfo(keyval ...string) {
   604  	kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
   605  	kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
   606  	c.xGoogHeaders = []string{
   607  		"x-goog-api-client", gax.XGoogHeader(kv...),
   608  	}
   609  }
   610  
   611  // Close closes the connection to the API service. The user should invoke this when
   612  // the client is no longer required.
   613  func (c *notebookRESTClient) Close() error {
   614  	// Replace httpClient with nil to force cleanup.
   615  	c.httpClient = nil
   616  	return nil
   617  }
   618  
   619  // Connection returns a connection to the API service.
   620  //
   621  // Deprecated: This method always returns nil.
   622  func (c *notebookRESTClient) Connection() *grpc.ClientConn {
   623  	return nil
   624  }
   625  func (c *notebookGRPCClient) CreateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.CreateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error) {
   626  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   627  
   628  	hds = append(c.xGoogHeaders, hds...)
   629  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   630  	opts = append((*c.CallOptions).CreateNotebookRuntimeTemplate[0:len((*c.CallOptions).CreateNotebookRuntimeTemplate):len((*c.CallOptions).CreateNotebookRuntimeTemplate)], opts...)
   631  	var resp *longrunningpb.Operation
   632  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   633  		var err error
   634  		resp, err = executeRPC(ctx, c.notebookClient.CreateNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "CreateNotebookRuntimeTemplate")
   635  		return err
   636  	}, opts...)
   637  	if err != nil {
   638  		return nil, err
   639  	}
   640  	return &CreateNotebookRuntimeTemplateOperation{
   641  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   642  	}, nil
   643  }
   644  
   645  func (c *notebookGRPCClient) GetNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) {
   646  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   647  
   648  	hds = append(c.xGoogHeaders, hds...)
   649  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   650  	opts = append((*c.CallOptions).GetNotebookRuntimeTemplate[0:len((*c.CallOptions).GetNotebookRuntimeTemplate):len((*c.CallOptions).GetNotebookRuntimeTemplate)], opts...)
   651  	var resp *aiplatformpb.NotebookRuntimeTemplate
   652  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   653  		var err error
   654  		resp, err = executeRPC(ctx, c.notebookClient.GetNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "GetNotebookRuntimeTemplate")
   655  		return err
   656  	}, opts...)
   657  	if err != nil {
   658  		return nil, err
   659  	}
   660  	return resp, nil
   661  }
   662  
   663  func (c *notebookGRPCClient) ListNotebookRuntimeTemplates(ctx context.Context, req *aiplatformpb.ListNotebookRuntimeTemplatesRequest, opts ...gax.CallOption) *NotebookRuntimeTemplateIterator {
   664  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   665  
   666  	hds = append(c.xGoogHeaders, hds...)
   667  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   668  	opts = append((*c.CallOptions).ListNotebookRuntimeTemplates[0:len((*c.CallOptions).ListNotebookRuntimeTemplates):len((*c.CallOptions).ListNotebookRuntimeTemplates)], opts...)
   669  	it := &NotebookRuntimeTemplateIterator{}
   670  	req = proto.Clone(req).(*aiplatformpb.ListNotebookRuntimeTemplatesRequest)
   671  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookRuntimeTemplate, string, error) {
   672  		resp := &aiplatformpb.ListNotebookRuntimeTemplatesResponse{}
   673  		if pageToken != "" {
   674  			req.PageToken = pageToken
   675  		}
   676  		if pageSize > math.MaxInt32 {
   677  			req.PageSize = math.MaxInt32
   678  		} else if pageSize != 0 {
   679  			req.PageSize = int32(pageSize)
   680  		}
   681  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   682  			var err error
   683  			resp, err = executeRPC(ctx, c.notebookClient.ListNotebookRuntimeTemplates, req, settings.GRPC, c.logger, "ListNotebookRuntimeTemplates")
   684  			return err
   685  		}, opts...)
   686  		if err != nil {
   687  			return nil, "", err
   688  		}
   689  
   690  		it.Response = resp
   691  		return resp.GetNotebookRuntimeTemplates(), resp.GetNextPageToken(), nil
   692  	}
   693  	fetch := func(pageSize int, pageToken string) (string, error) {
   694  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   695  		if err != nil {
   696  			return "", err
   697  		}
   698  		it.items = append(it.items, items...)
   699  		return nextPageToken, nil
   700  	}
   701  
   702  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   703  	it.pageInfo.MaxSize = int(req.GetPageSize())
   704  	it.pageInfo.Token = req.GetPageToken()
   705  
   706  	return it
   707  }
   708  
   709  func (c *notebookGRPCClient) DeleteNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error) {
   710  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   711  
   712  	hds = append(c.xGoogHeaders, hds...)
   713  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   714  	opts = append((*c.CallOptions).DeleteNotebookRuntimeTemplate[0:len((*c.CallOptions).DeleteNotebookRuntimeTemplate):len((*c.CallOptions).DeleteNotebookRuntimeTemplate)], opts...)
   715  	var resp *longrunningpb.Operation
   716  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   717  		var err error
   718  		resp, err = executeRPC(ctx, c.notebookClient.DeleteNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "DeleteNotebookRuntimeTemplate")
   719  		return err
   720  	}, opts...)
   721  	if err != nil {
   722  		return nil, err
   723  	}
   724  	return &DeleteNotebookRuntimeTemplateOperation{
   725  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   726  	}, nil
   727  }
   728  
   729  func (c *notebookGRPCClient) UpdateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) {
   730  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "notebook_runtime_template.name", url.QueryEscape(req.GetNotebookRuntimeTemplate().GetName()))}
   731  
   732  	hds = append(c.xGoogHeaders, hds...)
   733  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   734  	opts = append((*c.CallOptions).UpdateNotebookRuntimeTemplate[0:len((*c.CallOptions).UpdateNotebookRuntimeTemplate):len((*c.CallOptions).UpdateNotebookRuntimeTemplate)], opts...)
   735  	var resp *aiplatformpb.NotebookRuntimeTemplate
   736  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   737  		var err error
   738  		resp, err = executeRPC(ctx, c.notebookClient.UpdateNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "UpdateNotebookRuntimeTemplate")
   739  		return err
   740  	}, opts...)
   741  	if err != nil {
   742  		return nil, err
   743  	}
   744  	return resp, nil
   745  }
   746  
   747  func (c *notebookGRPCClient) AssignNotebookRuntime(ctx context.Context, req *aiplatformpb.AssignNotebookRuntimeRequest, opts ...gax.CallOption) (*AssignNotebookRuntimeOperation, error) {
   748  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   749  
   750  	hds = append(c.xGoogHeaders, hds...)
   751  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   752  	opts = append((*c.CallOptions).AssignNotebookRuntime[0:len((*c.CallOptions).AssignNotebookRuntime):len((*c.CallOptions).AssignNotebookRuntime)], opts...)
   753  	var resp *longrunningpb.Operation
   754  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   755  		var err error
   756  		resp, err = executeRPC(ctx, c.notebookClient.AssignNotebookRuntime, req, settings.GRPC, c.logger, "AssignNotebookRuntime")
   757  		return err
   758  	}, opts...)
   759  	if err != nil {
   760  		return nil, err
   761  	}
   762  	return &AssignNotebookRuntimeOperation{
   763  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   764  	}, nil
   765  }
   766  
   767  func (c *notebookGRPCClient) GetNotebookRuntime(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error) {
   768  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   769  
   770  	hds = append(c.xGoogHeaders, hds...)
   771  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   772  	opts = append((*c.CallOptions).GetNotebookRuntime[0:len((*c.CallOptions).GetNotebookRuntime):len((*c.CallOptions).GetNotebookRuntime)], opts...)
   773  	var resp *aiplatformpb.NotebookRuntime
   774  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   775  		var err error
   776  		resp, err = executeRPC(ctx, c.notebookClient.GetNotebookRuntime, req, settings.GRPC, c.logger, "GetNotebookRuntime")
   777  		return err
   778  	}, opts...)
   779  	if err != nil {
   780  		return nil, err
   781  	}
   782  	return resp, nil
   783  }
   784  
   785  func (c *notebookGRPCClient) ListNotebookRuntimes(ctx context.Context, req *aiplatformpb.ListNotebookRuntimesRequest, opts ...gax.CallOption) *NotebookRuntimeIterator {
   786  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   787  
   788  	hds = append(c.xGoogHeaders, hds...)
   789  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   790  	opts = append((*c.CallOptions).ListNotebookRuntimes[0:len((*c.CallOptions).ListNotebookRuntimes):len((*c.CallOptions).ListNotebookRuntimes)], opts...)
   791  	it := &NotebookRuntimeIterator{}
   792  	req = proto.Clone(req).(*aiplatformpb.ListNotebookRuntimesRequest)
   793  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookRuntime, string, error) {
   794  		resp := &aiplatformpb.ListNotebookRuntimesResponse{}
   795  		if pageToken != "" {
   796  			req.PageToken = pageToken
   797  		}
   798  		if pageSize > math.MaxInt32 {
   799  			req.PageSize = math.MaxInt32
   800  		} else if pageSize != 0 {
   801  			req.PageSize = int32(pageSize)
   802  		}
   803  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   804  			var err error
   805  			resp, err = executeRPC(ctx, c.notebookClient.ListNotebookRuntimes, req, settings.GRPC, c.logger, "ListNotebookRuntimes")
   806  			return err
   807  		}, opts...)
   808  		if err != nil {
   809  			return nil, "", err
   810  		}
   811  
   812  		it.Response = resp
   813  		return resp.GetNotebookRuntimes(), resp.GetNextPageToken(), nil
   814  	}
   815  	fetch := func(pageSize int, pageToken string) (string, error) {
   816  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   817  		if err != nil {
   818  			return "", err
   819  		}
   820  		it.items = append(it.items, items...)
   821  		return nextPageToken, nil
   822  	}
   823  
   824  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   825  	it.pageInfo.MaxSize = int(req.GetPageSize())
   826  	it.pageInfo.Token = req.GetPageToken()
   827  
   828  	return it
   829  }
   830  
   831  func (c *notebookGRPCClient) DeleteNotebookRuntime(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error) {
   832  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   833  
   834  	hds = append(c.xGoogHeaders, hds...)
   835  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   836  	opts = append((*c.CallOptions).DeleteNotebookRuntime[0:len((*c.CallOptions).DeleteNotebookRuntime):len((*c.CallOptions).DeleteNotebookRuntime)], opts...)
   837  	var resp *longrunningpb.Operation
   838  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   839  		var err error
   840  		resp, err = executeRPC(ctx, c.notebookClient.DeleteNotebookRuntime, req, settings.GRPC, c.logger, "DeleteNotebookRuntime")
   841  		return err
   842  	}, opts...)
   843  	if err != nil {
   844  		return nil, err
   845  	}
   846  	return &DeleteNotebookRuntimeOperation{
   847  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   848  	}, nil
   849  }
   850  
   851  func (c *notebookGRPCClient) UpgradeNotebookRuntime(ctx context.Context, req *aiplatformpb.UpgradeNotebookRuntimeRequest, opts ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error) {
   852  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   853  
   854  	hds = append(c.xGoogHeaders, hds...)
   855  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   856  	opts = append((*c.CallOptions).UpgradeNotebookRuntime[0:len((*c.CallOptions).UpgradeNotebookRuntime):len((*c.CallOptions).UpgradeNotebookRuntime)], opts...)
   857  	var resp *longrunningpb.Operation
   858  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   859  		var err error
   860  		resp, err = executeRPC(ctx, c.notebookClient.UpgradeNotebookRuntime, req, settings.GRPC, c.logger, "UpgradeNotebookRuntime")
   861  		return err
   862  	}, opts...)
   863  	if err != nil {
   864  		return nil, err
   865  	}
   866  	return &UpgradeNotebookRuntimeOperation{
   867  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   868  	}, nil
   869  }
   870  
   871  func (c *notebookGRPCClient) StartNotebookRuntime(ctx context.Context, req *aiplatformpb.StartNotebookRuntimeRequest, opts ...gax.CallOption) (*StartNotebookRuntimeOperation, error) {
   872  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   873  
   874  	hds = append(c.xGoogHeaders, hds...)
   875  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   876  	opts = append((*c.CallOptions).StartNotebookRuntime[0:len((*c.CallOptions).StartNotebookRuntime):len((*c.CallOptions).StartNotebookRuntime)], opts...)
   877  	var resp *longrunningpb.Operation
   878  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   879  		var err error
   880  		resp, err = executeRPC(ctx, c.notebookClient.StartNotebookRuntime, req, settings.GRPC, c.logger, "StartNotebookRuntime")
   881  		return err
   882  	}, opts...)
   883  	if err != nil {
   884  		return nil, err
   885  	}
   886  	return &StartNotebookRuntimeOperation{
   887  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   888  	}, nil
   889  }
   890  
   891  func (c *notebookGRPCClient) StopNotebookRuntime(ctx context.Context, req *aiplatformpb.StopNotebookRuntimeRequest, opts ...gax.CallOption) (*StopNotebookRuntimeOperation, error) {
   892  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   893  
   894  	hds = append(c.xGoogHeaders, hds...)
   895  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   896  	opts = append((*c.CallOptions).StopNotebookRuntime[0:len((*c.CallOptions).StopNotebookRuntime):len((*c.CallOptions).StopNotebookRuntime)], opts...)
   897  	var resp *longrunningpb.Operation
   898  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   899  		var err error
   900  		resp, err = executeRPC(ctx, c.notebookClient.StopNotebookRuntime, req, settings.GRPC, c.logger, "StopNotebookRuntime")
   901  		return err
   902  	}, opts...)
   903  	if err != nil {
   904  		return nil, err
   905  	}
   906  	return &StopNotebookRuntimeOperation{
   907  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   908  	}, nil
   909  }
   910  
   911  func (c *notebookGRPCClient) CreateNotebookExecutionJob(ctx context.Context, req *aiplatformpb.CreateNotebookExecutionJobRequest, opts ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error) {
   912  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   913  
   914  	hds = append(c.xGoogHeaders, hds...)
   915  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   916  	opts = append((*c.CallOptions).CreateNotebookExecutionJob[0:len((*c.CallOptions).CreateNotebookExecutionJob):len((*c.CallOptions).CreateNotebookExecutionJob)], opts...)
   917  	var resp *longrunningpb.Operation
   918  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   919  		var err error
   920  		resp, err = executeRPC(ctx, c.notebookClient.CreateNotebookExecutionJob, req, settings.GRPC, c.logger, "CreateNotebookExecutionJob")
   921  		return err
   922  	}, opts...)
   923  	if err != nil {
   924  		return nil, err
   925  	}
   926  	return &CreateNotebookExecutionJobOperation{
   927  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
   928  	}, nil
   929  }
   930  
   931  func (c *notebookGRPCClient) GetNotebookExecutionJob(ctx context.Context, req *aiplatformpb.GetNotebookExecutionJobRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error) {
   932  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   933  
   934  	hds = append(c.xGoogHeaders, hds...)
   935  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   936  	opts = append((*c.CallOptions).GetNotebookExecutionJob[0:len((*c.CallOptions).GetNotebookExecutionJob):len((*c.CallOptions).GetNotebookExecutionJob)], opts...)
   937  	var resp *aiplatformpb.NotebookExecutionJob
   938  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   939  		var err error
   940  		resp, err = executeRPC(ctx, c.notebookClient.GetNotebookExecutionJob, req, settings.GRPC, c.logger, "GetNotebookExecutionJob")
   941  		return err
   942  	}, opts...)
   943  	if err != nil {
   944  		return nil, err
   945  	}
   946  	return resp, nil
   947  }
   948  
   949  func (c *notebookGRPCClient) ListNotebookExecutionJobs(ctx context.Context, req *aiplatformpb.ListNotebookExecutionJobsRequest, opts ...gax.CallOption) *NotebookExecutionJobIterator {
   950  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
   951  
   952  	hds = append(c.xGoogHeaders, hds...)
   953  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
   954  	opts = append((*c.CallOptions).ListNotebookExecutionJobs[0:len((*c.CallOptions).ListNotebookExecutionJobs):len((*c.CallOptions).ListNotebookExecutionJobs)], opts...)
   955  	it := &NotebookExecutionJobIterator{}
   956  	req = proto.Clone(req).(*aiplatformpb.ListNotebookExecutionJobsRequest)
   957  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookExecutionJob, string, error) {
   958  		resp := &aiplatformpb.ListNotebookExecutionJobsResponse{}
   959  		if pageToken != "" {
   960  			req.PageToken = pageToken
   961  		}
   962  		if pageSize > math.MaxInt32 {
   963  			req.PageSize = math.MaxInt32
   964  		} else if pageSize != 0 {
   965  			req.PageSize = int32(pageSize)
   966  		}
   967  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
   968  			var err error
   969  			resp, err = executeRPC(ctx, c.notebookClient.ListNotebookExecutionJobs, req, settings.GRPC, c.logger, "ListNotebookExecutionJobs")
   970  			return err
   971  		}, opts...)
   972  		if err != nil {
   973  			return nil, "", err
   974  		}
   975  
   976  		it.Response = resp
   977  		return resp.GetNotebookExecutionJobs(), resp.GetNextPageToken(), nil
   978  	}
   979  	fetch := func(pageSize int, pageToken string) (string, error) {
   980  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
   981  		if err != nil {
   982  			return "", err
   983  		}
   984  		it.items = append(it.items, items...)
   985  		return nextPageToken, nil
   986  	}
   987  
   988  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
   989  	it.pageInfo.MaxSize = int(req.GetPageSize())
   990  	it.pageInfo.Token = req.GetPageToken()
   991  
   992  	return it
   993  }
   994  
   995  func (c *notebookGRPCClient) DeleteNotebookExecutionJob(ctx context.Context, req *aiplatformpb.DeleteNotebookExecutionJobRequest, opts ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error) {
   996  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
   997  
   998  	hds = append(c.xGoogHeaders, hds...)
   999  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1000  	opts = append((*c.CallOptions).DeleteNotebookExecutionJob[0:len((*c.CallOptions).DeleteNotebookExecutionJob):len((*c.CallOptions).DeleteNotebookExecutionJob)], opts...)
  1001  	var resp *longrunningpb.Operation
  1002  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1003  		var err error
  1004  		resp, err = executeRPC(ctx, c.notebookClient.DeleteNotebookExecutionJob, req, settings.GRPC, c.logger, "DeleteNotebookExecutionJob")
  1005  		return err
  1006  	}, opts...)
  1007  	if err != nil {
  1008  		return nil, err
  1009  	}
  1010  	return &DeleteNotebookExecutionJobOperation{
  1011  		lro: longrunning.InternalNewOperation(*c.LROClient, resp),
  1012  	}, nil
  1013  }
  1014  
  1015  func (c *notebookGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  1016  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1017  
  1018  	hds = append(c.xGoogHeaders, hds...)
  1019  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1020  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  1021  	var resp *locationpb.Location
  1022  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1023  		var err error
  1024  		resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
  1025  		return err
  1026  	}, opts...)
  1027  	if err != nil {
  1028  		return nil, err
  1029  	}
  1030  	return resp, nil
  1031  }
  1032  
  1033  func (c *notebookGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  1034  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1035  
  1036  	hds = append(c.xGoogHeaders, hds...)
  1037  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1038  	opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
  1039  	it := &LocationIterator{}
  1040  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  1041  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  1042  		resp := &locationpb.ListLocationsResponse{}
  1043  		if pageToken != "" {
  1044  			req.PageToken = pageToken
  1045  		}
  1046  		if pageSize > math.MaxInt32 {
  1047  			req.PageSize = math.MaxInt32
  1048  		} else if pageSize != 0 {
  1049  			req.PageSize = int32(pageSize)
  1050  		}
  1051  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1052  			var err error
  1053  			resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
  1054  			return err
  1055  		}, opts...)
  1056  		if err != nil {
  1057  			return nil, "", err
  1058  		}
  1059  
  1060  		it.Response = resp
  1061  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  1062  	}
  1063  	fetch := func(pageSize int, pageToken string) (string, error) {
  1064  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1065  		if err != nil {
  1066  			return "", err
  1067  		}
  1068  		it.items = append(it.items, items...)
  1069  		return nextPageToken, nil
  1070  	}
  1071  
  1072  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1073  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1074  	it.pageInfo.Token = req.GetPageToken()
  1075  
  1076  	return it
  1077  }
  1078  
  1079  func (c *notebookGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1080  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1081  
  1082  	hds = append(c.xGoogHeaders, hds...)
  1083  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1084  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  1085  	var resp *iampb.Policy
  1086  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1087  		var err error
  1088  		resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
  1089  		return err
  1090  	}, opts...)
  1091  	if err != nil {
  1092  		return nil, err
  1093  	}
  1094  	return resp, nil
  1095  }
  1096  
  1097  func (c *notebookGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  1098  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1099  
  1100  	hds = append(c.xGoogHeaders, hds...)
  1101  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1102  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  1103  	var resp *iampb.Policy
  1104  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1105  		var err error
  1106  		resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
  1107  		return err
  1108  	}, opts...)
  1109  	if err != nil {
  1110  		return nil, err
  1111  	}
  1112  	return resp, nil
  1113  }
  1114  
  1115  func (c *notebookGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  1116  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  1117  
  1118  	hds = append(c.xGoogHeaders, hds...)
  1119  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1120  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  1121  	var resp *iampb.TestIamPermissionsResponse
  1122  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1123  		var err error
  1124  		resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
  1125  		return err
  1126  	}, opts...)
  1127  	if err != nil {
  1128  		return nil, err
  1129  	}
  1130  	return resp, nil
  1131  }
  1132  
  1133  func (c *notebookGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  1134  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1135  
  1136  	hds = append(c.xGoogHeaders, hds...)
  1137  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1138  	opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
  1139  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1140  		var err error
  1141  		_, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
  1142  		return err
  1143  	}, opts...)
  1144  	return err
  1145  }
  1146  
  1147  func (c *notebookGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  1148  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1149  
  1150  	hds = append(c.xGoogHeaders, hds...)
  1151  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1152  	opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
  1153  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1154  		var err error
  1155  		_, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
  1156  		return err
  1157  	}, opts...)
  1158  	return err
  1159  }
  1160  
  1161  func (c *notebookGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1162  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1163  
  1164  	hds = append(c.xGoogHeaders, hds...)
  1165  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1166  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  1167  	var resp *longrunningpb.Operation
  1168  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1169  		var err error
  1170  		resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
  1171  		return err
  1172  	}, opts...)
  1173  	if err != nil {
  1174  		return nil, err
  1175  	}
  1176  	return resp, nil
  1177  }
  1178  
  1179  func (c *notebookGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  1180  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1181  
  1182  	hds = append(c.xGoogHeaders, hds...)
  1183  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1184  	opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
  1185  	it := &OperationIterator{}
  1186  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  1187  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  1188  		resp := &longrunningpb.ListOperationsResponse{}
  1189  		if pageToken != "" {
  1190  			req.PageToken = pageToken
  1191  		}
  1192  		if pageSize > math.MaxInt32 {
  1193  			req.PageSize = math.MaxInt32
  1194  		} else if pageSize != 0 {
  1195  			req.PageSize = int32(pageSize)
  1196  		}
  1197  		err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1198  			var err error
  1199  			resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
  1200  			return err
  1201  		}, opts...)
  1202  		if err != nil {
  1203  			return nil, "", err
  1204  		}
  1205  
  1206  		it.Response = resp
  1207  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  1208  	}
  1209  	fetch := func(pageSize int, pageToken string) (string, error) {
  1210  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1211  		if err != nil {
  1212  			return "", err
  1213  		}
  1214  		it.items = append(it.items, items...)
  1215  		return nextPageToken, nil
  1216  	}
  1217  
  1218  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1219  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1220  	it.pageInfo.Token = req.GetPageToken()
  1221  
  1222  	return it
  1223  }
  1224  
  1225  func (c *notebookGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  1226  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1227  
  1228  	hds = append(c.xGoogHeaders, hds...)
  1229  	ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
  1230  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  1231  	var resp *longrunningpb.Operation
  1232  	err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1233  		var err error
  1234  		resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation")
  1235  		return err
  1236  	}, opts...)
  1237  	if err != nil {
  1238  		return nil, err
  1239  	}
  1240  	return resp, nil
  1241  }
  1242  
  1243  // CreateNotebookRuntimeTemplate creates a NotebookRuntimeTemplate.
  1244  func (c *notebookRESTClient) CreateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.CreateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error) {
  1245  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1246  	body := req.GetNotebookRuntimeTemplate()
  1247  	jsonReq, err := m.Marshal(body)
  1248  	if err != nil {
  1249  		return nil, err
  1250  	}
  1251  
  1252  	baseUrl, err := url.Parse(c.endpoint)
  1253  	if err != nil {
  1254  		return nil, err
  1255  	}
  1256  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/notebookRuntimeTemplates", req.GetParent())
  1257  
  1258  	params := url.Values{}
  1259  	params.Add("$alt", "json;enum-encoding=int")
  1260  	if req.GetNotebookRuntimeTemplateId() != "" {
  1261  		params.Add("notebookRuntimeTemplateId", fmt.Sprintf("%v", req.GetNotebookRuntimeTemplateId()))
  1262  	}
  1263  
  1264  	baseUrl.RawQuery = params.Encode()
  1265  
  1266  	// Build HTTP headers from client and context metadata.
  1267  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1268  
  1269  	hds = append(c.xGoogHeaders, hds...)
  1270  	hds = append(hds, "Content-Type", "application/json")
  1271  	headers := gax.BuildHeaders(ctx, hds...)
  1272  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1273  	resp := &longrunningpb.Operation{}
  1274  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1275  		if settings.Path != "" {
  1276  			baseUrl.Path = settings.Path
  1277  		}
  1278  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1279  		if err != nil {
  1280  			return err
  1281  		}
  1282  		httpReq = httpReq.WithContext(ctx)
  1283  		httpReq.Header = headers
  1284  
  1285  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateNotebookRuntimeTemplate")
  1286  		if err != nil {
  1287  			return err
  1288  		}
  1289  		if err := unm.Unmarshal(buf, resp); err != nil {
  1290  			return err
  1291  		}
  1292  
  1293  		return nil
  1294  	}, opts...)
  1295  	if e != nil {
  1296  		return nil, e
  1297  	}
  1298  
  1299  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1300  	return &CreateNotebookRuntimeTemplateOperation{
  1301  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1302  		pollPath: override,
  1303  	}, nil
  1304  }
  1305  
  1306  // GetNotebookRuntimeTemplate gets a NotebookRuntimeTemplate.
  1307  func (c *notebookRESTClient) GetNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) {
  1308  	baseUrl, err := url.Parse(c.endpoint)
  1309  	if err != nil {
  1310  		return nil, err
  1311  	}
  1312  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1313  
  1314  	params := url.Values{}
  1315  	params.Add("$alt", "json;enum-encoding=int")
  1316  
  1317  	baseUrl.RawQuery = params.Encode()
  1318  
  1319  	// Build HTTP headers from client and context metadata.
  1320  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1321  
  1322  	hds = append(c.xGoogHeaders, hds...)
  1323  	hds = append(hds, "Content-Type", "application/json")
  1324  	headers := gax.BuildHeaders(ctx, hds...)
  1325  	opts = append((*c.CallOptions).GetNotebookRuntimeTemplate[0:len((*c.CallOptions).GetNotebookRuntimeTemplate):len((*c.CallOptions).GetNotebookRuntimeTemplate)], opts...)
  1326  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1327  	resp := &aiplatformpb.NotebookRuntimeTemplate{}
  1328  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1329  		if settings.Path != "" {
  1330  			baseUrl.Path = settings.Path
  1331  		}
  1332  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1333  		if err != nil {
  1334  			return err
  1335  		}
  1336  		httpReq = httpReq.WithContext(ctx)
  1337  		httpReq.Header = headers
  1338  
  1339  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetNotebookRuntimeTemplate")
  1340  		if err != nil {
  1341  			return err
  1342  		}
  1343  
  1344  		if err := unm.Unmarshal(buf, resp); err != nil {
  1345  			return err
  1346  		}
  1347  
  1348  		return nil
  1349  	}, opts...)
  1350  	if e != nil {
  1351  		return nil, e
  1352  	}
  1353  	return resp, nil
  1354  }
  1355  
  1356  // ListNotebookRuntimeTemplates lists NotebookRuntimeTemplates in a Location.
  1357  func (c *notebookRESTClient) ListNotebookRuntimeTemplates(ctx context.Context, req *aiplatformpb.ListNotebookRuntimeTemplatesRequest, opts ...gax.CallOption) *NotebookRuntimeTemplateIterator {
  1358  	it := &NotebookRuntimeTemplateIterator{}
  1359  	req = proto.Clone(req).(*aiplatformpb.ListNotebookRuntimeTemplatesRequest)
  1360  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1361  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookRuntimeTemplate, string, error) {
  1362  		resp := &aiplatformpb.ListNotebookRuntimeTemplatesResponse{}
  1363  		if pageToken != "" {
  1364  			req.PageToken = pageToken
  1365  		}
  1366  		if pageSize > math.MaxInt32 {
  1367  			req.PageSize = math.MaxInt32
  1368  		} else if pageSize != 0 {
  1369  			req.PageSize = int32(pageSize)
  1370  		}
  1371  		baseUrl, err := url.Parse(c.endpoint)
  1372  		if err != nil {
  1373  			return nil, "", err
  1374  		}
  1375  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/notebookRuntimeTemplates", req.GetParent())
  1376  
  1377  		params := url.Values{}
  1378  		params.Add("$alt", "json;enum-encoding=int")
  1379  		if req.GetFilter() != "" {
  1380  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1381  		}
  1382  		if req.GetOrderBy() != "" {
  1383  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  1384  		}
  1385  		if req.GetPageSize() != 0 {
  1386  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1387  		}
  1388  		if req.GetPageToken() != "" {
  1389  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1390  		}
  1391  		if req.GetReadMask() != nil {
  1392  			field, err := protojson.Marshal(req.GetReadMask())
  1393  			if err != nil {
  1394  				return nil, "", err
  1395  			}
  1396  			params.Add("readMask", string(field[1:len(field)-1]))
  1397  		}
  1398  
  1399  		baseUrl.RawQuery = params.Encode()
  1400  
  1401  		// Build HTTP headers from client and context metadata.
  1402  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1403  		headers := gax.BuildHeaders(ctx, hds...)
  1404  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1405  			if settings.Path != "" {
  1406  				baseUrl.Path = settings.Path
  1407  			}
  1408  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1409  			if err != nil {
  1410  				return err
  1411  			}
  1412  			httpReq.Header = headers
  1413  
  1414  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListNotebookRuntimeTemplates")
  1415  			if err != nil {
  1416  				return err
  1417  			}
  1418  			if err := unm.Unmarshal(buf, resp); err != nil {
  1419  				return err
  1420  			}
  1421  
  1422  			return nil
  1423  		}, opts...)
  1424  		if e != nil {
  1425  			return nil, "", e
  1426  		}
  1427  		it.Response = resp
  1428  		return resp.GetNotebookRuntimeTemplates(), resp.GetNextPageToken(), nil
  1429  	}
  1430  
  1431  	fetch := func(pageSize int, pageToken string) (string, error) {
  1432  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1433  		if err != nil {
  1434  			return "", err
  1435  		}
  1436  		it.items = append(it.items, items...)
  1437  		return nextPageToken, nil
  1438  	}
  1439  
  1440  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1441  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1442  	it.pageInfo.Token = req.GetPageToken()
  1443  
  1444  	return it
  1445  }
  1446  
  1447  // DeleteNotebookRuntimeTemplate deletes a NotebookRuntimeTemplate.
  1448  func (c *notebookRESTClient) DeleteNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error) {
  1449  	baseUrl, err := url.Parse(c.endpoint)
  1450  	if err != nil {
  1451  		return nil, err
  1452  	}
  1453  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1454  
  1455  	params := url.Values{}
  1456  	params.Add("$alt", "json;enum-encoding=int")
  1457  
  1458  	baseUrl.RawQuery = params.Encode()
  1459  
  1460  	// Build HTTP headers from client and context metadata.
  1461  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1462  
  1463  	hds = append(c.xGoogHeaders, hds...)
  1464  	hds = append(hds, "Content-Type", "application/json")
  1465  	headers := gax.BuildHeaders(ctx, hds...)
  1466  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1467  	resp := &longrunningpb.Operation{}
  1468  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1469  		if settings.Path != "" {
  1470  			baseUrl.Path = settings.Path
  1471  		}
  1472  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1473  		if err != nil {
  1474  			return err
  1475  		}
  1476  		httpReq = httpReq.WithContext(ctx)
  1477  		httpReq.Header = headers
  1478  
  1479  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteNotebookRuntimeTemplate")
  1480  		if err != nil {
  1481  			return err
  1482  		}
  1483  		if err := unm.Unmarshal(buf, resp); err != nil {
  1484  			return err
  1485  		}
  1486  
  1487  		return nil
  1488  	}, opts...)
  1489  	if e != nil {
  1490  		return nil, e
  1491  	}
  1492  
  1493  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1494  	return &DeleteNotebookRuntimeTemplateOperation{
  1495  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1496  		pollPath: override,
  1497  	}, nil
  1498  }
  1499  
  1500  // UpdateNotebookRuntimeTemplate updates a NotebookRuntimeTemplate.
  1501  func (c *notebookRESTClient) UpdateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) {
  1502  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1503  	body := req.GetNotebookRuntimeTemplate()
  1504  	jsonReq, err := m.Marshal(body)
  1505  	if err != nil {
  1506  		return nil, err
  1507  	}
  1508  
  1509  	baseUrl, err := url.Parse(c.endpoint)
  1510  	if err != nil {
  1511  		return nil, err
  1512  	}
  1513  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetNotebookRuntimeTemplate().GetName())
  1514  
  1515  	params := url.Values{}
  1516  	params.Add("$alt", "json;enum-encoding=int")
  1517  	if req.GetUpdateMask() != nil {
  1518  		field, err := protojson.Marshal(req.GetUpdateMask())
  1519  		if err != nil {
  1520  			return nil, err
  1521  		}
  1522  		params.Add("updateMask", string(field[1:len(field)-1]))
  1523  	}
  1524  
  1525  	baseUrl.RawQuery = params.Encode()
  1526  
  1527  	// Build HTTP headers from client and context metadata.
  1528  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "notebook_runtime_template.name", url.QueryEscape(req.GetNotebookRuntimeTemplate().GetName()))}
  1529  
  1530  	hds = append(c.xGoogHeaders, hds...)
  1531  	hds = append(hds, "Content-Type", "application/json")
  1532  	headers := gax.BuildHeaders(ctx, hds...)
  1533  	opts = append((*c.CallOptions).UpdateNotebookRuntimeTemplate[0:len((*c.CallOptions).UpdateNotebookRuntimeTemplate):len((*c.CallOptions).UpdateNotebookRuntimeTemplate)], opts...)
  1534  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1535  	resp := &aiplatformpb.NotebookRuntimeTemplate{}
  1536  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1537  		if settings.Path != "" {
  1538  			baseUrl.Path = settings.Path
  1539  		}
  1540  		httpReq, err := http.NewRequest("PATCH", baseUrl.String(), bytes.NewReader(jsonReq))
  1541  		if err != nil {
  1542  			return err
  1543  		}
  1544  		httpReq = httpReq.WithContext(ctx)
  1545  		httpReq.Header = headers
  1546  
  1547  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateNotebookRuntimeTemplate")
  1548  		if err != nil {
  1549  			return err
  1550  		}
  1551  
  1552  		if err := unm.Unmarshal(buf, resp); err != nil {
  1553  			return err
  1554  		}
  1555  
  1556  		return nil
  1557  	}, opts...)
  1558  	if e != nil {
  1559  		return nil, e
  1560  	}
  1561  	return resp, nil
  1562  }
  1563  
  1564  // AssignNotebookRuntime assigns a NotebookRuntime to a user for a particular Notebook file. This
  1565  // method will either returns an existing assignment or generates a new one.
  1566  func (c *notebookRESTClient) AssignNotebookRuntime(ctx context.Context, req *aiplatformpb.AssignNotebookRuntimeRequest, opts ...gax.CallOption) (*AssignNotebookRuntimeOperation, error) {
  1567  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1568  	jsonReq, err := m.Marshal(req)
  1569  	if err != nil {
  1570  		return nil, err
  1571  	}
  1572  
  1573  	baseUrl, err := url.Parse(c.endpoint)
  1574  	if err != nil {
  1575  		return nil, err
  1576  	}
  1577  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/notebookRuntimes:assign", req.GetParent())
  1578  
  1579  	params := url.Values{}
  1580  	params.Add("$alt", "json;enum-encoding=int")
  1581  
  1582  	baseUrl.RawQuery = params.Encode()
  1583  
  1584  	// Build HTTP headers from client and context metadata.
  1585  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  1586  
  1587  	hds = append(c.xGoogHeaders, hds...)
  1588  	hds = append(hds, "Content-Type", "application/json")
  1589  	headers := gax.BuildHeaders(ctx, hds...)
  1590  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1591  	resp := &longrunningpb.Operation{}
  1592  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1593  		if settings.Path != "" {
  1594  			baseUrl.Path = settings.Path
  1595  		}
  1596  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1597  		if err != nil {
  1598  			return err
  1599  		}
  1600  		httpReq = httpReq.WithContext(ctx)
  1601  		httpReq.Header = headers
  1602  
  1603  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "AssignNotebookRuntime")
  1604  		if err != nil {
  1605  			return err
  1606  		}
  1607  		if err := unm.Unmarshal(buf, resp); err != nil {
  1608  			return err
  1609  		}
  1610  
  1611  		return nil
  1612  	}, opts...)
  1613  	if e != nil {
  1614  		return nil, e
  1615  	}
  1616  
  1617  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1618  	return &AssignNotebookRuntimeOperation{
  1619  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1620  		pollPath: override,
  1621  	}, nil
  1622  }
  1623  
  1624  // GetNotebookRuntime gets a NotebookRuntime.
  1625  func (c *notebookRESTClient) GetNotebookRuntime(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error) {
  1626  	baseUrl, err := url.Parse(c.endpoint)
  1627  	if err != nil {
  1628  		return nil, err
  1629  	}
  1630  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1631  
  1632  	params := url.Values{}
  1633  	params.Add("$alt", "json;enum-encoding=int")
  1634  
  1635  	baseUrl.RawQuery = params.Encode()
  1636  
  1637  	// Build HTTP headers from client and context metadata.
  1638  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1639  
  1640  	hds = append(c.xGoogHeaders, hds...)
  1641  	hds = append(hds, "Content-Type", "application/json")
  1642  	headers := gax.BuildHeaders(ctx, hds...)
  1643  	opts = append((*c.CallOptions).GetNotebookRuntime[0:len((*c.CallOptions).GetNotebookRuntime):len((*c.CallOptions).GetNotebookRuntime)], opts...)
  1644  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1645  	resp := &aiplatformpb.NotebookRuntime{}
  1646  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1647  		if settings.Path != "" {
  1648  			baseUrl.Path = settings.Path
  1649  		}
  1650  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1651  		if err != nil {
  1652  			return err
  1653  		}
  1654  		httpReq = httpReq.WithContext(ctx)
  1655  		httpReq.Header = headers
  1656  
  1657  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetNotebookRuntime")
  1658  		if err != nil {
  1659  			return err
  1660  		}
  1661  
  1662  		if err := unm.Unmarshal(buf, resp); err != nil {
  1663  			return err
  1664  		}
  1665  
  1666  		return nil
  1667  	}, opts...)
  1668  	if e != nil {
  1669  		return nil, e
  1670  	}
  1671  	return resp, nil
  1672  }
  1673  
  1674  // ListNotebookRuntimes lists NotebookRuntimes in a Location.
  1675  func (c *notebookRESTClient) ListNotebookRuntimes(ctx context.Context, req *aiplatformpb.ListNotebookRuntimesRequest, opts ...gax.CallOption) *NotebookRuntimeIterator {
  1676  	it := &NotebookRuntimeIterator{}
  1677  	req = proto.Clone(req).(*aiplatformpb.ListNotebookRuntimesRequest)
  1678  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1679  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookRuntime, string, error) {
  1680  		resp := &aiplatformpb.ListNotebookRuntimesResponse{}
  1681  		if pageToken != "" {
  1682  			req.PageToken = pageToken
  1683  		}
  1684  		if pageSize > math.MaxInt32 {
  1685  			req.PageSize = math.MaxInt32
  1686  		} else if pageSize != 0 {
  1687  			req.PageSize = int32(pageSize)
  1688  		}
  1689  		baseUrl, err := url.Parse(c.endpoint)
  1690  		if err != nil {
  1691  			return nil, "", err
  1692  		}
  1693  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/notebookRuntimes", req.GetParent())
  1694  
  1695  		params := url.Values{}
  1696  		params.Add("$alt", "json;enum-encoding=int")
  1697  		if req.GetFilter() != "" {
  1698  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  1699  		}
  1700  		if req.GetOrderBy() != "" {
  1701  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  1702  		}
  1703  		if req.GetPageSize() != 0 {
  1704  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  1705  		}
  1706  		if req.GetPageToken() != "" {
  1707  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  1708  		}
  1709  		if req.GetReadMask() != nil {
  1710  			field, err := protojson.Marshal(req.GetReadMask())
  1711  			if err != nil {
  1712  				return nil, "", err
  1713  			}
  1714  			params.Add("readMask", string(field[1:len(field)-1]))
  1715  		}
  1716  
  1717  		baseUrl.RawQuery = params.Encode()
  1718  
  1719  		// Build HTTP headers from client and context metadata.
  1720  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  1721  		headers := gax.BuildHeaders(ctx, hds...)
  1722  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1723  			if settings.Path != "" {
  1724  				baseUrl.Path = settings.Path
  1725  			}
  1726  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  1727  			if err != nil {
  1728  				return err
  1729  			}
  1730  			httpReq.Header = headers
  1731  
  1732  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListNotebookRuntimes")
  1733  			if err != nil {
  1734  				return err
  1735  			}
  1736  			if err := unm.Unmarshal(buf, resp); err != nil {
  1737  				return err
  1738  			}
  1739  
  1740  			return nil
  1741  		}, opts...)
  1742  		if e != nil {
  1743  			return nil, "", e
  1744  		}
  1745  		it.Response = resp
  1746  		return resp.GetNotebookRuntimes(), resp.GetNextPageToken(), nil
  1747  	}
  1748  
  1749  	fetch := func(pageSize int, pageToken string) (string, error) {
  1750  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  1751  		if err != nil {
  1752  			return "", err
  1753  		}
  1754  		it.items = append(it.items, items...)
  1755  		return nextPageToken, nil
  1756  	}
  1757  
  1758  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  1759  	it.pageInfo.MaxSize = int(req.GetPageSize())
  1760  	it.pageInfo.Token = req.GetPageToken()
  1761  
  1762  	return it
  1763  }
  1764  
  1765  // DeleteNotebookRuntime deletes a NotebookRuntime.
  1766  func (c *notebookRESTClient) DeleteNotebookRuntime(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error) {
  1767  	baseUrl, err := url.Parse(c.endpoint)
  1768  	if err != nil {
  1769  		return nil, err
  1770  	}
  1771  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  1772  
  1773  	params := url.Values{}
  1774  	params.Add("$alt", "json;enum-encoding=int")
  1775  
  1776  	baseUrl.RawQuery = params.Encode()
  1777  
  1778  	// Build HTTP headers from client and context metadata.
  1779  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1780  
  1781  	hds = append(c.xGoogHeaders, hds...)
  1782  	hds = append(hds, "Content-Type", "application/json")
  1783  	headers := gax.BuildHeaders(ctx, hds...)
  1784  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1785  	resp := &longrunningpb.Operation{}
  1786  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1787  		if settings.Path != "" {
  1788  			baseUrl.Path = settings.Path
  1789  		}
  1790  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  1791  		if err != nil {
  1792  			return err
  1793  		}
  1794  		httpReq = httpReq.WithContext(ctx)
  1795  		httpReq.Header = headers
  1796  
  1797  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteNotebookRuntime")
  1798  		if err != nil {
  1799  			return err
  1800  		}
  1801  		if err := unm.Unmarshal(buf, resp); err != nil {
  1802  			return err
  1803  		}
  1804  
  1805  		return nil
  1806  	}, opts...)
  1807  	if e != nil {
  1808  		return nil, e
  1809  	}
  1810  
  1811  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1812  	return &DeleteNotebookRuntimeOperation{
  1813  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1814  		pollPath: override,
  1815  	}, nil
  1816  }
  1817  
  1818  // UpgradeNotebookRuntime upgrades a NotebookRuntime.
  1819  func (c *notebookRESTClient) UpgradeNotebookRuntime(ctx context.Context, req *aiplatformpb.UpgradeNotebookRuntimeRequest, opts ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error) {
  1820  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1821  	jsonReq, err := m.Marshal(req)
  1822  	if err != nil {
  1823  		return nil, err
  1824  	}
  1825  
  1826  	baseUrl, err := url.Parse(c.endpoint)
  1827  	if err != nil {
  1828  		return nil, err
  1829  	}
  1830  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:upgrade", req.GetName())
  1831  
  1832  	params := url.Values{}
  1833  	params.Add("$alt", "json;enum-encoding=int")
  1834  
  1835  	baseUrl.RawQuery = params.Encode()
  1836  
  1837  	// Build HTTP headers from client and context metadata.
  1838  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1839  
  1840  	hds = append(c.xGoogHeaders, hds...)
  1841  	hds = append(hds, "Content-Type", "application/json")
  1842  	headers := gax.BuildHeaders(ctx, hds...)
  1843  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1844  	resp := &longrunningpb.Operation{}
  1845  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1846  		if settings.Path != "" {
  1847  			baseUrl.Path = settings.Path
  1848  		}
  1849  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1850  		if err != nil {
  1851  			return err
  1852  		}
  1853  		httpReq = httpReq.WithContext(ctx)
  1854  		httpReq.Header = headers
  1855  
  1856  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpgradeNotebookRuntime")
  1857  		if err != nil {
  1858  			return err
  1859  		}
  1860  		if err := unm.Unmarshal(buf, resp); err != nil {
  1861  			return err
  1862  		}
  1863  
  1864  		return nil
  1865  	}, opts...)
  1866  	if e != nil {
  1867  		return nil, e
  1868  	}
  1869  
  1870  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1871  	return &UpgradeNotebookRuntimeOperation{
  1872  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1873  		pollPath: override,
  1874  	}, nil
  1875  }
  1876  
  1877  // StartNotebookRuntime starts a NotebookRuntime.
  1878  func (c *notebookRESTClient) StartNotebookRuntime(ctx context.Context, req *aiplatformpb.StartNotebookRuntimeRequest, opts ...gax.CallOption) (*StartNotebookRuntimeOperation, error) {
  1879  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1880  	jsonReq, err := m.Marshal(req)
  1881  	if err != nil {
  1882  		return nil, err
  1883  	}
  1884  
  1885  	baseUrl, err := url.Parse(c.endpoint)
  1886  	if err != nil {
  1887  		return nil, err
  1888  	}
  1889  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:start", req.GetName())
  1890  
  1891  	params := url.Values{}
  1892  	params.Add("$alt", "json;enum-encoding=int")
  1893  
  1894  	baseUrl.RawQuery = params.Encode()
  1895  
  1896  	// Build HTTP headers from client and context metadata.
  1897  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1898  
  1899  	hds = append(c.xGoogHeaders, hds...)
  1900  	hds = append(hds, "Content-Type", "application/json")
  1901  	headers := gax.BuildHeaders(ctx, hds...)
  1902  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1903  	resp := &longrunningpb.Operation{}
  1904  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1905  		if settings.Path != "" {
  1906  			baseUrl.Path = settings.Path
  1907  		}
  1908  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1909  		if err != nil {
  1910  			return err
  1911  		}
  1912  		httpReq = httpReq.WithContext(ctx)
  1913  		httpReq.Header = headers
  1914  
  1915  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "StartNotebookRuntime")
  1916  		if err != nil {
  1917  			return err
  1918  		}
  1919  		if err := unm.Unmarshal(buf, resp); err != nil {
  1920  			return err
  1921  		}
  1922  
  1923  		return nil
  1924  	}, opts...)
  1925  	if e != nil {
  1926  		return nil, e
  1927  	}
  1928  
  1929  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1930  	return &StartNotebookRuntimeOperation{
  1931  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1932  		pollPath: override,
  1933  	}, nil
  1934  }
  1935  
  1936  // StopNotebookRuntime stops a NotebookRuntime.
  1937  func (c *notebookRESTClient) StopNotebookRuntime(ctx context.Context, req *aiplatformpb.StopNotebookRuntimeRequest, opts ...gax.CallOption) (*StopNotebookRuntimeOperation, error) {
  1938  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1939  	jsonReq, err := m.Marshal(req)
  1940  	if err != nil {
  1941  		return nil, err
  1942  	}
  1943  
  1944  	baseUrl, err := url.Parse(c.endpoint)
  1945  	if err != nil {
  1946  		return nil, err
  1947  	}
  1948  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:stop", req.GetName())
  1949  
  1950  	params := url.Values{}
  1951  	params.Add("$alt", "json;enum-encoding=int")
  1952  
  1953  	baseUrl.RawQuery = params.Encode()
  1954  
  1955  	// Build HTTP headers from client and context metadata.
  1956  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  1957  
  1958  	hds = append(c.xGoogHeaders, hds...)
  1959  	hds = append(hds, "Content-Type", "application/json")
  1960  	headers := gax.BuildHeaders(ctx, hds...)
  1961  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  1962  	resp := &longrunningpb.Operation{}
  1963  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  1964  		if settings.Path != "" {
  1965  			baseUrl.Path = settings.Path
  1966  		}
  1967  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  1968  		if err != nil {
  1969  			return err
  1970  		}
  1971  		httpReq = httpReq.WithContext(ctx)
  1972  		httpReq.Header = headers
  1973  
  1974  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "StopNotebookRuntime")
  1975  		if err != nil {
  1976  			return err
  1977  		}
  1978  		if err := unm.Unmarshal(buf, resp); err != nil {
  1979  			return err
  1980  		}
  1981  
  1982  		return nil
  1983  	}, opts...)
  1984  	if e != nil {
  1985  		return nil, e
  1986  	}
  1987  
  1988  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  1989  	return &StopNotebookRuntimeOperation{
  1990  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  1991  		pollPath: override,
  1992  	}, nil
  1993  }
  1994  
  1995  // CreateNotebookExecutionJob creates a NotebookExecutionJob.
  1996  func (c *notebookRESTClient) CreateNotebookExecutionJob(ctx context.Context, req *aiplatformpb.CreateNotebookExecutionJobRequest, opts ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error) {
  1997  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  1998  	body := req.GetNotebookExecutionJob()
  1999  	jsonReq, err := m.Marshal(body)
  2000  	if err != nil {
  2001  		return nil, err
  2002  	}
  2003  
  2004  	baseUrl, err := url.Parse(c.endpoint)
  2005  	if err != nil {
  2006  		return nil, err
  2007  	}
  2008  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v/notebookExecutionJobs", req.GetParent())
  2009  
  2010  	params := url.Values{}
  2011  	params.Add("$alt", "json;enum-encoding=int")
  2012  	if req.GetNotebookExecutionJobId() != "" {
  2013  		params.Add("notebookExecutionJobId", fmt.Sprintf("%v", req.GetNotebookExecutionJobId()))
  2014  	}
  2015  
  2016  	baseUrl.RawQuery = params.Encode()
  2017  
  2018  	// Build HTTP headers from client and context metadata.
  2019  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
  2020  
  2021  	hds = append(c.xGoogHeaders, hds...)
  2022  	hds = append(hds, "Content-Type", "application/json")
  2023  	headers := gax.BuildHeaders(ctx, hds...)
  2024  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2025  	resp := &longrunningpb.Operation{}
  2026  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2027  		if settings.Path != "" {
  2028  			baseUrl.Path = settings.Path
  2029  		}
  2030  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2031  		if err != nil {
  2032  			return err
  2033  		}
  2034  		httpReq = httpReq.WithContext(ctx)
  2035  		httpReq.Header = headers
  2036  
  2037  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateNotebookExecutionJob")
  2038  		if err != nil {
  2039  			return err
  2040  		}
  2041  		if err := unm.Unmarshal(buf, resp); err != nil {
  2042  			return err
  2043  		}
  2044  
  2045  		return nil
  2046  	}, opts...)
  2047  	if e != nil {
  2048  		return nil, e
  2049  	}
  2050  
  2051  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2052  	return &CreateNotebookExecutionJobOperation{
  2053  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2054  		pollPath: override,
  2055  	}, nil
  2056  }
  2057  
  2058  // GetNotebookExecutionJob gets a NotebookExecutionJob.
  2059  func (c *notebookRESTClient) GetNotebookExecutionJob(ctx context.Context, req *aiplatformpb.GetNotebookExecutionJobRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error) {
  2060  	baseUrl, err := url.Parse(c.endpoint)
  2061  	if err != nil {
  2062  		return nil, err
  2063  	}
  2064  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2065  
  2066  	params := url.Values{}
  2067  	params.Add("$alt", "json;enum-encoding=int")
  2068  	if req.GetView() != 0 {
  2069  		params.Add("view", fmt.Sprintf("%v", req.GetView()))
  2070  	}
  2071  
  2072  	baseUrl.RawQuery = params.Encode()
  2073  
  2074  	// Build HTTP headers from client and context metadata.
  2075  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2076  
  2077  	hds = append(c.xGoogHeaders, hds...)
  2078  	hds = append(hds, "Content-Type", "application/json")
  2079  	headers := gax.BuildHeaders(ctx, hds...)
  2080  	opts = append((*c.CallOptions).GetNotebookExecutionJob[0:len((*c.CallOptions).GetNotebookExecutionJob):len((*c.CallOptions).GetNotebookExecutionJob)], opts...)
  2081  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2082  	resp := &aiplatformpb.NotebookExecutionJob{}
  2083  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2084  		if settings.Path != "" {
  2085  			baseUrl.Path = settings.Path
  2086  		}
  2087  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2088  		if err != nil {
  2089  			return err
  2090  		}
  2091  		httpReq = httpReq.WithContext(ctx)
  2092  		httpReq.Header = headers
  2093  
  2094  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetNotebookExecutionJob")
  2095  		if err != nil {
  2096  			return err
  2097  		}
  2098  
  2099  		if err := unm.Unmarshal(buf, resp); err != nil {
  2100  			return err
  2101  		}
  2102  
  2103  		return nil
  2104  	}, opts...)
  2105  	if e != nil {
  2106  		return nil, e
  2107  	}
  2108  	return resp, nil
  2109  }
  2110  
  2111  // ListNotebookExecutionJobs lists NotebookExecutionJobs in a Location.
  2112  func (c *notebookRESTClient) ListNotebookExecutionJobs(ctx context.Context, req *aiplatformpb.ListNotebookExecutionJobsRequest, opts ...gax.CallOption) *NotebookExecutionJobIterator {
  2113  	it := &NotebookExecutionJobIterator{}
  2114  	req = proto.Clone(req).(*aiplatformpb.ListNotebookExecutionJobsRequest)
  2115  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2116  	it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookExecutionJob, string, error) {
  2117  		resp := &aiplatformpb.ListNotebookExecutionJobsResponse{}
  2118  		if pageToken != "" {
  2119  			req.PageToken = pageToken
  2120  		}
  2121  		if pageSize > math.MaxInt32 {
  2122  			req.PageSize = math.MaxInt32
  2123  		} else if pageSize != 0 {
  2124  			req.PageSize = int32(pageSize)
  2125  		}
  2126  		baseUrl, err := url.Parse(c.endpoint)
  2127  		if err != nil {
  2128  			return nil, "", err
  2129  		}
  2130  		baseUrl.Path += fmt.Sprintf("/v1beta1/%v/notebookExecutionJobs", req.GetParent())
  2131  
  2132  		params := url.Values{}
  2133  		params.Add("$alt", "json;enum-encoding=int")
  2134  		if req.GetFilter() != "" {
  2135  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2136  		}
  2137  		if req.GetOrderBy() != "" {
  2138  			params.Add("orderBy", fmt.Sprintf("%v", req.GetOrderBy()))
  2139  		}
  2140  		if req.GetPageSize() != 0 {
  2141  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2142  		}
  2143  		if req.GetPageToken() != "" {
  2144  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2145  		}
  2146  		if req.GetView() != 0 {
  2147  			params.Add("view", fmt.Sprintf("%v", req.GetView()))
  2148  		}
  2149  
  2150  		baseUrl.RawQuery = params.Encode()
  2151  
  2152  		// Build HTTP headers from client and context metadata.
  2153  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2154  		headers := gax.BuildHeaders(ctx, hds...)
  2155  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2156  			if settings.Path != "" {
  2157  				baseUrl.Path = settings.Path
  2158  			}
  2159  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2160  			if err != nil {
  2161  				return err
  2162  			}
  2163  			httpReq.Header = headers
  2164  
  2165  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListNotebookExecutionJobs")
  2166  			if err != nil {
  2167  				return err
  2168  			}
  2169  			if err := unm.Unmarshal(buf, resp); err != nil {
  2170  				return err
  2171  			}
  2172  
  2173  			return nil
  2174  		}, opts...)
  2175  		if e != nil {
  2176  			return nil, "", e
  2177  		}
  2178  		it.Response = resp
  2179  		return resp.GetNotebookExecutionJobs(), resp.GetNextPageToken(), nil
  2180  	}
  2181  
  2182  	fetch := func(pageSize int, pageToken string) (string, error) {
  2183  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2184  		if err != nil {
  2185  			return "", err
  2186  		}
  2187  		it.items = append(it.items, items...)
  2188  		return nextPageToken, nil
  2189  	}
  2190  
  2191  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2192  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2193  	it.pageInfo.Token = req.GetPageToken()
  2194  
  2195  	return it
  2196  }
  2197  
  2198  // DeleteNotebookExecutionJob deletes a NotebookExecutionJob.
  2199  func (c *notebookRESTClient) DeleteNotebookExecutionJob(ctx context.Context, req *aiplatformpb.DeleteNotebookExecutionJobRequest, opts ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error) {
  2200  	baseUrl, err := url.Parse(c.endpoint)
  2201  	if err != nil {
  2202  		return nil, err
  2203  	}
  2204  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v", req.GetName())
  2205  
  2206  	params := url.Values{}
  2207  	params.Add("$alt", "json;enum-encoding=int")
  2208  
  2209  	baseUrl.RawQuery = params.Encode()
  2210  
  2211  	// Build HTTP headers from client and context metadata.
  2212  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2213  
  2214  	hds = append(c.xGoogHeaders, hds...)
  2215  	hds = append(hds, "Content-Type", "application/json")
  2216  	headers := gax.BuildHeaders(ctx, hds...)
  2217  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2218  	resp := &longrunningpb.Operation{}
  2219  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2220  		if settings.Path != "" {
  2221  			baseUrl.Path = settings.Path
  2222  		}
  2223  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2224  		if err != nil {
  2225  			return err
  2226  		}
  2227  		httpReq = httpReq.WithContext(ctx)
  2228  		httpReq.Header = headers
  2229  
  2230  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteNotebookExecutionJob")
  2231  		if err != nil {
  2232  			return err
  2233  		}
  2234  		if err := unm.Unmarshal(buf, resp); err != nil {
  2235  			return err
  2236  		}
  2237  
  2238  		return nil
  2239  	}, opts...)
  2240  	if e != nil {
  2241  		return nil, e
  2242  	}
  2243  
  2244  	override := fmt.Sprintf("/ui/%s", resp.GetName())
  2245  	return &DeleteNotebookExecutionJobOperation{
  2246  		lro:      longrunning.InternalNewOperation(*c.LROClient, resp),
  2247  		pollPath: override,
  2248  	}, nil
  2249  }
  2250  
  2251  // GetLocation gets information about a location.
  2252  func (c *notebookRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
  2253  	baseUrl, err := url.Parse(c.endpoint)
  2254  	if err != nil {
  2255  		return nil, err
  2256  	}
  2257  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  2258  
  2259  	params := url.Values{}
  2260  	params.Add("$alt", "json;enum-encoding=int")
  2261  
  2262  	baseUrl.RawQuery = params.Encode()
  2263  
  2264  	// Build HTTP headers from client and context metadata.
  2265  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2266  
  2267  	hds = append(c.xGoogHeaders, hds...)
  2268  	hds = append(hds, "Content-Type", "application/json")
  2269  	headers := gax.BuildHeaders(ctx, hds...)
  2270  	opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
  2271  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2272  	resp := &locationpb.Location{}
  2273  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2274  		if settings.Path != "" {
  2275  			baseUrl.Path = settings.Path
  2276  		}
  2277  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2278  		if err != nil {
  2279  			return err
  2280  		}
  2281  		httpReq = httpReq.WithContext(ctx)
  2282  		httpReq.Header = headers
  2283  
  2284  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
  2285  		if err != nil {
  2286  			return err
  2287  		}
  2288  
  2289  		if err := unm.Unmarshal(buf, resp); err != nil {
  2290  			return err
  2291  		}
  2292  
  2293  		return nil
  2294  	}, opts...)
  2295  	if e != nil {
  2296  		return nil, e
  2297  	}
  2298  	return resp, nil
  2299  }
  2300  
  2301  // ListLocations lists information about the supported locations for this service.
  2302  func (c *notebookRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
  2303  	it := &LocationIterator{}
  2304  	req = proto.Clone(req).(*locationpb.ListLocationsRequest)
  2305  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2306  	it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
  2307  		resp := &locationpb.ListLocationsResponse{}
  2308  		if pageToken != "" {
  2309  			req.PageToken = pageToken
  2310  		}
  2311  		if pageSize > math.MaxInt32 {
  2312  			req.PageSize = math.MaxInt32
  2313  		} else if pageSize != 0 {
  2314  			req.PageSize = int32(pageSize)
  2315  		}
  2316  		baseUrl, err := url.Parse(c.endpoint)
  2317  		if err != nil {
  2318  			return nil, "", err
  2319  		}
  2320  		baseUrl.Path += fmt.Sprintf("/ui/%v/locations", req.GetName())
  2321  
  2322  		params := url.Values{}
  2323  		params.Add("$alt", "json;enum-encoding=int")
  2324  		if req.GetFilter() != "" {
  2325  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2326  		}
  2327  		if req.GetPageSize() != 0 {
  2328  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2329  		}
  2330  		if req.GetPageToken() != "" {
  2331  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2332  		}
  2333  
  2334  		baseUrl.RawQuery = params.Encode()
  2335  
  2336  		// Build HTTP headers from client and context metadata.
  2337  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2338  		headers := gax.BuildHeaders(ctx, hds...)
  2339  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2340  			if settings.Path != "" {
  2341  				baseUrl.Path = settings.Path
  2342  			}
  2343  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2344  			if err != nil {
  2345  				return err
  2346  			}
  2347  			httpReq.Header = headers
  2348  
  2349  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
  2350  			if err != nil {
  2351  				return err
  2352  			}
  2353  			if err := unm.Unmarshal(buf, resp); err != nil {
  2354  				return err
  2355  			}
  2356  
  2357  			return nil
  2358  		}, opts...)
  2359  		if e != nil {
  2360  			return nil, "", e
  2361  		}
  2362  		it.Response = resp
  2363  		return resp.GetLocations(), resp.GetNextPageToken(), nil
  2364  	}
  2365  
  2366  	fetch := func(pageSize int, pageToken string) (string, error) {
  2367  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2368  		if err != nil {
  2369  			return "", err
  2370  		}
  2371  		it.items = append(it.items, items...)
  2372  		return nextPageToken, nil
  2373  	}
  2374  
  2375  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2376  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2377  	it.pageInfo.Token = req.GetPageToken()
  2378  
  2379  	return it
  2380  }
  2381  
  2382  // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
  2383  // if the resource exists and does not have a policy set.
  2384  func (c *notebookRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  2385  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2386  	jsonReq, err := m.Marshal(req)
  2387  	if err != nil {
  2388  		return nil, err
  2389  	}
  2390  
  2391  	baseUrl, err := url.Parse(c.endpoint)
  2392  	if err != nil {
  2393  		return nil, err
  2394  	}
  2395  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:getIamPolicy", req.GetResource())
  2396  
  2397  	params := url.Values{}
  2398  	params.Add("$alt", "json;enum-encoding=int")
  2399  
  2400  	baseUrl.RawQuery = params.Encode()
  2401  
  2402  	// Build HTTP headers from client and context metadata.
  2403  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  2404  
  2405  	hds = append(c.xGoogHeaders, hds...)
  2406  	hds = append(hds, "Content-Type", "application/json")
  2407  	headers := gax.BuildHeaders(ctx, hds...)
  2408  	opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
  2409  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2410  	resp := &iampb.Policy{}
  2411  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2412  		if settings.Path != "" {
  2413  			baseUrl.Path = settings.Path
  2414  		}
  2415  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2416  		if err != nil {
  2417  			return err
  2418  		}
  2419  		httpReq = httpReq.WithContext(ctx)
  2420  		httpReq.Header = headers
  2421  
  2422  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "GetIamPolicy")
  2423  		if err != nil {
  2424  			return err
  2425  		}
  2426  
  2427  		if err := unm.Unmarshal(buf, resp); err != nil {
  2428  			return err
  2429  		}
  2430  
  2431  		return nil
  2432  	}, opts...)
  2433  	if e != nil {
  2434  		return nil, e
  2435  	}
  2436  	return resp, nil
  2437  }
  2438  
  2439  // SetIamPolicy sets the access control policy on the specified resource. Replaces
  2440  // any existing policy.
  2441  //
  2442  // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
  2443  // errors.
  2444  func (c *notebookRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
  2445  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2446  	jsonReq, err := m.Marshal(req)
  2447  	if err != nil {
  2448  		return nil, err
  2449  	}
  2450  
  2451  	baseUrl, err := url.Parse(c.endpoint)
  2452  	if err != nil {
  2453  		return nil, err
  2454  	}
  2455  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:setIamPolicy", req.GetResource())
  2456  
  2457  	params := url.Values{}
  2458  	params.Add("$alt", "json;enum-encoding=int")
  2459  
  2460  	baseUrl.RawQuery = params.Encode()
  2461  
  2462  	// Build HTTP headers from client and context metadata.
  2463  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  2464  
  2465  	hds = append(c.xGoogHeaders, hds...)
  2466  	hds = append(hds, "Content-Type", "application/json")
  2467  	headers := gax.BuildHeaders(ctx, hds...)
  2468  	opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
  2469  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2470  	resp := &iampb.Policy{}
  2471  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2472  		if settings.Path != "" {
  2473  			baseUrl.Path = settings.Path
  2474  		}
  2475  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2476  		if err != nil {
  2477  			return err
  2478  		}
  2479  		httpReq = httpReq.WithContext(ctx)
  2480  		httpReq.Header = headers
  2481  
  2482  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
  2483  		if err != nil {
  2484  			return err
  2485  		}
  2486  
  2487  		if err := unm.Unmarshal(buf, resp); err != nil {
  2488  			return err
  2489  		}
  2490  
  2491  		return nil
  2492  	}, opts...)
  2493  	if e != nil {
  2494  		return nil, e
  2495  	}
  2496  	return resp, nil
  2497  }
  2498  
  2499  // TestIamPermissions returns permissions that a caller has on the specified resource. If the
  2500  // resource does not exist, this will return an empty set of
  2501  // permissions, not a NOT_FOUND error.
  2502  //
  2503  // Note: This operation is designed to be used for building
  2504  // permission-aware UIs and command-line tools, not for authorization
  2505  // checking. This operation may “fail open” without warning.
  2506  func (c *notebookRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
  2507  	m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
  2508  	jsonReq, err := m.Marshal(req)
  2509  	if err != nil {
  2510  		return nil, err
  2511  	}
  2512  
  2513  	baseUrl, err := url.Parse(c.endpoint)
  2514  	if err != nil {
  2515  		return nil, err
  2516  	}
  2517  	baseUrl.Path += fmt.Sprintf("/v1beta1/%v:testIamPermissions", req.GetResource())
  2518  
  2519  	params := url.Values{}
  2520  	params.Add("$alt", "json;enum-encoding=int")
  2521  
  2522  	baseUrl.RawQuery = params.Encode()
  2523  
  2524  	// Build HTTP headers from client and context metadata.
  2525  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
  2526  
  2527  	hds = append(c.xGoogHeaders, hds...)
  2528  	hds = append(hds, "Content-Type", "application/json")
  2529  	headers := gax.BuildHeaders(ctx, hds...)
  2530  	opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
  2531  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2532  	resp := &iampb.TestIamPermissionsResponse{}
  2533  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2534  		if settings.Path != "" {
  2535  			baseUrl.Path = settings.Path
  2536  		}
  2537  		httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
  2538  		if err != nil {
  2539  			return err
  2540  		}
  2541  		httpReq = httpReq.WithContext(ctx)
  2542  		httpReq.Header = headers
  2543  
  2544  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
  2545  		if err != nil {
  2546  			return err
  2547  		}
  2548  
  2549  		if err := unm.Unmarshal(buf, resp); err != nil {
  2550  			return err
  2551  		}
  2552  
  2553  		return nil
  2554  	}, opts...)
  2555  	if e != nil {
  2556  		return nil, e
  2557  	}
  2558  	return resp, nil
  2559  }
  2560  
  2561  // CancelOperation is a utility method from google.longrunning.Operations.
  2562  func (c *notebookRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
  2563  	baseUrl, err := url.Parse(c.endpoint)
  2564  	if err != nil {
  2565  		return err
  2566  	}
  2567  	baseUrl.Path += fmt.Sprintf("/ui/%v:cancel", req.GetName())
  2568  
  2569  	params := url.Values{}
  2570  	params.Add("$alt", "json;enum-encoding=int")
  2571  
  2572  	baseUrl.RawQuery = params.Encode()
  2573  
  2574  	// Build HTTP headers from client and context metadata.
  2575  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2576  
  2577  	hds = append(c.xGoogHeaders, hds...)
  2578  	hds = append(hds, "Content-Type", "application/json")
  2579  	headers := gax.BuildHeaders(ctx, hds...)
  2580  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2581  		if settings.Path != "" {
  2582  			baseUrl.Path = settings.Path
  2583  		}
  2584  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  2585  		if err != nil {
  2586  			return err
  2587  		}
  2588  		httpReq = httpReq.WithContext(ctx)
  2589  		httpReq.Header = headers
  2590  
  2591  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "CancelOperation")
  2592  		return err
  2593  	}, opts...)
  2594  }
  2595  
  2596  // DeleteOperation is a utility method from google.longrunning.Operations.
  2597  func (c *notebookRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
  2598  	baseUrl, err := url.Parse(c.endpoint)
  2599  	if err != nil {
  2600  		return err
  2601  	}
  2602  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  2603  
  2604  	params := url.Values{}
  2605  	params.Add("$alt", "json;enum-encoding=int")
  2606  
  2607  	baseUrl.RawQuery = params.Encode()
  2608  
  2609  	// Build HTTP headers from client and context metadata.
  2610  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2611  
  2612  	hds = append(c.xGoogHeaders, hds...)
  2613  	hds = append(hds, "Content-Type", "application/json")
  2614  	headers := gax.BuildHeaders(ctx, hds...)
  2615  	return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2616  		if settings.Path != "" {
  2617  			baseUrl.Path = settings.Path
  2618  		}
  2619  		httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
  2620  		if err != nil {
  2621  			return err
  2622  		}
  2623  		httpReq = httpReq.WithContext(ctx)
  2624  		httpReq.Header = headers
  2625  
  2626  		_, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
  2627  		return err
  2628  	}, opts...)
  2629  }
  2630  
  2631  // GetOperation is a utility method from google.longrunning.Operations.
  2632  func (c *notebookRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  2633  	baseUrl, err := url.Parse(c.endpoint)
  2634  	if err != nil {
  2635  		return nil, err
  2636  	}
  2637  	baseUrl.Path += fmt.Sprintf("/ui/%v", req.GetName())
  2638  
  2639  	params := url.Values{}
  2640  	params.Add("$alt", "json;enum-encoding=int")
  2641  
  2642  	baseUrl.RawQuery = params.Encode()
  2643  
  2644  	// Build HTTP headers from client and context metadata.
  2645  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2646  
  2647  	hds = append(c.xGoogHeaders, hds...)
  2648  	hds = append(hds, "Content-Type", "application/json")
  2649  	headers := gax.BuildHeaders(ctx, hds...)
  2650  	opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
  2651  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2652  	resp := &longrunningpb.Operation{}
  2653  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2654  		if settings.Path != "" {
  2655  			baseUrl.Path = settings.Path
  2656  		}
  2657  		httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2658  		if err != nil {
  2659  			return err
  2660  		}
  2661  		httpReq = httpReq.WithContext(ctx)
  2662  		httpReq.Header = headers
  2663  
  2664  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
  2665  		if err != nil {
  2666  			return err
  2667  		}
  2668  
  2669  		if err := unm.Unmarshal(buf, resp); err != nil {
  2670  			return err
  2671  		}
  2672  
  2673  		return nil
  2674  	}, opts...)
  2675  	if e != nil {
  2676  		return nil, e
  2677  	}
  2678  	return resp, nil
  2679  }
  2680  
  2681  // ListOperations is a utility method from google.longrunning.Operations.
  2682  func (c *notebookRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
  2683  	it := &OperationIterator{}
  2684  	req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
  2685  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2686  	it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
  2687  		resp := &longrunningpb.ListOperationsResponse{}
  2688  		if pageToken != "" {
  2689  			req.PageToken = pageToken
  2690  		}
  2691  		if pageSize > math.MaxInt32 {
  2692  			req.PageSize = math.MaxInt32
  2693  		} else if pageSize != 0 {
  2694  			req.PageSize = int32(pageSize)
  2695  		}
  2696  		baseUrl, err := url.Parse(c.endpoint)
  2697  		if err != nil {
  2698  			return nil, "", err
  2699  		}
  2700  		baseUrl.Path += fmt.Sprintf("/ui/%v/operations", req.GetName())
  2701  
  2702  		params := url.Values{}
  2703  		params.Add("$alt", "json;enum-encoding=int")
  2704  		if req.GetFilter() != "" {
  2705  			params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
  2706  		}
  2707  		if req.GetPageSize() != 0 {
  2708  			params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
  2709  		}
  2710  		if req.GetPageToken() != "" {
  2711  			params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
  2712  		}
  2713  
  2714  		baseUrl.RawQuery = params.Encode()
  2715  
  2716  		// Build HTTP headers from client and context metadata.
  2717  		hds := append(c.xGoogHeaders, "Content-Type", "application/json")
  2718  		headers := gax.BuildHeaders(ctx, hds...)
  2719  		e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2720  			if settings.Path != "" {
  2721  				baseUrl.Path = settings.Path
  2722  			}
  2723  			httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
  2724  			if err != nil {
  2725  				return err
  2726  			}
  2727  			httpReq.Header = headers
  2728  
  2729  			buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
  2730  			if err != nil {
  2731  				return err
  2732  			}
  2733  			if err := unm.Unmarshal(buf, resp); err != nil {
  2734  				return err
  2735  			}
  2736  
  2737  			return nil
  2738  		}, opts...)
  2739  		if e != nil {
  2740  			return nil, "", e
  2741  		}
  2742  		it.Response = resp
  2743  		return resp.GetOperations(), resp.GetNextPageToken(), nil
  2744  	}
  2745  
  2746  	fetch := func(pageSize int, pageToken string) (string, error) {
  2747  		items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
  2748  		if err != nil {
  2749  			return "", err
  2750  		}
  2751  		it.items = append(it.items, items...)
  2752  		return nextPageToken, nil
  2753  	}
  2754  
  2755  	it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
  2756  	it.pageInfo.MaxSize = int(req.GetPageSize())
  2757  	it.pageInfo.Token = req.GetPageToken()
  2758  
  2759  	return it
  2760  }
  2761  
  2762  // WaitOperation is a utility method from google.longrunning.Operations.
  2763  func (c *notebookRESTClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
  2764  	baseUrl, err := url.Parse(c.endpoint)
  2765  	if err != nil {
  2766  		return nil, err
  2767  	}
  2768  	baseUrl.Path += fmt.Sprintf("/ui/%v:wait", req.GetName())
  2769  
  2770  	params := url.Values{}
  2771  	params.Add("$alt", "json;enum-encoding=int")
  2772  	if req.GetTimeout() != nil {
  2773  		field, err := protojson.Marshal(req.GetTimeout())
  2774  		if err != nil {
  2775  			return nil, err
  2776  		}
  2777  		params.Add("timeout", string(field[1:len(field)-1]))
  2778  	}
  2779  
  2780  	baseUrl.RawQuery = params.Encode()
  2781  
  2782  	// Build HTTP headers from client and context metadata.
  2783  	hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
  2784  
  2785  	hds = append(c.xGoogHeaders, hds...)
  2786  	hds = append(hds, "Content-Type", "application/json")
  2787  	headers := gax.BuildHeaders(ctx, hds...)
  2788  	opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...)
  2789  	unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
  2790  	resp := &longrunningpb.Operation{}
  2791  	e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
  2792  		if settings.Path != "" {
  2793  			baseUrl.Path = settings.Path
  2794  		}
  2795  		httpReq, err := http.NewRequest("POST", baseUrl.String(), nil)
  2796  		if err != nil {
  2797  			return err
  2798  		}
  2799  		httpReq = httpReq.WithContext(ctx)
  2800  		httpReq.Header = headers
  2801  
  2802  		buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "WaitOperation")
  2803  		if err != nil {
  2804  			return err
  2805  		}
  2806  
  2807  		if err := unm.Unmarshal(buf, resp); err != nil {
  2808  			return err
  2809  		}
  2810  
  2811  		return nil
  2812  	}, opts...)
  2813  	if e != nil {
  2814  		return nil, e
  2815  	}
  2816  	return resp, nil
  2817  }
  2818  
  2819  // AssignNotebookRuntimeOperation returns a new AssignNotebookRuntimeOperation from a given name.
  2820  // The name must be that of a previously created AssignNotebookRuntimeOperation, possibly from a different process.
  2821  func (c *notebookGRPCClient) AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation {
  2822  	return &AssignNotebookRuntimeOperation{
  2823  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2824  	}
  2825  }
  2826  
  2827  // AssignNotebookRuntimeOperation returns a new AssignNotebookRuntimeOperation from a given name.
  2828  // The name must be that of a previously created AssignNotebookRuntimeOperation, possibly from a different process.
  2829  func (c *notebookRESTClient) AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation {
  2830  	override := fmt.Sprintf("/ui/%s", name)
  2831  	return &AssignNotebookRuntimeOperation{
  2832  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2833  		pollPath: override,
  2834  	}
  2835  }
  2836  
  2837  // CreateNotebookExecutionJobOperation returns a new CreateNotebookExecutionJobOperation from a given name.
  2838  // The name must be that of a previously created CreateNotebookExecutionJobOperation, possibly from a different process.
  2839  func (c *notebookGRPCClient) CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation {
  2840  	return &CreateNotebookExecutionJobOperation{
  2841  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2842  	}
  2843  }
  2844  
  2845  // CreateNotebookExecutionJobOperation returns a new CreateNotebookExecutionJobOperation from a given name.
  2846  // The name must be that of a previously created CreateNotebookExecutionJobOperation, possibly from a different process.
  2847  func (c *notebookRESTClient) CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation {
  2848  	override := fmt.Sprintf("/ui/%s", name)
  2849  	return &CreateNotebookExecutionJobOperation{
  2850  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2851  		pollPath: override,
  2852  	}
  2853  }
  2854  
  2855  // CreateNotebookRuntimeTemplateOperation returns a new CreateNotebookRuntimeTemplateOperation from a given name.
  2856  // The name must be that of a previously created CreateNotebookRuntimeTemplateOperation, possibly from a different process.
  2857  func (c *notebookGRPCClient) CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation {
  2858  	return &CreateNotebookRuntimeTemplateOperation{
  2859  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2860  	}
  2861  }
  2862  
  2863  // CreateNotebookRuntimeTemplateOperation returns a new CreateNotebookRuntimeTemplateOperation from a given name.
  2864  // The name must be that of a previously created CreateNotebookRuntimeTemplateOperation, possibly from a different process.
  2865  func (c *notebookRESTClient) CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation {
  2866  	override := fmt.Sprintf("/ui/%s", name)
  2867  	return &CreateNotebookRuntimeTemplateOperation{
  2868  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2869  		pollPath: override,
  2870  	}
  2871  }
  2872  
  2873  // DeleteNotebookExecutionJobOperation returns a new DeleteNotebookExecutionJobOperation from a given name.
  2874  // The name must be that of a previously created DeleteNotebookExecutionJobOperation, possibly from a different process.
  2875  func (c *notebookGRPCClient) DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation {
  2876  	return &DeleteNotebookExecutionJobOperation{
  2877  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2878  	}
  2879  }
  2880  
  2881  // DeleteNotebookExecutionJobOperation returns a new DeleteNotebookExecutionJobOperation from a given name.
  2882  // The name must be that of a previously created DeleteNotebookExecutionJobOperation, possibly from a different process.
  2883  func (c *notebookRESTClient) DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation {
  2884  	override := fmt.Sprintf("/ui/%s", name)
  2885  	return &DeleteNotebookExecutionJobOperation{
  2886  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2887  		pollPath: override,
  2888  	}
  2889  }
  2890  
  2891  // DeleteNotebookRuntimeOperation returns a new DeleteNotebookRuntimeOperation from a given name.
  2892  // The name must be that of a previously created DeleteNotebookRuntimeOperation, possibly from a different process.
  2893  func (c *notebookGRPCClient) DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation {
  2894  	return &DeleteNotebookRuntimeOperation{
  2895  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2896  	}
  2897  }
  2898  
  2899  // DeleteNotebookRuntimeOperation returns a new DeleteNotebookRuntimeOperation from a given name.
  2900  // The name must be that of a previously created DeleteNotebookRuntimeOperation, possibly from a different process.
  2901  func (c *notebookRESTClient) DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation {
  2902  	override := fmt.Sprintf("/ui/%s", name)
  2903  	return &DeleteNotebookRuntimeOperation{
  2904  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2905  		pollPath: override,
  2906  	}
  2907  }
  2908  
  2909  // DeleteNotebookRuntimeTemplateOperation returns a new DeleteNotebookRuntimeTemplateOperation from a given name.
  2910  // The name must be that of a previously created DeleteNotebookRuntimeTemplateOperation, possibly from a different process.
  2911  func (c *notebookGRPCClient) DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation {
  2912  	return &DeleteNotebookRuntimeTemplateOperation{
  2913  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2914  	}
  2915  }
  2916  
  2917  // DeleteNotebookRuntimeTemplateOperation returns a new DeleteNotebookRuntimeTemplateOperation from a given name.
  2918  // The name must be that of a previously created DeleteNotebookRuntimeTemplateOperation, possibly from a different process.
  2919  func (c *notebookRESTClient) DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation {
  2920  	override := fmt.Sprintf("/ui/%s", name)
  2921  	return &DeleteNotebookRuntimeTemplateOperation{
  2922  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2923  		pollPath: override,
  2924  	}
  2925  }
  2926  
  2927  // StartNotebookRuntimeOperation returns a new StartNotebookRuntimeOperation from a given name.
  2928  // The name must be that of a previously created StartNotebookRuntimeOperation, possibly from a different process.
  2929  func (c *notebookGRPCClient) StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation {
  2930  	return &StartNotebookRuntimeOperation{
  2931  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2932  	}
  2933  }
  2934  
  2935  // StartNotebookRuntimeOperation returns a new StartNotebookRuntimeOperation from a given name.
  2936  // The name must be that of a previously created StartNotebookRuntimeOperation, possibly from a different process.
  2937  func (c *notebookRESTClient) StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation {
  2938  	override := fmt.Sprintf("/ui/%s", name)
  2939  	return &StartNotebookRuntimeOperation{
  2940  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2941  		pollPath: override,
  2942  	}
  2943  }
  2944  
  2945  // StopNotebookRuntimeOperation returns a new StopNotebookRuntimeOperation from a given name.
  2946  // The name must be that of a previously created StopNotebookRuntimeOperation, possibly from a different process.
  2947  func (c *notebookGRPCClient) StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation {
  2948  	return &StopNotebookRuntimeOperation{
  2949  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2950  	}
  2951  }
  2952  
  2953  // StopNotebookRuntimeOperation returns a new StopNotebookRuntimeOperation from a given name.
  2954  // The name must be that of a previously created StopNotebookRuntimeOperation, possibly from a different process.
  2955  func (c *notebookRESTClient) StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation {
  2956  	override := fmt.Sprintf("/ui/%s", name)
  2957  	return &StopNotebookRuntimeOperation{
  2958  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2959  		pollPath: override,
  2960  	}
  2961  }
  2962  
  2963  // UpgradeNotebookRuntimeOperation returns a new UpgradeNotebookRuntimeOperation from a given name.
  2964  // The name must be that of a previously created UpgradeNotebookRuntimeOperation, possibly from a different process.
  2965  func (c *notebookGRPCClient) UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation {
  2966  	return &UpgradeNotebookRuntimeOperation{
  2967  		lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2968  	}
  2969  }
  2970  
  2971  // UpgradeNotebookRuntimeOperation returns a new UpgradeNotebookRuntimeOperation from a given name.
  2972  // The name must be that of a previously created UpgradeNotebookRuntimeOperation, possibly from a different process.
  2973  func (c *notebookRESTClient) UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation {
  2974  	override := fmt.Sprintf("/ui/%s", name)
  2975  	return &UpgradeNotebookRuntimeOperation{
  2976  		lro:      longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}),
  2977  		pollPath: override,
  2978  	}
  2979  }