1// Copyright 2019 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// 15 16syntax = "proto3"; 17 18package google.firestore.admin.v1beta1; 19 20import "google/api/annotations.proto"; 21import "google/firestore/admin/v1beta1/index.proto"; 22import "google/longrunning/operations.proto"; 23import "google/protobuf/empty.proto"; 24import "google/protobuf/timestamp.proto"; 25import "google/api/client.proto"; 26 27option csharp_namespace = "Google.Cloud.Firestore.Admin.V1Beta1"; 28option go_package = "cloud.google.com/go/firestore/admin/apiv1beta1/adminpb;adminpb"; 29option java_multiple_files = true; 30option java_outer_classname = "FirestoreAdminProto"; 31option java_package = "com.google.firestore.admin.v1beta1"; 32option objc_class_prefix = "GCFS"; 33 34// The Cloud Firestore Admin API. 35// 36// This API provides several administrative services for Cloud Firestore. 37// 38// # Concepts 39// 40// Project, Database, Namespace, Collection, and Document are used as defined in 41// the Google Cloud Firestore API. 42// 43// Operation: An Operation represents work being performed in the background. 44// 45// 46// # Services 47// 48// ## Index 49// 50// The index service manages Cloud Firestore indexes. 51// 52// Index creation is performed asynchronously. 53// An Operation resource is created for each such asynchronous operation. 54// The state of the operation (including any errors encountered) 55// may be queried via the Operation resource. 56// 57// ## Metadata 58// 59// Provides metadata and statistical information about data in Cloud Firestore. 60// The data provided as part of this API may be stale. 61// 62// ## Operation 63// 64// The Operations collection provides a record of actions performed for the 65// specified Project (including any Operations in progress). Operations are not 66// created directly but through calls on other collections or resources. 67// 68// An Operation that is not yet done may be cancelled. The request to cancel is 69// asynchronous and the Operation may continue to run for some time after the 70// request to cancel is made. 71// 72// An Operation that is done may be deleted so that it is no longer listed as 73// part of the Operation collection. 74// 75// Operations are created by service `FirestoreAdmin`, but are accessed via 76// service `google.longrunning.Operations`. 77service FirestoreAdmin { 78 option (google.api.default_host) = "firestore.googleapis.com"; 79 option (google.api.oauth_scopes) = 80 "https://www.googleapis.com/auth/cloud-platform," 81 "https://www.googleapis.com/auth/datastore"; 82 83 // Creates the specified index. 84 // A newly created index's initial state is `CREATING`. On completion of the 85 // returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. 86 // If the index already exists, the call will return an `ALREADY_EXISTS` 87 // status. 88 // 89 // During creation, the process could result in an error, in which case the 90 // index will move to the `ERROR` state. The process can be recovered by 91 // fixing the data that caused the error, removing the index with 92 // [delete][google.firestore.admin.v1beta1.FirestoreAdmin.DeleteIndex], then re-creating the index with 93 // [create][google.firestore.admin.v1beta1.FirestoreAdmin.CreateIndex]. 94 // 95 // Indexes with a single field cannot be created. 96 rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { 97 option (google.api.http) = { 98 post: "/v1beta1/{parent=projects/*/databases/*}/indexes" 99 body: "index" 100 }; 101 } 102 103 // Lists the indexes that match the specified filters. 104 rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { 105 option (google.api.http) = { 106 get: "/v1beta1/{parent=projects/*/databases/*}/indexes" 107 }; 108 } 109 110 // Gets an index. 111 rpc GetIndex(GetIndexRequest) returns (Index) { 112 option (google.api.http) = { 113 get: "/v1beta1/{name=projects/*/databases/*/indexes/*}" 114 }; 115 } 116 117 // Deletes an index. 118 rpc DeleteIndex(DeleteIndexRequest) returns (google.protobuf.Empty) { 119 option (google.api.http) = { 120 delete: "/v1beta1/{name=projects/*/databases/*/indexes/*}" 121 }; 122 } 123 124 // Exports a copy of all or a subset of documents from Google Cloud Firestore 125 // to another storage system, such as Google Cloud Storage. Recent updates to 126 // documents may not be reflected in the export. The export occurs in the 127 // background and its progress can be monitored and managed via the 128 // Operation resource that is created. The output of an export may only be 129 // used once the associated operation is done. If an export operation is 130 // cancelled before completion it may leave partial data behind in Google 131 // Cloud Storage. 132 rpc ExportDocuments(ExportDocumentsRequest) returns (google.longrunning.Operation) { 133 option (google.api.http) = { 134 post: "/v1beta1/{name=projects/*/databases/*}:exportDocuments" 135 body: "*" 136 }; 137 } 138 139 // Imports documents into Google Cloud Firestore. Existing documents with the 140 // same name are overwritten. The import occurs in the background and its 141 // progress can be monitored and managed via the Operation resource that is 142 // created. If an ImportDocuments operation is cancelled, it is possible 143 // that a subset of the data has already been imported to Cloud Firestore. 144 rpc ImportDocuments(ImportDocumentsRequest) returns (google.longrunning.Operation) { 145 option (google.api.http) = { 146 post: "/v1beta1/{name=projects/*/databases/*}:importDocuments" 147 body: "*" 148 }; 149 } 150} 151 152// Metadata for index operations. This metadata populates 153// the metadata field of [google.longrunning.Operation][google.longrunning.Operation]. 154message IndexOperationMetadata { 155 // The type of index operation. 156 enum OperationType { 157 // Unspecified. Never set by server. 158 OPERATION_TYPE_UNSPECIFIED = 0; 159 160 // The operation is creating the index. Initiated by a `CreateIndex` call. 161 CREATING_INDEX = 1; 162 } 163 164 // The time that work began on the operation. 165 google.protobuf.Timestamp start_time = 1; 166 167 // The time the operation ended, either successfully or otherwise. Unset if 168 // the operation is still active. 169 google.protobuf.Timestamp end_time = 2; 170 171 // The index resource that this operation is acting on. For example: 172 // `projects/{project_id}/databases/{database_id}/indexes/{index_id}` 173 string index = 3; 174 175 // The type of index operation. 176 OperationType operation_type = 4; 177 178 // True if the [google.longrunning.Operation] was cancelled. If the 179 // cancellation is in progress, cancelled will be true but 180 // [google.longrunning.Operation.done][google.longrunning.Operation.done] will be false. 181 bool cancelled = 5; 182 183 // Progress of the existing operation, measured in number of documents. 184 Progress document_progress = 6; 185} 186 187// Measures the progress of a particular metric. 188message Progress { 189 // An estimate of how much work has been completed. Note that this may be 190 // greater than `work_estimated`. 191 int64 work_completed = 1; 192 193 // An estimate of how much work needs to be performed. Zero if the 194 // work estimate is unavailable. May change as work progresses. 195 int64 work_estimated = 2; 196} 197 198// The request for [FirestoreAdmin.CreateIndex][google.firestore.admin.v1beta1.FirestoreAdmin.CreateIndex]. 199message CreateIndexRequest { 200 // The name of the database this index will apply to. For example: 201 // `projects/{project_id}/databases/{database_id}` 202 string parent = 1; 203 204 // The index to create. The name and state fields are output only and will be 205 // ignored. Certain single field indexes cannot be created or deleted. 206 Index index = 2; 207} 208 209// The request for [FirestoreAdmin.GetIndex][google.firestore.admin.v1beta1.FirestoreAdmin.GetIndex]. 210message GetIndexRequest { 211 // The name of the index. For example: 212 // `projects/{project_id}/databases/{database_id}/indexes/{index_id}` 213 string name = 1; 214} 215 216// The request for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1beta1.FirestoreAdmin.ListIndexes]. 217message ListIndexesRequest { 218 // The database name. For example: 219 // `projects/{project_id}/databases/{database_id}` 220 string parent = 1; 221 222 string filter = 2; 223 224 // The standard List page size. 225 int32 page_size = 3; 226 227 // The standard List page token. 228 string page_token = 4; 229} 230 231// The request for [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1beta1.FirestoreAdmin.DeleteIndex]. 232message DeleteIndexRequest { 233 // The index name. For example: 234 // `projects/{project_id}/databases/{database_id}/indexes/{index_id}` 235 string name = 1; 236} 237 238// The response for [FirestoreAdmin.ListIndexes][google.firestore.admin.v1beta1.FirestoreAdmin.ListIndexes]. 239message ListIndexesResponse { 240 // The indexes. 241 repeated Index indexes = 1; 242 243 // The standard List next-page token. 244 string next_page_token = 2; 245} 246 247// The request for [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1beta1.FirestoreAdmin.ExportDocuments]. 248message ExportDocumentsRequest { 249 // Database to export. Should be of the form: 250 // `projects/{project_id}/databases/{database_id}`. 251 string name = 1; 252 253 // Which collection ids to export. Unspecified means all collections. 254 repeated string collection_ids = 3; 255 256 // The output URI. Currently only supports Google Cloud Storage URIs of the 257 // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name 258 // of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional 259 // Google Cloud Storage namespace path. When 260 // choosing a name, be sure to consider Google Cloud Storage naming 261 // guidelines: https://cloud.google.com/storage/docs/naming. 262 // If the URI is a bucket (without a namespace path), a prefix will be 263 // generated based on the start time. 264 string output_uri_prefix = 4; 265} 266 267// The request for [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1beta1.FirestoreAdmin.ImportDocuments]. 268message ImportDocumentsRequest { 269 // Database to import into. Should be of the form: 270 // `projects/{project_id}/databases/{database_id}`. 271 string name = 1; 272 273 // Which collection ids to import. Unspecified means all collections included 274 // in the import. 275 repeated string collection_ids = 3; 276 277 // Location of the exported files. 278 // This must match the output_uri_prefix of an ExportDocumentsResponse from 279 // an export that has completed successfully. 280 // See: 281 // [google.firestore.admin.v1beta1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1beta1.ExportDocumentsResponse.output_uri_prefix]. 282 string input_uri_prefix = 4; 283} 284 285// Returned in the [google.longrunning.Operation][google.longrunning.Operation] response field. 286message ExportDocumentsResponse { 287 // Location of the output files. This can be used to begin an import 288 // into Cloud Firestore (this project or another project) after the operation 289 // completes successfully. 290 string output_uri_prefix = 1; 291} 292 293// Metadata for ExportDocuments operations. 294message ExportDocumentsMetadata { 295 // The time that work began on the operation. 296 google.protobuf.Timestamp start_time = 1; 297 298 // The time the operation ended, either successfully or otherwise. Unset if 299 // the operation is still active. 300 google.protobuf.Timestamp end_time = 2; 301 302 // The state of the export operation. 303 OperationState operation_state = 3; 304 305 // An estimate of the number of documents processed. 306 Progress progress_documents = 4; 307 308 // An estimate of the number of bytes processed. 309 Progress progress_bytes = 5; 310 311 // Which collection ids are being exported. 312 repeated string collection_ids = 6; 313 314 // Where the entities are being exported to. 315 string output_uri_prefix = 7; 316} 317 318// Metadata for ImportDocuments operations. 319message ImportDocumentsMetadata { 320 // The time that work began on the operation. 321 google.protobuf.Timestamp start_time = 1; 322 323 // The time the operation ended, either successfully or otherwise. Unset if 324 // the operation is still active. 325 google.protobuf.Timestamp end_time = 2; 326 327 // The state of the import operation. 328 OperationState operation_state = 3; 329 330 // An estimate of the number of documents processed. 331 Progress progress_documents = 4; 332 333 // An estimate of the number of bytes processed. 334 Progress progress_bytes = 5; 335 336 // Which collection ids are being imported. 337 repeated string collection_ids = 6; 338 339 // The location of the documents being imported. 340 string input_uri_prefix = 7; 341} 342 343// The various possible states for an ongoing Operation. 344enum OperationState { 345 // Unspecified. 346 STATE_UNSPECIFIED = 0; 347 348 // Request is being prepared for processing. 349 INITIALIZING = 1; 350 351 // Request is actively being processed. 352 PROCESSING = 2; 353 354 // Request is in the process of being cancelled after user called 355 // google.longrunning.Operations.CancelOperation on the operation. 356 CANCELLING = 3; 357 358 // Request has been processed and is in its finalization stage. 359 FINALIZING = 4; 360 361 // Request has completed successfully. 362 SUCCESSFUL = 5; 363 364 // Request has finished being processed, but encountered an error. 365 FAILED = 6; 366 367 // Request has finished being cancelled after user called 368 // google.longrunning.Operations.CancelOperation. 369 CANCELLED = 7; 370} 371