1// Copyright 2023 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// http://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 15syntax = "proto3"; 16 17package google.cloud.notebooks.v2; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/api/resource.proto"; 23import "google/cloud/notebooks/v2/diagnostic_config.proto"; 24import "google/cloud/notebooks/v2/instance.proto"; 25import "google/longrunning/operations.proto"; 26import "google/protobuf/empty.proto"; 27import "google/protobuf/field_mask.proto"; 28import "google/protobuf/timestamp.proto"; 29 30option csharp_namespace = "Google.Cloud.Notebooks.V2"; 31option go_package = "cloud.google.com/go/notebooks/apiv2/notebookspb;notebookspb"; 32option java_multiple_files = true; 33option java_outer_classname = "ServiceProto"; 34option java_package = "com.google.cloud.notebooks.v2"; 35option php_namespace = "Google\\Cloud\\Notebooks\\V2"; 36option ruby_package = "Google::Cloud::Notebooks::V2"; 37 38// API v2 service for Workbench Notebooks Instances. 39service NotebookService { 40 option (google.api.default_host) = "notebooks.googleapis.com"; 41 option (google.api.oauth_scopes) = 42 "https://www.googleapis.com/auth/cloud-platform"; 43 44 // Lists instances in a given project and location. 45 rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) { 46 option (google.api.http) = { 47 get: "/v2/{parent=projects/*/locations/*}/instances" 48 }; 49 option (google.api.method_signature) = "parent"; 50 } 51 52 // Gets details of a single Instance. 53 rpc GetInstance(GetInstanceRequest) returns (Instance) { 54 option (google.api.http) = { 55 get: "/v2/{name=projects/*/locations/*/instances/*}" 56 }; 57 option (google.api.method_signature) = "name"; 58 } 59 60 // Creates a new Instance in a given project and location. 61 rpc CreateInstance(CreateInstanceRequest) 62 returns (google.longrunning.Operation) { 63 option (google.api.http) = { 64 post: "/v2/{parent=projects/*/locations/*}/instances" 65 body: "instance" 66 }; 67 option (google.api.method_signature) = "parent,instance,instance_id"; 68 option (google.longrunning.operation_info) = { 69 response_type: "Instance" 70 metadata_type: "OperationMetadata" 71 }; 72 } 73 74 // UpdateInstance updates an Instance. 75 rpc UpdateInstance(UpdateInstanceRequest) 76 returns (google.longrunning.Operation) { 77 option (google.api.http) = { 78 patch: "/v2/{instance.name=projects/*/locations/*/instances/*}" 79 body: "instance" 80 }; 81 option (google.api.method_signature) = "instance,update_mask"; 82 option (google.longrunning.operation_info) = { 83 response_type: "Instance" 84 metadata_type: "OperationMetadata" 85 }; 86 } 87 88 // Deletes a single Instance. 89 rpc DeleteInstance(DeleteInstanceRequest) 90 returns (google.longrunning.Operation) { 91 option (google.api.http) = { 92 delete: "/v2/{name=projects/*/locations/*/instances/*}" 93 }; 94 option (google.api.method_signature) = "name"; 95 option (google.longrunning.operation_info) = { 96 response_type: "google.protobuf.Empty" 97 metadata_type: "OperationMetadata" 98 }; 99 } 100 101 // Starts a notebook instance. 102 rpc StartInstance(StartInstanceRequest) 103 returns (google.longrunning.Operation) { 104 option (google.api.http) = { 105 post: "/v2/{name=projects/*/locations/*/instances/*}:start" 106 body: "*" 107 }; 108 option (google.longrunning.operation_info) = { 109 response_type: "Instance" 110 metadata_type: "OperationMetadata" 111 }; 112 } 113 114 // Stops a notebook instance. 115 rpc StopInstance(StopInstanceRequest) returns (google.longrunning.Operation) { 116 option (google.api.http) = { 117 post: "/v2/{name=projects/*/locations/*/instances/*}:stop" 118 body: "*" 119 }; 120 option (google.longrunning.operation_info) = { 121 response_type: "Instance" 122 metadata_type: "OperationMetadata" 123 }; 124 } 125 126 // Resets a notebook instance. 127 rpc ResetInstance(ResetInstanceRequest) 128 returns (google.longrunning.Operation) { 129 option (google.api.http) = { 130 post: "/v2/{name=projects/*/locations/*/instances/*}:reset" 131 body: "*" 132 }; 133 option (google.longrunning.operation_info) = { 134 response_type: "Instance" 135 metadata_type: "OperationMetadata" 136 }; 137 } 138 139 // Checks whether a notebook instance is upgradable. 140 rpc CheckInstanceUpgradability(CheckInstanceUpgradabilityRequest) 141 returns (CheckInstanceUpgradabilityResponse) { 142 option (google.api.http) = { 143 get: "/v2/{notebook_instance=projects/*/locations/*/instances/*}:checkUpgradability" 144 }; 145 } 146 147 // Upgrades a notebook instance to the latest version. 148 rpc UpgradeInstance(UpgradeInstanceRequest) 149 returns (google.longrunning.Operation) { 150 option (google.api.http) = { 151 post: "/v2/{name=projects/*/locations/*/instances/*}:upgrade" 152 body: "*" 153 }; 154 option (google.longrunning.operation_info) = { 155 response_type: "Instance" 156 metadata_type: "OperationMetadata" 157 }; 158 } 159 160 // Rollbacks a notebook instance to the previous version. 161 rpc RollbackInstance(RollbackInstanceRequest) 162 returns (google.longrunning.Operation) { 163 option (google.api.http) = { 164 post: "/v2/{name=projects/*/locations/*/instances/*}:rollback" 165 body: "*" 166 }; 167 option (google.longrunning.operation_info) = { 168 response_type: "Instance" 169 metadata_type: "OperationMetadata" 170 }; 171 } 172 173 // Creates a Diagnostic File and runs Diagnostic Tool given an Instance. 174 rpc DiagnoseInstance(DiagnoseInstanceRequest) 175 returns (google.longrunning.Operation) { 176 option (google.api.http) = { 177 post: "/v2/{name=projects/*/locations/*/instances/*}:diagnose" 178 body: "*" 179 }; 180 option (google.api.method_signature) = "name,diagnostic_config"; 181 option (google.longrunning.operation_info) = { 182 response_type: "Instance" 183 metadata_type: "OperationMetadata" 184 }; 185 } 186} 187 188// Represents the metadata of the long-running operation. 189message OperationMetadata { 190 // The time the operation was created. 191 google.protobuf.Timestamp create_time = 1; 192 193 // The time the operation finished running. 194 google.protobuf.Timestamp end_time = 2; 195 196 // Server-defined resource path for the target of the operation. 197 string target = 3; 198 199 // Name of the verb executed by the operation. 200 string verb = 4; 201 202 // Human-readable status of the operation, if any. 203 string status_message = 5; 204 205 // Identifies whether the user has requested cancellation 206 // of the operation. Operations that have successfully been cancelled 207 // have [Operation.error][] value with a 208 // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to 209 // `Code.CANCELLED`. 210 bool requested_cancellation = 6; 211 212 // API version used to start the operation. 213 string api_version = 7; 214 215 // API endpoint name of this operation. 216 string endpoint = 8; 217} 218 219// Request for listing notebook instances. 220message ListInstancesRequest { 221 // Required. Format: 222 // `parent=projects/{project_id}/locations/{location}` 223 string parent = 1 [ 224 (google.api.field_behavior) = REQUIRED, 225 (google.api.resource_reference) = { 226 child_type: "notebooks.googleapis.com/Instance" 227 } 228 ]; 229 230 // Optional. Maximum return size of the list call. 231 int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; 232 233 // Optional. A previous returned page token that can be used to continue 234 // listing from the last result. 235 string page_token = 3 [(google.api.field_behavior) = OPTIONAL]; 236 237 // Optional. Sort results. Supported values are "name", "name desc" or "" 238 // (unsorted). 239 string order_by = 4 [(google.api.field_behavior) = OPTIONAL]; 240 241 // Optional. List filter. 242 string filter = 5 [(google.api.field_behavior) = OPTIONAL]; 243} 244 245// Response for listing notebook instances. 246message ListInstancesResponse { 247 // A list of returned instances. 248 repeated Instance instances = 1; 249 250 // Page token that can be used to continue listing from the last result in the 251 // next list call. 252 string next_page_token = 2; 253 254 // Locations that could not be reached. For example, 255 // ['us-west1-a', 'us-central1-b']. 256 // A ListInstancesResponse will only contain either instances or unreachables, 257 repeated string unreachable = 3; 258} 259 260// Request for getting a notebook instance. 261message GetInstanceRequest { 262 // Required. Format: 263 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 264 string name = 1 [ 265 (google.api.field_behavior) = REQUIRED, 266 (google.api.resource_reference) = { 267 type: "notebooks.googleapis.com/Instance" 268 } 269 ]; 270} 271 272// Request for creating a notebook instance. 273message CreateInstanceRequest { 274 // Required. Format: 275 // `parent=projects/{project_id}/locations/{location}` 276 string parent = 1 [ 277 (google.api.field_behavior) = REQUIRED, 278 (google.api.resource_reference) = { 279 child_type: "notebooks.googleapis.com/Instance" 280 } 281 ]; 282 283 // Required. User-defined unique ID of this instance. 284 string instance_id = 2 [(google.api.field_behavior) = REQUIRED]; 285 286 // Required. The instance to be created. 287 Instance instance = 3 [(google.api.field_behavior) = REQUIRED]; 288 289 // Optional. Idempotent request UUID. 290 string request_id = 4 [(google.api.field_behavior) = OPTIONAL]; 291} 292 293// Request for updating a notebook instance. 294message UpdateInstanceRequest { 295 // Required. A representation of an instance. 296 Instance instance = 1 [(google.api.field_behavior) = REQUIRED]; 297 298 // Required. Mask used to update an instance 299 google.protobuf.FieldMask update_mask = 2 300 [(google.api.field_behavior) = REQUIRED]; 301 302 // Optional. Idempotent request UUID. 303 string request_id = 3 [(google.api.field_behavior) = OPTIONAL]; 304} 305 306// Request for deleting a notebook instance. 307message DeleteInstanceRequest { 308 // Required. Format: 309 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 310 string name = 1 [ 311 (google.api.field_behavior) = REQUIRED, 312 (google.api.resource_reference) = { 313 type: "notebooks.googleapis.com/Instance" 314 } 315 ]; 316 317 // Optional. Idempotent request UUID. 318 string request_id = 2 [(google.api.field_behavior) = OPTIONAL]; 319} 320 321// Request for starting a notebook instance 322message StartInstanceRequest { 323 // Required. Format: 324 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 325 string name = 1 [(google.api.field_behavior) = REQUIRED]; 326} 327 328// Request for stopping a notebook instance 329message StopInstanceRequest { 330 // Required. Format: 331 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 332 string name = 1 [(google.api.field_behavior) = REQUIRED]; 333} 334 335// Request for resetting a notebook instance 336message ResetInstanceRequest { 337 // Required. Format: 338 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 339 string name = 1 [(google.api.field_behavior) = REQUIRED]; 340} 341 342// Request for checking if a notebook instance is upgradeable. 343message CheckInstanceUpgradabilityRequest { 344 // Required. Format: 345 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 346 string notebook_instance = 1 [(google.api.field_behavior) = REQUIRED]; 347} 348 349// Response for checking if a notebook instance is upgradeable. 350message CheckInstanceUpgradabilityResponse { 351 // If an instance is upgradeable. 352 bool upgradeable = 1; 353 354 // The version this instance will be upgraded to if calling the upgrade 355 // endpoint. This field will only be populated if field upgradeable is true. 356 string upgrade_version = 2; 357 358 // Additional information about upgrade. 359 string upgrade_info = 3; 360 361 // The new image self link this instance will be upgraded to if calling the 362 // upgrade endpoint. This field will only be populated if field upgradeable 363 // is true. 364 string upgrade_image = 4; 365} 366 367// Request for upgrading a notebook instance 368message UpgradeInstanceRequest { 369 // Required. Format: 370 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 371 string name = 1 [(google.api.field_behavior) = REQUIRED]; 372} 373 374// Request for rollbacking a notebook instance 375message RollbackInstanceRequest { 376 // Required. Format: 377 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 378 string name = 1 [ 379 (google.api.field_behavior) = REQUIRED, 380 (google.api.resource_reference) = { 381 type: "notebooks.googleapis.com/Instance" 382 } 383 ]; 384 385 // Required. The snapshot for rollback. 386 // Example: "projects/test-project/global/snapshots/krwlzipynril". 387 string target_snapshot = 2 [(google.api.field_behavior) = REQUIRED]; 388 389 // Required. Output only. Revision Id 390 string revision_id = 3 [ 391 (google.api.field_behavior) = OUTPUT_ONLY, 392 (google.api.field_behavior) = REQUIRED 393 ]; 394} 395 396// Request for creating a notebook instance diagnostic file. 397message DiagnoseInstanceRequest { 398 // Required. Format: 399 // `projects/{project_id}/locations/{location}/instances/{instance_id}` 400 string name = 1 [ 401 (google.api.field_behavior) = REQUIRED, 402 (google.api.resource_reference) = { 403 type: "notebooks.googleapis.com/Instance" 404 } 405 ]; 406 407 // Required. Defines flags that are used to run the diagnostic tool 408 DiagnosticConfig diagnostic_config = 2 409 [(google.api.field_behavior) = REQUIRED]; 410 411 // Optional. Maxmium amount of time in minutes before the operation times out. 412 int32 timeout_minutes = 3 [(google.api.field_behavior) = OPTIONAL]; 413} 414