1// Copyright 2018 Google Inc. 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.v1beta1; 18 19import "google/api/annotations.proto"; 20import "google/longrunning/operations.proto"; 21import "google/protobuf/timestamp.proto"; 22 23option csharp_namespace = "Google.Cloud.Datastore.Admin.V1Beta1"; 24option go_package = "google.golang.org/genproto/googleapis/datastore/admin/v1beta1;admin"; 25option java_multiple_files = true; 26option java_outer_classname = "DatastoreAdminProto"; 27option java_package = "com.google.datastore.admin.v1beta1"; 28option ruby_package = "Google::Cloud::Datastore::Admin::V1beta1"; 29 30// Google Cloud Datastore Admin API 31// 32// The Datastore Admin API provides several admin services for Cloud Datastore. 33// 34// ----------------------------------------------------------------------------- 35// ## Concepts 36// 37// Project, namespace, kind, and entity as defined in the Google Cloud Datastore 38// API. 39// 40// Operation: An Operation represents work being performed in the background. 41// 42// EntityFilter: Allows specifying a subset of entities in a project. This is 43// specified as a combination of kinds and namespaces (either or both of which 44// may be all). 45// 46// ----------------------------------------------------------------------------- 47// ## Services 48// 49// # Export/Import 50// 51// The Export/Import service provides the ability to copy all or a subset of 52// entities to/from Google Cloud Storage. 53// 54// Exported data may be imported into Cloud Datastore for any Google Cloud 55// Platform project. It is not restricted to the export source project. It is 56// possible to export from one project and then import into another. 57// 58// Exported data can also be loaded into Google BigQuery for analysis. 59// 60// Exports and imports are performed asynchronously. An Operation resource is 61// created for each export/import. The state (including any errors encountered) 62// of the export/import may be queried via the Operation resource. 63// 64// # Operation 65// 66// The Operations collection provides a record of actions performed for the 67// specified project (including any operations in progress). Operations are not 68// created directly but through calls on other collections or resources. 69// 70// An operation that is not yet done may be cancelled. The request to cancel is 71// asynchronous and the operation may continue to run for some time after the 72// request to cancel is made. 73// 74// An operation that is done may be deleted so that it is no longer listed as 75// part of the Operation collection. 76// 77// ListOperations returns all pending operations, but not completed operations. 78// 79// Operations are created by service DatastoreAdmin, 80// but are accessed via service google.longrunning.Operations. 81service DatastoreAdmin { 82 // Exports a copy of all or a subset of entities from Google Cloud Datastore 83 // to another storage system, such as Google Cloud Storage. Recent updates to 84 // entities may not be reflected in the export. The export occurs in the 85 // background and its progress can be monitored and managed via the 86 // Operation resource that is created. The output of an export may only be 87 // used once the associated operation is done. If an export operation is 88 // cancelled before completion it may leave partial data behind in Google 89 // Cloud Storage. 90 rpc ExportEntities(ExportEntitiesRequest) 91 returns (google.longrunning.Operation) { 92 option (google.api.http) = { 93 post: "/v1beta1/projects/{project_id}:export" 94 body: "*" 95 }; 96 } 97 98 // Imports entities into Google Cloud Datastore. Existing entities with the 99 // same key are overwritten. The import occurs in the background and its 100 // progress can be monitored and managed via the Operation resource that is 101 // created. If an ImportEntities operation is cancelled, it is possible 102 // that a subset of the data has already been imported to Cloud Datastore. 103 rpc ImportEntities(ImportEntitiesRequest) 104 returns (google.longrunning.Operation) { 105 option (google.api.http) = { 106 post: "/v1beta1/projects/{project_id}:import" 107 body: "*" 108 }; 109 } 110} 111 112// Metadata common to all Datastore Admin operations. 113message CommonMetadata { 114 // The various possible states for an ongoing Operation. 115 enum State { 116 // Unspecified. 117 STATE_UNSPECIFIED = 0; 118 119 // Request is being prepared for processing. 120 INITIALIZING = 1; 121 122 // Request is actively being processed. 123 PROCESSING = 2; 124 125 // Request is in the process of being cancelled after user called 126 // google.longrunning.Operations.CancelOperation on the operation. 127 CANCELLING = 3; 128 129 // Request has been processed and is in its finalization stage. 130 FINALIZING = 4; 131 132 // Request has completed successfully. 133 SUCCESSFUL = 5; 134 135 // Request has finished being processed, but encountered an error. 136 FAILED = 6; 137 138 // Request has finished being cancelled after user called 139 // google.longrunning.Operations.CancelOperation. 140 CANCELLED = 7; 141 } 142 143 // The time that work began on the operation. 144 google.protobuf.Timestamp start_time = 1; 145 146 // The time the operation ended, either successfully or otherwise. 147 google.protobuf.Timestamp end_time = 2; 148 149 // The type of the operation. Can be used as a filter in 150 // ListOperationsRequest. 151 OperationType operation_type = 3; 152 153 // The client-assigned labels which were provided when the operation was 154 // created. May also include additional labels. 155 map<string, string> labels = 4; 156 157 // The current state of the Operation. 158 State state = 5; 159} 160 161// Measures the progress of a particular metric. 162message Progress { 163 // The amount of work that has been completed. Note that this may be greater 164 // than work_estimated. 165 int64 work_completed = 1; 166 167 // An estimate of how much work needs to be performed. May be zero if the 168 // work estimate is unavailable. 169 int64 work_estimated = 2; 170} 171 172// The request for 173// [google.datastore.admin.v1beta1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1beta1.DatastoreAdmin.ExportEntities]. 174message ExportEntitiesRequest { 175 // Project ID against which to make the request. 176 string project_id = 1; 177 178 // Client-assigned labels. 179 map<string, string> labels = 2; 180 181 // Description of what data from the project is included in the export. 182 EntityFilter entity_filter = 3; 183 184 // Location for the export metadata and data files. 185 // 186 // The full resource URL of the external storage location. Currently, only 187 // Google Cloud Storage is supported. So output_url_prefix should be of the 188 // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the 189 // name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud 190 // Storage namespace path (this is not a Cloud Datastore namespace). For more 191 // information about Cloud Storage namespace paths, see 192 // [Object name 193 // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). 194 // 195 // The resulting files will be nested deeper than the specified URL prefix. 196 // The final output URL will be provided in the 197 // [google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url][google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url] 198 // field. That value should be used for subsequent ImportEntities operations. 199 // 200 // By nesting the data files deeper, the same Cloud Storage bucket can be used 201 // in multiple ExportEntities operations without conflict. 202 string output_url_prefix = 4; 203} 204 205// The request for 206// [google.datastore.admin.v1beta1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1beta1.DatastoreAdmin.ImportEntities]. 207message ImportEntitiesRequest { 208 // Project ID against which to make the request. 209 string project_id = 1; 210 211 // Client-assigned labels. 212 map<string, string> labels = 2; 213 214 // The full resource URL of the external storage location. Currently, only 215 // Google Cloud Storage is supported. So input_url should be of the form: 216 // `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where 217 // `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is 218 // an optional Cloud Storage namespace path (this is not a Cloud Datastore 219 // namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written 220 // by the ExportEntities operation. For more information about Cloud Storage 221 // namespace paths, see 222 // [Object name 223 // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). 224 // 225 // For more information, see 226 // [google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url][google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url]. 227 string input_url = 3; 228 229 // Optionally specify which kinds/namespaces are to be imported. If provided, 230 // the list must be a subset of the EntityFilter used in creating the export, 231 // otherwise a FAILED_PRECONDITION error will be returned. If no filter is 232 // specified then all entities from the export are imported. 233 EntityFilter entity_filter = 4; 234} 235 236// The response for 237// [google.datastore.admin.v1beta1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1beta1.DatastoreAdmin.ExportEntities]. 238message ExportEntitiesResponse { 239 // Location of the output metadata file. This can be used to begin an import 240 // into Cloud Datastore (this project or another project). See 241 // [google.datastore.admin.v1beta1.ImportEntitiesRequest.input_url][google.datastore.admin.v1beta1.ImportEntitiesRequest.input_url]. 242 // Only present if the operation completed successfully. 243 string output_url = 1; 244} 245 246// Metadata for ExportEntities operations. 247message ExportEntitiesMetadata { 248 // Metadata common to all Datastore Admin operations. 249 CommonMetadata common = 1; 250 251 // An estimate of the number of entities processed. 252 Progress progress_entities = 2; 253 254 // An estimate of the number of bytes processed. 255 Progress progress_bytes = 3; 256 257 // Description of which entities are being exported. 258 EntityFilter entity_filter = 4; 259 260 // Location for the export metadata and data files. This will be the same 261 // value as the 262 // [google.datastore.admin.v1beta1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1beta1.ExportEntitiesRequest.output_url_prefix] 263 // field. The final output location is provided in 264 // [google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url][google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url]. 265 string output_url_prefix = 5; 266} 267 268// Metadata for ImportEntities operations. 269message ImportEntitiesMetadata { 270 // Metadata common to all Datastore Admin operations. 271 CommonMetadata common = 1; 272 273 // An estimate of the number of entities processed. 274 Progress progress_entities = 2; 275 276 // An estimate of the number of bytes processed. 277 Progress progress_bytes = 3; 278 279 // Description of which entities are being imported. 280 EntityFilter entity_filter = 4; 281 282 // The location of the import metadata file. This will be the same value as 283 // the 284 // [google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url][google.datastore.admin.v1beta1.ExportEntitiesResponse.output_url] 285 // field. 286 string input_url = 5; 287} 288 289// Identifies a subset of entities in a project. This is specified as 290// combinations of kinds and namespaces (either or both of which may be all, as 291// described in the following examples). 292// Example usage: 293// 294// Entire project: 295// kinds=[], namespace_ids=[] 296// 297// Kinds Foo and Bar in all namespaces: 298// kinds=['Foo', 'Bar'], namespace_ids=[] 299// 300// Kinds Foo and Bar only in the default namespace: 301// kinds=['Foo', 'Bar'], namespace_ids=[''] 302// 303// Kinds Foo and Bar in both the default and Baz namespaces: 304// kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] 305// 306// The entire Baz namespace: 307// kinds=[], namespace_ids=['Baz'] 308message EntityFilter { 309 // If empty, then this represents all kinds. 310 repeated string kinds = 1; 311 312 // An empty list represents all namespaces. This is the preferred 313 // usage for projects that don't use namespaces. 314 // 315 // An empty string element represents the default namespace. This should be 316 // used if the project has data in non-default namespaces, but doesn't want to 317 // include them. 318 // Each namespace in this list must be unique. 319 repeated string namespace_ids = 2; 320} 321 322// Operation types. 323enum OperationType { 324 // Unspecified. 325 OPERATION_TYPE_UNSPECIFIED = 0; 326 327 // ExportEntities. 328 EXPORT_ENTITIES = 1; 329 330 // ImportEntities. 331 IMPORT_ENTITIES = 2; 332} 333