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.datastore.admin.v1; 18 19import "google/api/annotations.proto"; 20import "google/api/client.proto"; 21import "google/api/field_behavior.proto"; 22import "google/datastore/admin/v1/index.proto"; 23import "google/datastore/admin/v1/migration.proto"; 24import "google/longrunning/operations.proto"; 25import "google/protobuf/timestamp.proto"; 26 27option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; 28option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; 29option java_multiple_files = true; 30option java_outer_classname = "DatastoreAdminProto"; 31option java_package = "com.google.datastore.admin.v1"; 32option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; 33option ruby_package = "Google::Cloud::Datastore::Admin::V1"; 34 35// Google Cloud Datastore Admin API 36// 37// The Datastore Admin API provides several admin services for Cloud Datastore. 38// 39// Concepts: Project, namespace, kind, and entity as defined in the Google Cloud 40// Datastore API. 41// 42// Operation: An Operation represents work being performed in the background. 43// 44// EntityFilter: Allows specifying a subset of entities in a project. This is 45// specified as a combination of kinds and namespaces (either or both of which 46// may be all). 47// 48// Export/Import Service: 49// 50// - The Export/Import service provides the ability to copy all or a subset of 51// entities to/from Google Cloud Storage. 52// - Exported data may be imported into Cloud Datastore for any Google Cloud 53// Platform project. It is not restricted to the export source project. It is 54// possible to export from one project and then import into another. 55// - Exported data can also be loaded into Google BigQuery for analysis. 56// - Exports and imports are performed asynchronously. An Operation resource is 57// created for each export/import. The state (including any errors encountered) 58// of the export/import may be queried via the Operation resource. 59// 60// Index Service: 61// 62// - The index service manages Cloud Datastore composite indexes. 63// - Index creation and deletion are performed asynchronously. 64// An Operation resource is created for each such asynchronous operation. 65// The state of the operation (including any errors encountered) 66// may be queried via the Operation resource. 67// 68// Operation Service: 69// 70// - The Operations collection provides a record of actions performed for the 71// specified project (including any operations in progress). Operations are not 72// created directly but through calls on other collections or resources. 73// - An operation that is not yet done may be cancelled. The request to cancel 74// is asynchronous and the operation may continue to run for some time after the 75// request to cancel is made. 76// - An operation that is done may be deleted so that it is no longer listed as 77// part of the Operation collection. 78// - ListOperations returns all pending operations, but not completed 79// operations. 80// - Operations are created by service DatastoreAdmin, but are accessed via 81// service google.longrunning.Operations. 82service DatastoreAdmin { 83 option (google.api.default_host) = "datastore.googleapis.com"; 84 option (google.api.oauth_scopes) = 85 "https://www.googleapis.com/auth/cloud-platform," 86 "https://www.googleapis.com/auth/datastore"; 87 88 // Exports a copy of all or a subset of entities from Google Cloud Datastore 89 // to another storage system, such as Google Cloud Storage. Recent updates to 90 // entities may not be reflected in the export. The export occurs in the 91 // background and its progress can be monitored and managed via the 92 // Operation resource that is created. The output of an export may only be 93 // used once the associated operation is done. If an export operation is 94 // cancelled before completion it may leave partial data behind in Google 95 // Cloud Storage. 96 rpc ExportEntities(ExportEntitiesRequest) 97 returns (google.longrunning.Operation) { 98 option (google.api.http) = { 99 post: "/v1/projects/{project_id}:export" 100 body: "*" 101 }; 102 option (google.api.method_signature) = 103 "project_id,labels,entity_filter,output_url_prefix"; 104 option (google.longrunning.operation_info) = { 105 response_type: "ExportEntitiesResponse" 106 metadata_type: "ExportEntitiesMetadata" 107 }; 108 } 109 110 // Imports entities into Google Cloud Datastore. Existing entities with the 111 // same key are overwritten. The import occurs in the background and its 112 // progress can be monitored and managed via the Operation resource that is 113 // created. If an ImportEntities operation is cancelled, it is possible 114 // that a subset of the data has already been imported to Cloud Datastore. 115 rpc ImportEntities(ImportEntitiesRequest) 116 returns (google.longrunning.Operation) { 117 option (google.api.http) = { 118 post: "/v1/projects/{project_id}:import" 119 body: "*" 120 }; 121 option (google.api.method_signature) = 122 "project_id,labels,input_url,entity_filter"; 123 option (google.longrunning.operation_info) = { 124 response_type: "google.protobuf.Empty" 125 metadata_type: "ImportEntitiesMetadata" 126 }; 127 } 128 129 // Creates the specified index. 130 // A newly created index's initial state is `CREATING`. On completion of the 131 // returned [google.longrunning.Operation][google.longrunning.Operation], the 132 // state will be `READY`. If the index already exists, the call will return an 133 // `ALREADY_EXISTS` status. 134 // 135 // During index creation, the process could result in an error, in which 136 // case the index will move to the `ERROR` state. The process can be recovered 137 // by fixing the data that caused the error, removing the index with 138 // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then 139 // re-creating the index with [create] 140 // [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. 141 // 142 // Indexes with a single property cannot be created. 143 rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { 144 option (google.api.http) = { 145 post: "/v1/projects/{project_id}/indexes" 146 body: "index" 147 }; 148 option (google.longrunning.operation_info) = { 149 response_type: "Index" 150 metadata_type: "IndexOperationMetadata" 151 }; 152 } 153 154 // Deletes an existing index. 155 // An index can only be deleted if it is in a `READY` or `ERROR` state. On 156 // successful execution of the request, the index will be in a `DELETING` 157 // [state][google.datastore.admin.v1.Index.State]. And on completion of the 158 // returned [google.longrunning.Operation][google.longrunning.Operation], the 159 // index will be removed. 160 // 161 // During index deletion, the process could result in an error, in which 162 // case the index will move to the `ERROR` state. The process can be recovered 163 // by fixing the data that caused the error, followed by calling 164 // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. 165 rpc DeleteIndex(DeleteIndexRequest) returns (google.longrunning.Operation) { 166 option (google.api.http) = { 167 delete: "/v1/projects/{project_id}/indexes/{index_id}" 168 }; 169 option (google.longrunning.operation_info) = { 170 response_type: "Index" 171 metadata_type: "IndexOperationMetadata" 172 }; 173 } 174 175 // Gets an index. 176 rpc GetIndex(GetIndexRequest) returns (Index) { 177 option (google.api.http) = { 178 get: "/v1/projects/{project_id}/indexes/{index_id}" 179 }; 180 } 181 182 // Lists the indexes that match the specified filters. Datastore uses an 183 // eventually consistent query to fetch the list of indexes and may 184 // occasionally return stale results. 185 rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { 186 option (google.api.http) = { 187 get: "/v1/projects/{project_id}/indexes" 188 }; 189 } 190} 191 192// Metadata common to all Datastore Admin operations. 193message CommonMetadata { 194 // The various possible states for an ongoing Operation. 195 enum State { 196 // Unspecified. 197 STATE_UNSPECIFIED = 0; 198 199 // Request is being prepared for processing. 200 INITIALIZING = 1; 201 202 // Request is actively being processed. 203 PROCESSING = 2; 204 205 // Request is in the process of being cancelled after user called 206 // google.longrunning.Operations.CancelOperation on the operation. 207 CANCELLING = 3; 208 209 // Request has been processed and is in its finalization stage. 210 FINALIZING = 4; 211 212 // Request has completed successfully. 213 SUCCESSFUL = 5; 214 215 // Request has finished being processed, but encountered an error. 216 FAILED = 6; 217 218 // Request has finished being cancelled after user called 219 // google.longrunning.Operations.CancelOperation. 220 CANCELLED = 7; 221 } 222 223 // The time that work began on the operation. 224 google.protobuf.Timestamp start_time = 1; 225 226 // The time the operation ended, either successfully or otherwise. 227 google.protobuf.Timestamp end_time = 2; 228 229 // The type of the operation. Can be used as a filter in 230 // ListOperationsRequest. 231 OperationType operation_type = 3; 232 233 // The client-assigned labels which were provided when the operation was 234 // created. May also include additional labels. 235 map<string, string> labels = 4; 236 237 // The current state of the Operation. 238 State state = 5; 239} 240 241// Measures the progress of a particular metric. 242message Progress { 243 // The amount of work that has been completed. Note that this may be greater 244 // than work_estimated. 245 int64 work_completed = 1; 246 247 // An estimate of how much work needs to be performed. May be zero if the 248 // work estimate is unavailable. 249 int64 work_estimated = 2; 250} 251 252// The request for 253// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. 254message ExportEntitiesRequest { 255 // Required. Project ID against which to make the request. 256 string project_id = 1 [(google.api.field_behavior) = REQUIRED]; 257 258 // Client-assigned labels. 259 map<string, string> labels = 2; 260 261 // Description of what data from the project is included in the export. 262 EntityFilter entity_filter = 3; 263 264 // Required. Location for the export metadata and data files. 265 // 266 // The full resource URL of the external storage location. Currently, only 267 // Google Cloud Storage is supported. So output_url_prefix should be of the 268 // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the 269 // name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud 270 // Storage namespace path (this is not a Cloud Datastore namespace). For more 271 // information about Cloud Storage namespace paths, see 272 // [Object name 273 // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). 274 // 275 // The resulting files will be nested deeper than the specified URL prefix. 276 // The final output URL will be provided in the 277 // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] 278 // field. That value should be used for subsequent ImportEntities operations. 279 // 280 // By nesting the data files deeper, the same Cloud Storage bucket can be used 281 // in multiple ExportEntities operations without conflict. 282 string output_url_prefix = 4 [(google.api.field_behavior) = REQUIRED]; 283} 284 285// The request for 286// [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities]. 287message ImportEntitiesRequest { 288 // Required. Project ID against which to make the request. 289 string project_id = 1 [(google.api.field_behavior) = REQUIRED]; 290 291 // Client-assigned labels. 292 map<string, string> labels = 2; 293 294 // Required. The full resource URL of the external storage location. 295 // Currently, only Google Cloud Storage is supported. So input_url should be 296 // of the form: 297 // `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where 298 // `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is 299 // an optional Cloud Storage namespace path (this is not a Cloud Datastore 300 // namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written 301 // by the ExportEntities operation. For more information about Cloud Storage 302 // namespace paths, see 303 // [Object name 304 // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). 305 // 306 // For more information, see 307 // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. 308 string input_url = 3 [(google.api.field_behavior) = REQUIRED]; 309 310 // Optionally specify which kinds/namespaces are to be imported. If provided, 311 // the list must be a subset of the EntityFilter used in creating the export, 312 // otherwise a FAILED_PRECONDITION error will be returned. If no filter is 313 // specified then all entities from the export are imported. 314 EntityFilter entity_filter = 4; 315} 316 317// The response for 318// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. 319message ExportEntitiesResponse { 320 // Location of the output metadata file. This can be used to begin an import 321 // into Cloud Datastore (this project or another project). See 322 // [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url]. 323 // Only present if the operation completed successfully. 324 string output_url = 1; 325} 326 327// Metadata for ExportEntities operations. 328message ExportEntitiesMetadata { 329 // Metadata common to all Datastore Admin operations. 330 CommonMetadata common = 1; 331 332 // An estimate of the number of entities processed. 333 Progress progress_entities = 2; 334 335 // An estimate of the number of bytes processed. 336 Progress progress_bytes = 3; 337 338 // Description of which entities are being exported. 339 EntityFilter entity_filter = 4; 340 341 // Location for the export metadata and data files. This will be the same 342 // value as the 343 // [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix] 344 // field. The final output location is provided in 345 // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. 346 string output_url_prefix = 5; 347} 348 349// Metadata for ImportEntities operations. 350message ImportEntitiesMetadata { 351 // Metadata common to all Datastore Admin operations. 352 CommonMetadata common = 1; 353 354 // An estimate of the number of entities processed. 355 Progress progress_entities = 2; 356 357 // An estimate of the number of bytes processed. 358 Progress progress_bytes = 3; 359 360 // Description of which entities are being imported. 361 EntityFilter entity_filter = 4; 362 363 // The location of the import metadata file. This will be the same value as 364 // the 365 // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] 366 // field. 367 string input_url = 5; 368} 369 370// Identifies a subset of entities in a project. This is specified as 371// combinations of kinds and namespaces (either or both of which may be all, as 372// described in the following examples). 373// Example usage: 374// 375// Entire project: 376// kinds=[], namespace_ids=[] 377// 378// Kinds Foo and Bar in all namespaces: 379// kinds=['Foo', 'Bar'], namespace_ids=[] 380// 381// Kinds Foo and Bar only in the default namespace: 382// kinds=['Foo', 'Bar'], namespace_ids=[''] 383// 384// Kinds Foo and Bar in both the default and Baz namespaces: 385// kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] 386// 387// The entire Baz namespace: 388// kinds=[], namespace_ids=['Baz'] 389message EntityFilter { 390 // If empty, then this represents all kinds. 391 repeated string kinds = 1; 392 393 // An empty list represents all namespaces. This is the preferred 394 // usage for projects that don't use namespaces. 395 // 396 // An empty string element represents the default namespace. This should be 397 // used if the project has data in non-default namespaces, but doesn't want to 398 // include them. 399 // Each namespace in this list must be unique. 400 repeated string namespace_ids = 2; 401} 402 403// The request for 404// [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. 405message CreateIndexRequest { 406 // Project ID against which to make the request. 407 string project_id = 1; 408 409 // The index to create. The name and state fields are output only and will be 410 // ignored. Single property indexes cannot be created or deleted. 411 Index index = 3; 412} 413 414// The request for 415// [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]. 416message DeleteIndexRequest { 417 // Project ID against which to make the request. 418 string project_id = 1; 419 420 // The resource ID of the index to delete. 421 string index_id = 3; 422} 423 424// The request for 425// [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex]. 426message GetIndexRequest { 427 // Project ID against which to make the request. 428 string project_id = 1; 429 430 // The resource ID of the index to get. 431 string index_id = 3; 432} 433 434// The request for 435// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. 436message ListIndexesRequest { 437 // Project ID against which to make the request. 438 string project_id = 1; 439 440 string filter = 3; 441 442 // The maximum number of items to return. If zero, then all results will be 443 // returned. 444 int32 page_size = 4; 445 446 // The next_page_token value returned from a previous List request, if any. 447 string page_token = 5; 448} 449 450// The response for 451// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. 452message ListIndexesResponse { 453 // The indexes. 454 repeated Index indexes = 1; 455 456 // The standard List next-page token. 457 string next_page_token = 2; 458} 459 460// Metadata for Index operations. 461message IndexOperationMetadata { 462 // Metadata common to all Datastore Admin operations. 463 CommonMetadata common = 1; 464 465 // An estimate of the number of entities processed. 466 Progress progress_entities = 2; 467 468 // The index resource ID that this operation is acting on. 469 string index_id = 3; 470} 471 472// Metadata for Datastore to Firestore migration operations. 473// 474// The DatastoreFirestoreMigration operation is not started by the end-user via 475// an explicit "creation" method. This is an intentional deviation from the LRO 476// design pattern. 477// 478// This singleton resource can be accessed at: 479// "projects/{project_id}/operations/datastore-firestore-migration" 480message DatastoreFirestoreMigrationMetadata { 481 // The current state of migration from Cloud Datastore to Cloud Firestore in 482 // Datastore mode. 483 MigrationState migration_state = 1; 484 485 // The current step of migration from Cloud Datastore to Cloud Firestore in 486 // Datastore mode. 487 MigrationStep migration_step = 2; 488} 489 490// Operation types. 491enum OperationType { 492 // Unspecified. 493 OPERATION_TYPE_UNSPECIFIED = 0; 494 495 // ExportEntities. 496 EXPORT_ENTITIES = 1; 497 498 // ImportEntities. 499 IMPORT_ENTITIES = 2; 500 501 // CreateIndex. 502 CREATE_INDEX = 3; 503 504 // DeleteIndex. 505 DELETE_INDEX = 4; 506} 507