cloud.google.com/go/aiplatform@v1.106.0/apiv1/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 "context" 21 "fmt" 22 "log/slog" 23 "math" 24 "net/url" 25 26 aiplatformpb "cloud.google.com/go/aiplatform/apiv1/aiplatformpb" 27 iampb "cloud.google.com/go/iam/apiv1/iampb" 28 "cloud.google.com/go/longrunning" 29 lroauto "cloud.google.com/go/longrunning/autogen" 30 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" 31 gax "github.com/googleapis/gax-go/v2" 32 "google.golang.org/api/iterator" 33 "google.golang.org/api/option" 34 "google.golang.org/api/option/internaloption" 35 gtransport "google.golang.org/api/transport/grpc" 36 locationpb "google.golang.org/genproto/googleapis/cloud/location" 37 "google.golang.org/grpc" 38 "google.golang.org/protobuf/proto" 39 ) 40 41 var newNotebookClientHook clientHook 42 43 // NotebookCallOptions contains the retry settings for each method of NotebookClient. 44 type NotebookCallOptions struct { 45 CreateNotebookRuntimeTemplate []gax.CallOption 46 GetNotebookRuntimeTemplate []gax.CallOption 47 ListNotebookRuntimeTemplates []gax.CallOption 48 DeleteNotebookRuntimeTemplate []gax.CallOption 49 UpdateNotebookRuntimeTemplate []gax.CallOption 50 AssignNotebookRuntime []gax.CallOption 51 GetNotebookRuntime []gax.CallOption 52 ListNotebookRuntimes []gax.CallOption 53 DeleteNotebookRuntime []gax.CallOption 54 UpgradeNotebookRuntime []gax.CallOption 55 StartNotebookRuntime []gax.CallOption 56 StopNotebookRuntime []gax.CallOption 57 CreateNotebookExecutionJob []gax.CallOption 58 GetNotebookExecutionJob []gax.CallOption 59 ListNotebookExecutionJobs []gax.CallOption 60 DeleteNotebookExecutionJob []gax.CallOption 61 GetLocation []gax.CallOption 62 ListLocations []gax.CallOption 63 GetIamPolicy []gax.CallOption 64 SetIamPolicy []gax.CallOption 65 TestIamPermissions []gax.CallOption 66 CancelOperation []gax.CallOption 67 DeleteOperation []gax.CallOption 68 GetOperation []gax.CallOption 69 ListOperations []gax.CallOption 70 WaitOperation []gax.CallOption 71 } 72 73 func defaultNotebookGRPCClientOptions() []option.ClientOption { 74 return []option.ClientOption{ 75 internaloption.WithDefaultEndpoint("aiplatform.googleapis.com:443"), 76 internaloption.WithDefaultEndpointTemplate("aiplatform.UNIVERSE_DOMAIN:443"), 77 internaloption.WithDefaultMTLSEndpoint("aiplatform.mtls.googleapis.com:443"), 78 internaloption.WithDefaultUniverseDomain("googleapis.com"), 79 internaloption.WithDefaultAudience("https://aiplatform.googleapis.com/"), 80 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 81 internaloption.EnableJwtWithScope(), 82 internaloption.EnableNewAuthLibrary(), 83 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 84 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 85 } 86 } 87 88 func defaultNotebookCallOptions() *NotebookCallOptions { 89 return &NotebookCallOptions{ 90 CreateNotebookRuntimeTemplate: []gax.CallOption{}, 91 GetNotebookRuntimeTemplate: []gax.CallOption{}, 92 ListNotebookRuntimeTemplates: []gax.CallOption{}, 93 DeleteNotebookRuntimeTemplate: []gax.CallOption{}, 94 UpdateNotebookRuntimeTemplate: []gax.CallOption{}, 95 AssignNotebookRuntime: []gax.CallOption{}, 96 GetNotebookRuntime: []gax.CallOption{}, 97 ListNotebookRuntimes: []gax.CallOption{}, 98 DeleteNotebookRuntime: []gax.CallOption{}, 99 UpgradeNotebookRuntime: []gax.CallOption{}, 100 StartNotebookRuntime: []gax.CallOption{}, 101 StopNotebookRuntime: []gax.CallOption{}, 102 CreateNotebookExecutionJob: []gax.CallOption{}, 103 GetNotebookExecutionJob: []gax.CallOption{}, 104 ListNotebookExecutionJobs: []gax.CallOption{}, 105 DeleteNotebookExecutionJob: []gax.CallOption{}, 106 GetLocation: []gax.CallOption{}, 107 ListLocations: []gax.CallOption{}, 108 GetIamPolicy: []gax.CallOption{}, 109 SetIamPolicy: []gax.CallOption{}, 110 TestIamPermissions: []gax.CallOption{}, 111 CancelOperation: []gax.CallOption{}, 112 DeleteOperation: []gax.CallOption{}, 113 GetOperation: []gax.CallOption{}, 114 ListOperations: []gax.CallOption{}, 115 WaitOperation: []gax.CallOption{}, 116 } 117 } 118 119 // internalNotebookClient is an interface that defines the methods available from Vertex AI API. 120 type internalNotebookClient interface { 121 Close() error 122 setGoogleClientInfo(...string) 123 Connection() *grpc.ClientConn 124 CreateNotebookRuntimeTemplate(context.Context, *aiplatformpb.CreateNotebookRuntimeTemplateRequest, ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error) 125 CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation 126 GetNotebookRuntimeTemplate(context.Context, *aiplatformpb.GetNotebookRuntimeTemplateRequest, ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) 127 ListNotebookRuntimeTemplates(context.Context, *aiplatformpb.ListNotebookRuntimeTemplatesRequest, ...gax.CallOption) *NotebookRuntimeTemplateIterator 128 DeleteNotebookRuntimeTemplate(context.Context, *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error) 129 DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation 130 UpdateNotebookRuntimeTemplate(context.Context, *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) 131 AssignNotebookRuntime(context.Context, *aiplatformpb.AssignNotebookRuntimeRequest, ...gax.CallOption) (*AssignNotebookRuntimeOperation, error) 132 AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation 133 GetNotebookRuntime(context.Context, *aiplatformpb.GetNotebookRuntimeRequest, ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error) 134 ListNotebookRuntimes(context.Context, *aiplatformpb.ListNotebookRuntimesRequest, ...gax.CallOption) *NotebookRuntimeIterator 135 DeleteNotebookRuntime(context.Context, *aiplatformpb.DeleteNotebookRuntimeRequest, ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error) 136 DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation 137 UpgradeNotebookRuntime(context.Context, *aiplatformpb.UpgradeNotebookRuntimeRequest, ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error) 138 UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation 139 StartNotebookRuntime(context.Context, *aiplatformpb.StartNotebookRuntimeRequest, ...gax.CallOption) (*StartNotebookRuntimeOperation, error) 140 StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation 141 StopNotebookRuntime(context.Context, *aiplatformpb.StopNotebookRuntimeRequest, ...gax.CallOption) (*StopNotebookRuntimeOperation, error) 142 StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation 143 CreateNotebookExecutionJob(context.Context, *aiplatformpb.CreateNotebookExecutionJobRequest, ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error) 144 CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation 145 GetNotebookExecutionJob(context.Context, *aiplatformpb.GetNotebookExecutionJobRequest, ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error) 146 ListNotebookExecutionJobs(context.Context, *aiplatformpb.ListNotebookExecutionJobsRequest, ...gax.CallOption) *NotebookExecutionJobIterator 147 DeleteNotebookExecutionJob(context.Context, *aiplatformpb.DeleteNotebookExecutionJobRequest, ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error) 148 DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation 149 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error) 150 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator 151 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 152 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error) 153 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) 154 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error 155 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error 156 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 157 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator 158 WaitOperation(context.Context, *longrunningpb.WaitOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error) 159 } 160 161 // NotebookClient is a client for interacting with Vertex AI API. 162 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 163 // 164 // The interface for Vertex Notebook service (a.k.a. Colab on Workbench). 165 type NotebookClient struct { 166 // The internal transport-dependent client. 167 internalClient internalNotebookClient 168 169 // The call options for this service. 170 CallOptions *NotebookCallOptions 171 172 // LROClient is used internally to handle long-running operations. 173 // It is exposed so that its CallOptions can be modified if required. 174 // Users should not Close this client. 175 LROClient *lroauto.OperationsClient 176 } 177 178 // Wrapper methods routed to the internal client. 179 180 // Close closes the connection to the API service. The user should invoke this when 181 // the client is no longer required. 182 func (c *NotebookClient) Close() error { 183 return c.internalClient.Close() 184 } 185 186 // setGoogleClientInfo sets the name and version of the application in 187 // the `x-goog-api-client` header passed on each request. Intended for 188 // use by Google-written clients. 189 func (c *NotebookClient) setGoogleClientInfo(keyval ...string) { 190 c.internalClient.setGoogleClientInfo(keyval...) 191 } 192 193 // Connection returns a connection to the API service. 194 // 195 // Deprecated: Connections are now pooled so this method does not always 196 // return the same resource. 197 func (c *NotebookClient) Connection() *grpc.ClientConn { 198 return c.internalClient.Connection() 199 } 200 201 // CreateNotebookRuntimeTemplate creates a NotebookRuntimeTemplate. 202 func (c *NotebookClient) CreateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.CreateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error) { 203 return c.internalClient.CreateNotebookRuntimeTemplate(ctx, req, opts...) 204 } 205 206 // CreateNotebookRuntimeTemplateOperation returns a new CreateNotebookRuntimeTemplateOperation from a given name. 207 // The name must be that of a previously created CreateNotebookRuntimeTemplateOperation, possibly from a different process. 208 func (c *NotebookClient) CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation { 209 return c.internalClient.CreateNotebookRuntimeTemplateOperation(name) 210 } 211 212 // GetNotebookRuntimeTemplate gets a NotebookRuntimeTemplate. 213 func (c *NotebookClient) GetNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) { 214 return c.internalClient.GetNotebookRuntimeTemplate(ctx, req, opts...) 215 } 216 217 // ListNotebookRuntimeTemplates lists NotebookRuntimeTemplates in a Location. 218 func (c *NotebookClient) ListNotebookRuntimeTemplates(ctx context.Context, req *aiplatformpb.ListNotebookRuntimeTemplatesRequest, opts ...gax.CallOption) *NotebookRuntimeTemplateIterator { 219 return c.internalClient.ListNotebookRuntimeTemplates(ctx, req, opts...) 220 } 221 222 // DeleteNotebookRuntimeTemplate deletes a NotebookRuntimeTemplate. 223 func (c *NotebookClient) DeleteNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error) { 224 return c.internalClient.DeleteNotebookRuntimeTemplate(ctx, req, opts...) 225 } 226 227 // DeleteNotebookRuntimeTemplateOperation returns a new DeleteNotebookRuntimeTemplateOperation from a given name. 228 // The name must be that of a previously created DeleteNotebookRuntimeTemplateOperation, possibly from a different process. 229 func (c *NotebookClient) DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation { 230 return c.internalClient.DeleteNotebookRuntimeTemplateOperation(name) 231 } 232 233 // UpdateNotebookRuntimeTemplate updates a NotebookRuntimeTemplate. 234 func (c *NotebookClient) UpdateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) { 235 return c.internalClient.UpdateNotebookRuntimeTemplate(ctx, req, opts...) 236 } 237 238 // AssignNotebookRuntime assigns a NotebookRuntime to a user for a particular Notebook file. This 239 // method will either returns an existing assignment or generates a new one. 240 func (c *NotebookClient) AssignNotebookRuntime(ctx context.Context, req *aiplatformpb.AssignNotebookRuntimeRequest, opts ...gax.CallOption) (*AssignNotebookRuntimeOperation, error) { 241 return c.internalClient.AssignNotebookRuntime(ctx, req, opts...) 242 } 243 244 // AssignNotebookRuntimeOperation returns a new AssignNotebookRuntimeOperation from a given name. 245 // The name must be that of a previously created AssignNotebookRuntimeOperation, possibly from a different process. 246 func (c *NotebookClient) AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation { 247 return c.internalClient.AssignNotebookRuntimeOperation(name) 248 } 249 250 // GetNotebookRuntime gets a NotebookRuntime. 251 func (c *NotebookClient) GetNotebookRuntime(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error) { 252 return c.internalClient.GetNotebookRuntime(ctx, req, opts...) 253 } 254 255 // ListNotebookRuntimes lists NotebookRuntimes in a Location. 256 func (c *NotebookClient) ListNotebookRuntimes(ctx context.Context, req *aiplatformpb.ListNotebookRuntimesRequest, opts ...gax.CallOption) *NotebookRuntimeIterator { 257 return c.internalClient.ListNotebookRuntimes(ctx, req, opts...) 258 } 259 260 // DeleteNotebookRuntime deletes a NotebookRuntime. 261 func (c *NotebookClient) DeleteNotebookRuntime(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error) { 262 return c.internalClient.DeleteNotebookRuntime(ctx, req, opts...) 263 } 264 265 // DeleteNotebookRuntimeOperation returns a new DeleteNotebookRuntimeOperation from a given name. 266 // The name must be that of a previously created DeleteNotebookRuntimeOperation, possibly from a different process. 267 func (c *NotebookClient) DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation { 268 return c.internalClient.DeleteNotebookRuntimeOperation(name) 269 } 270 271 // UpgradeNotebookRuntime upgrades a NotebookRuntime. 272 func (c *NotebookClient) UpgradeNotebookRuntime(ctx context.Context, req *aiplatformpb.UpgradeNotebookRuntimeRequest, opts ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error) { 273 return c.internalClient.UpgradeNotebookRuntime(ctx, req, opts...) 274 } 275 276 // UpgradeNotebookRuntimeOperation returns a new UpgradeNotebookRuntimeOperation from a given name. 277 // The name must be that of a previously created UpgradeNotebookRuntimeOperation, possibly from a different process. 278 func (c *NotebookClient) UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation { 279 return c.internalClient.UpgradeNotebookRuntimeOperation(name) 280 } 281 282 // StartNotebookRuntime starts a NotebookRuntime. 283 func (c *NotebookClient) StartNotebookRuntime(ctx context.Context, req *aiplatformpb.StartNotebookRuntimeRequest, opts ...gax.CallOption) (*StartNotebookRuntimeOperation, error) { 284 return c.internalClient.StartNotebookRuntime(ctx, req, opts...) 285 } 286 287 // StartNotebookRuntimeOperation returns a new StartNotebookRuntimeOperation from a given name. 288 // The name must be that of a previously created StartNotebookRuntimeOperation, possibly from a different process. 289 func (c *NotebookClient) StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation { 290 return c.internalClient.StartNotebookRuntimeOperation(name) 291 } 292 293 // StopNotebookRuntime stops a NotebookRuntime. 294 func (c *NotebookClient) StopNotebookRuntime(ctx context.Context, req *aiplatformpb.StopNotebookRuntimeRequest, opts ...gax.CallOption) (*StopNotebookRuntimeOperation, error) { 295 return c.internalClient.StopNotebookRuntime(ctx, req, opts...) 296 } 297 298 // StopNotebookRuntimeOperation returns a new StopNotebookRuntimeOperation from a given name. 299 // The name must be that of a previously created StopNotebookRuntimeOperation, possibly from a different process. 300 func (c *NotebookClient) StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation { 301 return c.internalClient.StopNotebookRuntimeOperation(name) 302 } 303 304 // CreateNotebookExecutionJob creates a NotebookExecutionJob. 305 func (c *NotebookClient) CreateNotebookExecutionJob(ctx context.Context, req *aiplatformpb.CreateNotebookExecutionJobRequest, opts ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error) { 306 return c.internalClient.CreateNotebookExecutionJob(ctx, req, opts...) 307 } 308 309 // CreateNotebookExecutionJobOperation returns a new CreateNotebookExecutionJobOperation from a given name. 310 // The name must be that of a previously created CreateNotebookExecutionJobOperation, possibly from a different process. 311 func (c *NotebookClient) CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation { 312 return c.internalClient.CreateNotebookExecutionJobOperation(name) 313 } 314 315 // GetNotebookExecutionJob gets a NotebookExecutionJob. 316 func (c *NotebookClient) GetNotebookExecutionJob(ctx context.Context, req *aiplatformpb.GetNotebookExecutionJobRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error) { 317 return c.internalClient.GetNotebookExecutionJob(ctx, req, opts...) 318 } 319 320 // ListNotebookExecutionJobs lists NotebookExecutionJobs in a Location. 321 func (c *NotebookClient) ListNotebookExecutionJobs(ctx context.Context, req *aiplatformpb.ListNotebookExecutionJobsRequest, opts ...gax.CallOption) *NotebookExecutionJobIterator { 322 return c.internalClient.ListNotebookExecutionJobs(ctx, req, opts...) 323 } 324 325 // DeleteNotebookExecutionJob deletes a NotebookExecutionJob. 326 func (c *NotebookClient) DeleteNotebookExecutionJob(ctx context.Context, req *aiplatformpb.DeleteNotebookExecutionJobRequest, opts ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error) { 327 return c.internalClient.DeleteNotebookExecutionJob(ctx, req, opts...) 328 } 329 330 // DeleteNotebookExecutionJobOperation returns a new DeleteNotebookExecutionJobOperation from a given name. 331 // The name must be that of a previously created DeleteNotebookExecutionJobOperation, possibly from a different process. 332 func (c *NotebookClient) DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation { 333 return c.internalClient.DeleteNotebookExecutionJobOperation(name) 334 } 335 336 // GetLocation gets information about a location. 337 func (c *NotebookClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 338 return c.internalClient.GetLocation(ctx, req, opts...) 339 } 340 341 // ListLocations lists information about the supported locations for this service. 342 func (c *NotebookClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 343 return c.internalClient.ListLocations(ctx, req, opts...) 344 } 345 346 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy 347 // if the resource exists and does not have a policy set. 348 func (c *NotebookClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 349 return c.internalClient.GetIamPolicy(ctx, req, opts...) 350 } 351 352 // SetIamPolicy sets the access control policy on the specified resource. Replaces 353 // any existing policy. 354 // 355 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED 356 // errors. 357 func (c *NotebookClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 358 return c.internalClient.SetIamPolicy(ctx, req, opts...) 359 } 360 361 // TestIamPermissions returns permissions that a caller has on the specified resource. If the 362 // resource does not exist, this will return an empty set of 363 // permissions, not a NOT_FOUND error. 364 // 365 // Note: This operation is designed to be used for building 366 // permission-aware UIs and command-line tools, not for authorization 367 // checking. This operation may “fail open” without warning. 368 func (c *NotebookClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 369 return c.internalClient.TestIamPermissions(ctx, req, opts...) 370 } 371 372 // CancelOperation is a utility method from google.longrunning.Operations. 373 func (c *NotebookClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 374 return c.internalClient.CancelOperation(ctx, req, opts...) 375 } 376 377 // DeleteOperation is a utility method from google.longrunning.Operations. 378 func (c *NotebookClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 379 return c.internalClient.DeleteOperation(ctx, req, opts...) 380 } 381 382 // GetOperation is a utility method from google.longrunning.Operations. 383 func (c *NotebookClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 384 return c.internalClient.GetOperation(ctx, req, opts...) 385 } 386 387 // ListOperations is a utility method from google.longrunning.Operations. 388 func (c *NotebookClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 389 return c.internalClient.ListOperations(ctx, req, opts...) 390 } 391 392 // WaitOperation is a utility method from google.longrunning.Operations. 393 func (c *NotebookClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 394 return c.internalClient.WaitOperation(ctx, req, opts...) 395 } 396 397 // notebookGRPCClient is a client for interacting with Vertex AI API over gRPC transport. 398 // 399 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 400 type notebookGRPCClient struct { 401 // Connection pool of gRPC connections to the service. 402 connPool gtransport.ConnPool 403 404 // Points back to the CallOptions field of the containing NotebookClient 405 CallOptions **NotebookCallOptions 406 407 // The gRPC API client. 408 notebookClient aiplatformpb.NotebookServiceClient 409 410 // LROClient is used internally to handle long-running operations. 411 // It is exposed so that its CallOptions can be modified if required. 412 // Users should not Close this client. 413 LROClient **lroauto.OperationsClient 414 415 operationsClient longrunningpb.OperationsClient 416 417 iamPolicyClient iampb.IAMPolicyClient 418 419 locationsClient locationpb.LocationsClient 420 421 // The x-goog-* metadata to be sent with each request. 422 xGoogHeaders []string 423 424 logger *slog.Logger 425 } 426 427 // NewNotebookClient creates a new notebook service client based on gRPC. 428 // The returned client must be Closed when it is done being used to clean up its underlying connections. 429 // 430 // The interface for Vertex Notebook service (a.k.a. Colab on Workbench). 431 func NewNotebookClient(ctx context.Context, opts ...option.ClientOption) (*NotebookClient, error) { 432 clientOpts := defaultNotebookGRPCClientOptions() 433 if newNotebookClientHook != nil { 434 hookOpts, err := newNotebookClientHook(ctx, clientHookParams{}) 435 if err != nil { 436 return nil, err 437 } 438 clientOpts = append(clientOpts, hookOpts...) 439 } 440 441 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 442 if err != nil { 443 return nil, err 444 } 445 client := NotebookClient{CallOptions: defaultNotebookCallOptions()} 446 447 c := ¬ebookGRPCClient{ 448 connPool: connPool, 449 notebookClient: aiplatformpb.NewNotebookServiceClient(connPool), 450 CallOptions: &client.CallOptions, 451 logger: internaloption.GetLogger(opts), 452 operationsClient: longrunningpb.NewOperationsClient(connPool), 453 iamPolicyClient: iampb.NewIAMPolicyClient(connPool), 454 locationsClient: locationpb.NewLocationsClient(connPool), 455 } 456 c.setGoogleClientInfo() 457 458 client.internalClient = c 459 460 client.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) 461 if err != nil { 462 // This error "should not happen", since we are just reusing old connection pool 463 // and never actually need to dial. 464 // If this does happen, we could leak connp. However, we cannot close conn: 465 // If the user invoked the constructor with option.WithGRPCConn, 466 // we would close a connection that's still in use. 467 // TODO: investigate error conditions. 468 return nil, err 469 } 470 c.LROClient = &client.LROClient 471 return &client, nil 472 } 473 474 // Connection returns a connection to the API service. 475 // 476 // Deprecated: Connections are now pooled so this method does not always 477 // return the same resource. 478 func (c *notebookGRPCClient) Connection() *grpc.ClientConn { 479 return c.connPool.Conn() 480 } 481 482 // setGoogleClientInfo sets the name and version of the application in 483 // the `x-goog-api-client` header passed on each request. Intended for 484 // use by Google-written clients. 485 func (c *notebookGRPCClient) setGoogleClientInfo(keyval ...string) { 486 kv := append([]string{"gl-go", gax.GoVersion}, keyval...) 487 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion) 488 c.xGoogHeaders = []string{ 489 "x-goog-api-client", gax.XGoogHeader(kv...), 490 } 491 } 492 493 // Close closes the connection to the API service. The user should invoke this when 494 // the client is no longer required. 495 func (c *notebookGRPCClient) Close() error { 496 return c.connPool.Close() 497 } 498 499 func (c *notebookGRPCClient) CreateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.CreateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*CreateNotebookRuntimeTemplateOperation, error) { 500 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 501 502 hds = append(c.xGoogHeaders, hds...) 503 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 504 opts = append((*c.CallOptions).CreateNotebookRuntimeTemplate[0:len((*c.CallOptions).CreateNotebookRuntimeTemplate):len((*c.CallOptions).CreateNotebookRuntimeTemplate)], opts...) 505 var resp *longrunningpb.Operation 506 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 507 var err error 508 resp, err = executeRPC(ctx, c.notebookClient.CreateNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "CreateNotebookRuntimeTemplate") 509 return err 510 }, opts...) 511 if err != nil { 512 return nil, err 513 } 514 return &CreateNotebookRuntimeTemplateOperation{ 515 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 516 }, nil 517 } 518 519 func (c *notebookGRPCClient) GetNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) { 520 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 521 522 hds = append(c.xGoogHeaders, hds...) 523 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 524 opts = append((*c.CallOptions).GetNotebookRuntimeTemplate[0:len((*c.CallOptions).GetNotebookRuntimeTemplate):len((*c.CallOptions).GetNotebookRuntimeTemplate)], opts...) 525 var resp *aiplatformpb.NotebookRuntimeTemplate 526 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 527 var err error 528 resp, err = executeRPC(ctx, c.notebookClient.GetNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "GetNotebookRuntimeTemplate") 529 return err 530 }, opts...) 531 if err != nil { 532 return nil, err 533 } 534 return resp, nil 535 } 536 537 func (c *notebookGRPCClient) ListNotebookRuntimeTemplates(ctx context.Context, req *aiplatformpb.ListNotebookRuntimeTemplatesRequest, opts ...gax.CallOption) *NotebookRuntimeTemplateIterator { 538 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 539 540 hds = append(c.xGoogHeaders, hds...) 541 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 542 opts = append((*c.CallOptions).ListNotebookRuntimeTemplates[0:len((*c.CallOptions).ListNotebookRuntimeTemplates):len((*c.CallOptions).ListNotebookRuntimeTemplates)], opts...) 543 it := &NotebookRuntimeTemplateIterator{} 544 req = proto.Clone(req).(*aiplatformpb.ListNotebookRuntimeTemplatesRequest) 545 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookRuntimeTemplate, string, error) { 546 resp := &aiplatformpb.ListNotebookRuntimeTemplatesResponse{} 547 if pageToken != "" { 548 req.PageToken = pageToken 549 } 550 if pageSize > math.MaxInt32 { 551 req.PageSize = math.MaxInt32 552 } else if pageSize != 0 { 553 req.PageSize = int32(pageSize) 554 } 555 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 556 var err error 557 resp, err = executeRPC(ctx, c.notebookClient.ListNotebookRuntimeTemplates, req, settings.GRPC, c.logger, "ListNotebookRuntimeTemplates") 558 return err 559 }, opts...) 560 if err != nil { 561 return nil, "", err 562 } 563 564 it.Response = resp 565 return resp.GetNotebookRuntimeTemplates(), resp.GetNextPageToken(), nil 566 } 567 fetch := func(pageSize int, pageToken string) (string, error) { 568 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 569 if err != nil { 570 return "", err 571 } 572 it.items = append(it.items, items...) 573 return nextPageToken, nil 574 } 575 576 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 577 it.pageInfo.MaxSize = int(req.GetPageSize()) 578 it.pageInfo.Token = req.GetPageToken() 579 580 return it 581 } 582 583 func (c *notebookGRPCClient) DeleteNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeTemplateOperation, error) { 584 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 585 586 hds = append(c.xGoogHeaders, hds...) 587 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 588 opts = append((*c.CallOptions).DeleteNotebookRuntimeTemplate[0:len((*c.CallOptions).DeleteNotebookRuntimeTemplate):len((*c.CallOptions).DeleteNotebookRuntimeTemplate)], opts...) 589 var resp *longrunningpb.Operation 590 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 591 var err error 592 resp, err = executeRPC(ctx, c.notebookClient.DeleteNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "DeleteNotebookRuntimeTemplate") 593 return err 594 }, opts...) 595 if err != nil { 596 return nil, err 597 } 598 return &DeleteNotebookRuntimeTemplateOperation{ 599 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 600 }, nil 601 } 602 603 func (c *notebookGRPCClient) UpdateNotebookRuntimeTemplate(ctx context.Context, req *aiplatformpb.UpdateNotebookRuntimeTemplateRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntimeTemplate, error) { 604 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "notebook_runtime_template.name", url.QueryEscape(req.GetNotebookRuntimeTemplate().GetName()))} 605 606 hds = append(c.xGoogHeaders, hds...) 607 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 608 opts = append((*c.CallOptions).UpdateNotebookRuntimeTemplate[0:len((*c.CallOptions).UpdateNotebookRuntimeTemplate):len((*c.CallOptions).UpdateNotebookRuntimeTemplate)], opts...) 609 var resp *aiplatformpb.NotebookRuntimeTemplate 610 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 611 var err error 612 resp, err = executeRPC(ctx, c.notebookClient.UpdateNotebookRuntimeTemplate, req, settings.GRPC, c.logger, "UpdateNotebookRuntimeTemplate") 613 return err 614 }, opts...) 615 if err != nil { 616 return nil, err 617 } 618 return resp, nil 619 } 620 621 func (c *notebookGRPCClient) AssignNotebookRuntime(ctx context.Context, req *aiplatformpb.AssignNotebookRuntimeRequest, opts ...gax.CallOption) (*AssignNotebookRuntimeOperation, error) { 622 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 623 624 hds = append(c.xGoogHeaders, hds...) 625 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 626 opts = append((*c.CallOptions).AssignNotebookRuntime[0:len((*c.CallOptions).AssignNotebookRuntime):len((*c.CallOptions).AssignNotebookRuntime)], opts...) 627 var resp *longrunningpb.Operation 628 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 629 var err error 630 resp, err = executeRPC(ctx, c.notebookClient.AssignNotebookRuntime, req, settings.GRPC, c.logger, "AssignNotebookRuntime") 631 return err 632 }, opts...) 633 if err != nil { 634 return nil, err 635 } 636 return &AssignNotebookRuntimeOperation{ 637 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 638 }, nil 639 } 640 641 func (c *notebookGRPCClient) GetNotebookRuntime(ctx context.Context, req *aiplatformpb.GetNotebookRuntimeRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookRuntime, error) { 642 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 643 644 hds = append(c.xGoogHeaders, hds...) 645 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 646 opts = append((*c.CallOptions).GetNotebookRuntime[0:len((*c.CallOptions).GetNotebookRuntime):len((*c.CallOptions).GetNotebookRuntime)], opts...) 647 var resp *aiplatformpb.NotebookRuntime 648 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 649 var err error 650 resp, err = executeRPC(ctx, c.notebookClient.GetNotebookRuntime, req, settings.GRPC, c.logger, "GetNotebookRuntime") 651 return err 652 }, opts...) 653 if err != nil { 654 return nil, err 655 } 656 return resp, nil 657 } 658 659 func (c *notebookGRPCClient) ListNotebookRuntimes(ctx context.Context, req *aiplatformpb.ListNotebookRuntimesRequest, opts ...gax.CallOption) *NotebookRuntimeIterator { 660 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 661 662 hds = append(c.xGoogHeaders, hds...) 663 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 664 opts = append((*c.CallOptions).ListNotebookRuntimes[0:len((*c.CallOptions).ListNotebookRuntimes):len((*c.CallOptions).ListNotebookRuntimes)], opts...) 665 it := &NotebookRuntimeIterator{} 666 req = proto.Clone(req).(*aiplatformpb.ListNotebookRuntimesRequest) 667 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookRuntime, string, error) { 668 resp := &aiplatformpb.ListNotebookRuntimesResponse{} 669 if pageToken != "" { 670 req.PageToken = pageToken 671 } 672 if pageSize > math.MaxInt32 { 673 req.PageSize = math.MaxInt32 674 } else if pageSize != 0 { 675 req.PageSize = int32(pageSize) 676 } 677 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 678 var err error 679 resp, err = executeRPC(ctx, c.notebookClient.ListNotebookRuntimes, req, settings.GRPC, c.logger, "ListNotebookRuntimes") 680 return err 681 }, opts...) 682 if err != nil { 683 return nil, "", err 684 } 685 686 it.Response = resp 687 return resp.GetNotebookRuntimes(), resp.GetNextPageToken(), nil 688 } 689 fetch := func(pageSize int, pageToken string) (string, error) { 690 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 691 if err != nil { 692 return "", err 693 } 694 it.items = append(it.items, items...) 695 return nextPageToken, nil 696 } 697 698 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 699 it.pageInfo.MaxSize = int(req.GetPageSize()) 700 it.pageInfo.Token = req.GetPageToken() 701 702 return it 703 } 704 705 func (c *notebookGRPCClient) DeleteNotebookRuntime(ctx context.Context, req *aiplatformpb.DeleteNotebookRuntimeRequest, opts ...gax.CallOption) (*DeleteNotebookRuntimeOperation, error) { 706 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 707 708 hds = append(c.xGoogHeaders, hds...) 709 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 710 opts = append((*c.CallOptions).DeleteNotebookRuntime[0:len((*c.CallOptions).DeleteNotebookRuntime):len((*c.CallOptions).DeleteNotebookRuntime)], opts...) 711 var resp *longrunningpb.Operation 712 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 713 var err error 714 resp, err = executeRPC(ctx, c.notebookClient.DeleteNotebookRuntime, req, settings.GRPC, c.logger, "DeleteNotebookRuntime") 715 return err 716 }, opts...) 717 if err != nil { 718 return nil, err 719 } 720 return &DeleteNotebookRuntimeOperation{ 721 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 722 }, nil 723 } 724 725 func (c *notebookGRPCClient) UpgradeNotebookRuntime(ctx context.Context, req *aiplatformpb.UpgradeNotebookRuntimeRequest, opts ...gax.CallOption) (*UpgradeNotebookRuntimeOperation, error) { 726 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 727 728 hds = append(c.xGoogHeaders, hds...) 729 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 730 opts = append((*c.CallOptions).UpgradeNotebookRuntime[0:len((*c.CallOptions).UpgradeNotebookRuntime):len((*c.CallOptions).UpgradeNotebookRuntime)], opts...) 731 var resp *longrunningpb.Operation 732 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 733 var err error 734 resp, err = executeRPC(ctx, c.notebookClient.UpgradeNotebookRuntime, req, settings.GRPC, c.logger, "UpgradeNotebookRuntime") 735 return err 736 }, opts...) 737 if err != nil { 738 return nil, err 739 } 740 return &UpgradeNotebookRuntimeOperation{ 741 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 742 }, nil 743 } 744 745 func (c *notebookGRPCClient) StartNotebookRuntime(ctx context.Context, req *aiplatformpb.StartNotebookRuntimeRequest, opts ...gax.CallOption) (*StartNotebookRuntimeOperation, error) { 746 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 747 748 hds = append(c.xGoogHeaders, hds...) 749 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 750 opts = append((*c.CallOptions).StartNotebookRuntime[0:len((*c.CallOptions).StartNotebookRuntime):len((*c.CallOptions).StartNotebookRuntime)], opts...) 751 var resp *longrunningpb.Operation 752 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 753 var err error 754 resp, err = executeRPC(ctx, c.notebookClient.StartNotebookRuntime, req, settings.GRPC, c.logger, "StartNotebookRuntime") 755 return err 756 }, opts...) 757 if err != nil { 758 return nil, err 759 } 760 return &StartNotebookRuntimeOperation{ 761 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 762 }, nil 763 } 764 765 func (c *notebookGRPCClient) StopNotebookRuntime(ctx context.Context, req *aiplatformpb.StopNotebookRuntimeRequest, opts ...gax.CallOption) (*StopNotebookRuntimeOperation, error) { 766 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 767 768 hds = append(c.xGoogHeaders, hds...) 769 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 770 opts = append((*c.CallOptions).StopNotebookRuntime[0:len((*c.CallOptions).StopNotebookRuntime):len((*c.CallOptions).StopNotebookRuntime)], opts...) 771 var resp *longrunningpb.Operation 772 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 773 var err error 774 resp, err = executeRPC(ctx, c.notebookClient.StopNotebookRuntime, req, settings.GRPC, c.logger, "StopNotebookRuntime") 775 return err 776 }, opts...) 777 if err != nil { 778 return nil, err 779 } 780 return &StopNotebookRuntimeOperation{ 781 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 782 }, nil 783 } 784 785 func (c *notebookGRPCClient) CreateNotebookExecutionJob(ctx context.Context, req *aiplatformpb.CreateNotebookExecutionJobRequest, opts ...gax.CallOption) (*CreateNotebookExecutionJobOperation, error) { 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).CreateNotebookExecutionJob[0:len((*c.CallOptions).CreateNotebookExecutionJob):len((*c.CallOptions).CreateNotebookExecutionJob)], opts...) 791 var resp *longrunningpb.Operation 792 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 793 var err error 794 resp, err = executeRPC(ctx, c.notebookClient.CreateNotebookExecutionJob, req, settings.GRPC, c.logger, "CreateNotebookExecutionJob") 795 return err 796 }, opts...) 797 if err != nil { 798 return nil, err 799 } 800 return &CreateNotebookExecutionJobOperation{ 801 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 802 }, nil 803 } 804 805 func (c *notebookGRPCClient) GetNotebookExecutionJob(ctx context.Context, req *aiplatformpb.GetNotebookExecutionJobRequest, opts ...gax.CallOption) (*aiplatformpb.NotebookExecutionJob, error) { 806 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 807 808 hds = append(c.xGoogHeaders, hds...) 809 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 810 opts = append((*c.CallOptions).GetNotebookExecutionJob[0:len((*c.CallOptions).GetNotebookExecutionJob):len((*c.CallOptions).GetNotebookExecutionJob)], opts...) 811 var resp *aiplatformpb.NotebookExecutionJob 812 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 813 var err error 814 resp, err = executeRPC(ctx, c.notebookClient.GetNotebookExecutionJob, req, settings.GRPC, c.logger, "GetNotebookExecutionJob") 815 return err 816 }, opts...) 817 if err != nil { 818 return nil, err 819 } 820 return resp, nil 821 } 822 823 func (c *notebookGRPCClient) ListNotebookExecutionJobs(ctx context.Context, req *aiplatformpb.ListNotebookExecutionJobsRequest, opts ...gax.CallOption) *NotebookExecutionJobIterator { 824 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))} 825 826 hds = append(c.xGoogHeaders, hds...) 827 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 828 opts = append((*c.CallOptions).ListNotebookExecutionJobs[0:len((*c.CallOptions).ListNotebookExecutionJobs):len((*c.CallOptions).ListNotebookExecutionJobs)], opts...) 829 it := &NotebookExecutionJobIterator{} 830 req = proto.Clone(req).(*aiplatformpb.ListNotebookExecutionJobsRequest) 831 it.InternalFetch = func(pageSize int, pageToken string) ([]*aiplatformpb.NotebookExecutionJob, string, error) { 832 resp := &aiplatformpb.ListNotebookExecutionJobsResponse{} 833 if pageToken != "" { 834 req.PageToken = pageToken 835 } 836 if pageSize > math.MaxInt32 { 837 req.PageSize = math.MaxInt32 838 } else if pageSize != 0 { 839 req.PageSize = int32(pageSize) 840 } 841 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 842 var err error 843 resp, err = executeRPC(ctx, c.notebookClient.ListNotebookExecutionJobs, req, settings.GRPC, c.logger, "ListNotebookExecutionJobs") 844 return err 845 }, opts...) 846 if err != nil { 847 return nil, "", err 848 } 849 850 it.Response = resp 851 return resp.GetNotebookExecutionJobs(), resp.GetNextPageToken(), nil 852 } 853 fetch := func(pageSize int, pageToken string) (string, error) { 854 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 855 if err != nil { 856 return "", err 857 } 858 it.items = append(it.items, items...) 859 return nextPageToken, nil 860 } 861 862 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 863 it.pageInfo.MaxSize = int(req.GetPageSize()) 864 it.pageInfo.Token = req.GetPageToken() 865 866 return it 867 } 868 869 func (c *notebookGRPCClient) DeleteNotebookExecutionJob(ctx context.Context, req *aiplatformpb.DeleteNotebookExecutionJobRequest, opts ...gax.CallOption) (*DeleteNotebookExecutionJobOperation, error) { 870 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 871 872 hds = append(c.xGoogHeaders, hds...) 873 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 874 opts = append((*c.CallOptions).DeleteNotebookExecutionJob[0:len((*c.CallOptions).DeleteNotebookExecutionJob):len((*c.CallOptions).DeleteNotebookExecutionJob)], opts...) 875 var resp *longrunningpb.Operation 876 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 877 var err error 878 resp, err = executeRPC(ctx, c.notebookClient.DeleteNotebookExecutionJob, req, settings.GRPC, c.logger, "DeleteNotebookExecutionJob") 879 return err 880 }, opts...) 881 if err != nil { 882 return nil, err 883 } 884 return &DeleteNotebookExecutionJobOperation{ 885 lro: longrunning.InternalNewOperation(*c.LROClient, resp), 886 }, nil 887 } 888 889 func (c *notebookGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) { 890 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 891 892 hds = append(c.xGoogHeaders, hds...) 893 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 894 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...) 895 var resp *locationpb.Location 896 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 897 var err error 898 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation") 899 return err 900 }, opts...) 901 if err != nil { 902 return nil, err 903 } 904 return resp, nil 905 } 906 907 func (c *notebookGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator { 908 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 909 910 hds = append(c.xGoogHeaders, hds...) 911 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 912 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...) 913 it := &LocationIterator{} 914 req = proto.Clone(req).(*locationpb.ListLocationsRequest) 915 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) { 916 resp := &locationpb.ListLocationsResponse{} 917 if pageToken != "" { 918 req.PageToken = pageToken 919 } 920 if pageSize > math.MaxInt32 { 921 req.PageSize = math.MaxInt32 922 } else if pageSize != 0 { 923 req.PageSize = int32(pageSize) 924 } 925 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 926 var err error 927 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations") 928 return err 929 }, opts...) 930 if err != nil { 931 return nil, "", err 932 } 933 934 it.Response = resp 935 return resp.GetLocations(), resp.GetNextPageToken(), nil 936 } 937 fetch := func(pageSize int, pageToken string) (string, error) { 938 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 939 if err != nil { 940 return "", err 941 } 942 it.items = append(it.items, items...) 943 return nextPageToken, nil 944 } 945 946 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 947 it.pageInfo.MaxSize = int(req.GetPageSize()) 948 it.pageInfo.Token = req.GetPageToken() 949 950 return it 951 } 952 953 func (c *notebookGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 954 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 955 956 hds = append(c.xGoogHeaders, hds...) 957 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 958 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...) 959 var resp *iampb.Policy 960 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 961 var err error 962 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy") 963 return err 964 }, opts...) 965 if err != nil { 966 return nil, err 967 } 968 return resp, nil 969 } 970 971 func (c *notebookGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) { 972 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 973 974 hds = append(c.xGoogHeaders, hds...) 975 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 976 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...) 977 var resp *iampb.Policy 978 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 979 var err error 980 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy") 981 return err 982 }, opts...) 983 if err != nil { 984 return nil, err 985 } 986 return resp, nil 987 } 988 989 func (c *notebookGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) { 990 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))} 991 992 hds = append(c.xGoogHeaders, hds...) 993 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 994 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...) 995 var resp *iampb.TestIamPermissionsResponse 996 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 997 var err error 998 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions") 999 return err 1000 }, opts...) 1001 if err != nil { 1002 return nil, err 1003 } 1004 return resp, nil 1005 } 1006 1007 func (c *notebookGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error { 1008 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1009 1010 hds = append(c.xGoogHeaders, hds...) 1011 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1012 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...) 1013 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1014 var err error 1015 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation") 1016 return err 1017 }, opts...) 1018 return err 1019 } 1020 1021 func (c *notebookGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error { 1022 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1023 1024 hds = append(c.xGoogHeaders, hds...) 1025 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1026 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...) 1027 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1028 var err error 1029 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation") 1030 return err 1031 }, opts...) 1032 return err 1033 } 1034 1035 func (c *notebookGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1036 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1037 1038 hds = append(c.xGoogHeaders, hds...) 1039 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1040 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...) 1041 var resp *longrunningpb.Operation 1042 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1043 var err error 1044 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation") 1045 return err 1046 }, opts...) 1047 if err != nil { 1048 return nil, err 1049 } 1050 return resp, nil 1051 } 1052 1053 func (c *notebookGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator { 1054 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1055 1056 hds = append(c.xGoogHeaders, hds...) 1057 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1058 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...) 1059 it := &OperationIterator{} 1060 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest) 1061 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) { 1062 resp := &longrunningpb.ListOperationsResponse{} 1063 if pageToken != "" { 1064 req.PageToken = pageToken 1065 } 1066 if pageSize > math.MaxInt32 { 1067 req.PageSize = math.MaxInt32 1068 } else if pageSize != 0 { 1069 req.PageSize = int32(pageSize) 1070 } 1071 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1072 var err error 1073 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations") 1074 return err 1075 }, opts...) 1076 if err != nil { 1077 return nil, "", err 1078 } 1079 1080 it.Response = resp 1081 return resp.GetOperations(), resp.GetNextPageToken(), nil 1082 } 1083 fetch := func(pageSize int, pageToken string) (string, error) { 1084 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1085 if err != nil { 1086 return "", err 1087 } 1088 it.items = append(it.items, items...) 1089 return nextPageToken, nil 1090 } 1091 1092 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1093 it.pageInfo.MaxSize = int(req.GetPageSize()) 1094 it.pageInfo.Token = req.GetPageToken() 1095 1096 return it 1097 } 1098 1099 func (c *notebookGRPCClient) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) { 1100 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))} 1101 1102 hds = append(c.xGoogHeaders, hds...) 1103 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...) 1104 opts = append((*c.CallOptions).WaitOperation[0:len((*c.CallOptions).WaitOperation):len((*c.CallOptions).WaitOperation)], opts...) 1105 var resp *longrunningpb.Operation 1106 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1107 var err error 1108 resp, err = executeRPC(ctx, c.operationsClient.WaitOperation, req, settings.GRPC, c.logger, "WaitOperation") 1109 return err 1110 }, opts...) 1111 if err != nil { 1112 return nil, err 1113 } 1114 return resp, nil 1115 } 1116 1117 // AssignNotebookRuntimeOperation returns a new AssignNotebookRuntimeOperation from a given name. 1118 // The name must be that of a previously created AssignNotebookRuntimeOperation, possibly from a different process. 1119 func (c *notebookGRPCClient) AssignNotebookRuntimeOperation(name string) *AssignNotebookRuntimeOperation { 1120 return &AssignNotebookRuntimeOperation{ 1121 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1122 } 1123 } 1124 1125 // CreateNotebookExecutionJobOperation returns a new CreateNotebookExecutionJobOperation from a given name. 1126 // The name must be that of a previously created CreateNotebookExecutionJobOperation, possibly from a different process. 1127 func (c *notebookGRPCClient) CreateNotebookExecutionJobOperation(name string) *CreateNotebookExecutionJobOperation { 1128 return &CreateNotebookExecutionJobOperation{ 1129 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1130 } 1131 } 1132 1133 // CreateNotebookRuntimeTemplateOperation returns a new CreateNotebookRuntimeTemplateOperation from a given name. 1134 // The name must be that of a previously created CreateNotebookRuntimeTemplateOperation, possibly from a different process. 1135 func (c *notebookGRPCClient) CreateNotebookRuntimeTemplateOperation(name string) *CreateNotebookRuntimeTemplateOperation { 1136 return &CreateNotebookRuntimeTemplateOperation{ 1137 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1138 } 1139 } 1140 1141 // DeleteNotebookExecutionJobOperation returns a new DeleteNotebookExecutionJobOperation from a given name. 1142 // The name must be that of a previously created DeleteNotebookExecutionJobOperation, possibly from a different process. 1143 func (c *notebookGRPCClient) DeleteNotebookExecutionJobOperation(name string) *DeleteNotebookExecutionJobOperation { 1144 return &DeleteNotebookExecutionJobOperation{ 1145 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1146 } 1147 } 1148 1149 // DeleteNotebookRuntimeOperation returns a new DeleteNotebookRuntimeOperation from a given name. 1150 // The name must be that of a previously created DeleteNotebookRuntimeOperation, possibly from a different process. 1151 func (c *notebookGRPCClient) DeleteNotebookRuntimeOperation(name string) *DeleteNotebookRuntimeOperation { 1152 return &DeleteNotebookRuntimeOperation{ 1153 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1154 } 1155 } 1156 1157 // DeleteNotebookRuntimeTemplateOperation returns a new DeleteNotebookRuntimeTemplateOperation from a given name. 1158 // The name must be that of a previously created DeleteNotebookRuntimeTemplateOperation, possibly from a different process. 1159 func (c *notebookGRPCClient) DeleteNotebookRuntimeTemplateOperation(name string) *DeleteNotebookRuntimeTemplateOperation { 1160 return &DeleteNotebookRuntimeTemplateOperation{ 1161 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1162 } 1163 } 1164 1165 // StartNotebookRuntimeOperation returns a new StartNotebookRuntimeOperation from a given name. 1166 // The name must be that of a previously created StartNotebookRuntimeOperation, possibly from a different process. 1167 func (c *notebookGRPCClient) StartNotebookRuntimeOperation(name string) *StartNotebookRuntimeOperation { 1168 return &StartNotebookRuntimeOperation{ 1169 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1170 } 1171 } 1172 1173 // StopNotebookRuntimeOperation returns a new StopNotebookRuntimeOperation from a given name. 1174 // The name must be that of a previously created StopNotebookRuntimeOperation, possibly from a different process. 1175 func (c *notebookGRPCClient) StopNotebookRuntimeOperation(name string) *StopNotebookRuntimeOperation { 1176 return &StopNotebookRuntimeOperation{ 1177 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1178 } 1179 } 1180 1181 // UpgradeNotebookRuntimeOperation returns a new UpgradeNotebookRuntimeOperation from a given name. 1182 // The name must be that of a previously created UpgradeNotebookRuntimeOperation, possibly from a different process. 1183 func (c *notebookGRPCClient) UpgradeNotebookRuntimeOperation(name string) *UpgradeNotebookRuntimeOperation { 1184 return &UpgradeNotebookRuntimeOperation{ 1185 lro: longrunning.InternalNewOperation(*c.LROClient, &longrunningpb.Operation{Name: name}), 1186 } 1187 }