firestore.proto 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. // Copyright 2018 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. syntax = "proto3";
  16. package google.firestore.v1;
  17. import "google/api/annotations.proto";
  18. import "google/firestore/v1/common.proto";
  19. import "google/firestore/v1/document.proto";
  20. import "google/firestore/v1/query.proto";
  21. import "google/firestore/v1/write.proto";
  22. import "google/protobuf/empty.proto";
  23. import "google/protobuf/timestamp.proto";
  24. import "google/rpc/status.proto";
  25. option csharp_namespace = "Google.Cloud.Firestore.V1Beta1";
  26. option go_package = "google.golang.org/genproto/googleapis/firestore/v1;firestore";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "FirestoreProto";
  29. option java_package = "com.google.firestore.v1";
  30. option objc_class_prefix = "GCFS";
  31. option php_namespace = "Google\\Cloud\\Firestore\\V1beta1";
  32. // Specification of the Firestore API.
  33. // The Cloud Firestore service.
  34. //
  35. // This service exposes several types of comparable timestamps:
  36. //
  37. // * `create_time` - The time at which a document was created. Changes only
  38. // when a document is deleted, then re-created. Increases in a strict
  39. // monotonic fashion.
  40. // * `update_time` - The time at which a document was last updated. Changes
  41. // every time a document is modified. Does not change when a write results
  42. // in no modifications. Increases in a strict monotonic fashion.
  43. // * `read_time` - The time at which a particular state was observed. Used
  44. // to denote a consistent snapshot of the database or the time at which a
  45. // Document was observed to not exist.
  46. // * `commit_time` - The time at which the writes in a transaction were
  47. // committed. Any read with an equal or greater `read_time` is guaranteed
  48. // to see the effects of the transaction.
  49. service Firestore {
  50. // Gets a single document.
  51. rpc GetDocument(GetDocumentRequest) returns (Document) {
  52. option (google.api.http) = {
  53. get: "/v1/{name=projects/*/databases/*/documents/*/**}"
  54. };
  55. }
  56. // Lists documents.
  57. rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) {
  58. option (google.api.http) = {
  59. get: "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}"
  60. };
  61. }
  62. // Creates a new document.
  63. rpc CreateDocument(CreateDocumentRequest) returns (Document) {
  64. option (google.api.http) = {
  65. post: "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}"
  66. body: "document"
  67. };
  68. }
  69. // Updates or inserts a document.
  70. rpc UpdateDocument(UpdateDocumentRequest) returns (Document) {
  71. option (google.api.http) = {
  72. patch: "/v1/{document.name=projects/*/databases/*/documents/*/**}"
  73. body: "document"
  74. };
  75. }
  76. // Deletes a document.
  77. rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) {
  78. option (google.api.http) = {
  79. delete: "/v1/{name=projects/*/databases/*/documents/*/**}"
  80. };
  81. }
  82. // Gets multiple documents.
  83. //
  84. // Documents returned by this method are not guaranteed to be returned in the
  85. // same order that they were requested.
  86. rpc BatchGetDocuments(BatchGetDocumentsRequest) returns (stream BatchGetDocumentsResponse) {
  87. option (google.api.http) = {
  88. post: "/v1/{database=projects/*/databases/*}/documents:batchGet"
  89. body: "*"
  90. };
  91. }
  92. // Starts a new transaction.
  93. rpc BeginTransaction(BeginTransactionRequest) returns (BeginTransactionResponse) {
  94. option (google.api.http) = {
  95. post: "/v1/{database=projects/*/databases/*}/documents:beginTransaction"
  96. body: "*"
  97. };
  98. }
  99. // Commits a transaction, while optionally updating documents.
  100. rpc Commit(CommitRequest) returns (CommitResponse) {
  101. option (google.api.http) = {
  102. post: "/v1/{database=projects/*/databases/*}/documents:commit"
  103. body: "*"
  104. };
  105. }
  106. // Rolls back a transaction.
  107. rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) {
  108. option (google.api.http) = {
  109. post: "/v1/{database=projects/*/databases/*}/documents:rollback"
  110. body: "*"
  111. };
  112. }
  113. // Runs a query.
  114. rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) {
  115. option (google.api.http) = {
  116. post: "/v1/{parent=projects/*/databases/*/documents}:runQuery"
  117. body: "*"
  118. additional_bindings {
  119. post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery"
  120. body: "*"
  121. }
  122. };
  123. }
  124. // Streams batches of document updates and deletes, in order.
  125. rpc Write(stream WriteRequest) returns (stream WriteResponse) {
  126. option (google.api.http) = {
  127. post: "/v1/{database=projects/*/databases/*}/documents:write"
  128. body: "*"
  129. };
  130. }
  131. // Listens to changes.
  132. rpc Listen(stream ListenRequest) returns (stream ListenResponse) {
  133. option (google.api.http) = {
  134. post: "/v1/{database=projects/*/databases/*}/documents:listen"
  135. body: "*"
  136. };
  137. }
  138. // Lists all the collection IDs underneath a document.
  139. rpc ListCollectionIds(ListCollectionIdsRequest) returns (ListCollectionIdsResponse) {
  140. option (google.api.http) = {
  141. post: "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds"
  142. body: "*"
  143. additional_bindings {
  144. post: "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds"
  145. body: "*"
  146. }
  147. };
  148. }
  149. }
  150. // The request for [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument].
  151. message GetDocumentRequest {
  152. // The resource name of the Document to get. In the format:
  153. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  154. string name = 1;
  155. // The fields to return. If not set, returns all fields.
  156. //
  157. // If the document has a field that is not present in this mask, that field
  158. // will not be returned in the response.
  159. DocumentMask mask = 2;
  160. // The consistency mode for this transaction.
  161. // If not set, defaults to strong consistency.
  162. oneof consistency_selector {
  163. // Reads the document in a transaction.
  164. bytes transaction = 3;
  165. // Reads the version of the document at the given time.
  166. // This may not be older than 60 seconds.
  167. google.protobuf.Timestamp read_time = 5;
  168. }
  169. }
  170. // The request for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
  171. message ListDocumentsRequest {
  172. // The parent resource name. In the format:
  173. // `projects/{project_id}/databases/{database_id}/documents` or
  174. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  175. // For example:
  176. // `projects/my-project/databases/my-database/documents` or
  177. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  178. string parent = 1;
  179. // The collection ID, relative to `parent`, to list. For example: `chatrooms`
  180. // or `messages`.
  181. string collection_id = 2;
  182. // The maximum number of documents to return.
  183. int32 page_size = 3;
  184. // The `next_page_token` value returned from a previous List request, if any.
  185. string page_token = 4;
  186. // The order to sort results by. For example: `priority desc, name`.
  187. string order_by = 6;
  188. // The fields to return. If not set, returns all fields.
  189. //
  190. // If a document has a field that is not present in this mask, that field
  191. // will not be returned in the response.
  192. DocumentMask mask = 7;
  193. // The consistency mode for this transaction.
  194. // If not set, defaults to strong consistency.
  195. oneof consistency_selector {
  196. // Reads documents in a transaction.
  197. bytes transaction = 8;
  198. // Reads documents as they were at the given time.
  199. // This may not be older than 60 seconds.
  200. google.protobuf.Timestamp read_time = 10;
  201. }
  202. // If the list should show missing documents. A missing document is a
  203. // document that does not exist but has sub-documents. These documents will
  204. // be returned with a key but will not have fields, [Document.create_time][google.firestore.v1.Document.create_time],
  205. // or [Document.update_time][google.firestore.v1.Document.update_time] set.
  206. //
  207. // Requests with `show_missing` may not specify `where` or
  208. // `order_by`.
  209. bool show_missing = 12;
  210. }
  211. // The response for [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
  212. message ListDocumentsResponse {
  213. // The Documents found.
  214. repeated Document documents = 1;
  215. // The next page token.
  216. string next_page_token = 2;
  217. }
  218. // The request for [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument].
  219. message CreateDocumentRequest {
  220. // The parent resource. For example:
  221. // `projects/{project_id}/databases/{database_id}/documents` or
  222. // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
  223. string parent = 1;
  224. // The collection ID, relative to `parent`, to list. For example: `chatrooms`.
  225. string collection_id = 2;
  226. // The client-assigned document ID to use for this document.
  227. //
  228. // Optional. If not specified, an ID will be assigned by the service.
  229. string document_id = 3;
  230. // The document to create. `name` must not be set.
  231. Document document = 4;
  232. // The fields to return. If not set, returns all fields.
  233. //
  234. // If the document has a field that is not present in this mask, that field
  235. // will not be returned in the response.
  236. DocumentMask mask = 5;
  237. }
  238. // The request for [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument].
  239. message UpdateDocumentRequest {
  240. // The updated document.
  241. // Creates the document if it does not already exist.
  242. Document document = 1;
  243. // The fields to update.
  244. // None of the field paths in the mask may contain a reserved name.
  245. //
  246. // If the document exists on the server and has fields not referenced in the
  247. // mask, they are left unchanged.
  248. // Fields referenced in the mask, but not present in the input document, are
  249. // deleted from the document on the server.
  250. DocumentMask update_mask = 2;
  251. // The fields to return. If not set, returns all fields.
  252. //
  253. // If the document has a field that is not present in this mask, that field
  254. // will not be returned in the response.
  255. DocumentMask mask = 3;
  256. // An optional precondition on the document.
  257. // The request will fail if this is set and not met by the target document.
  258. Precondition current_document = 4;
  259. }
  260. // The request for [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument].
  261. message DeleteDocumentRequest {
  262. // The resource name of the Document to delete. In the format:
  263. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  264. string name = 1;
  265. // An optional precondition on the document.
  266. // The request will fail if this is set and not met by the target document.
  267. Precondition current_document = 2;
  268. }
  269. // The request for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
  270. message BatchGetDocumentsRequest {
  271. // The database name. In the format:
  272. // `projects/{project_id}/databases/{database_id}`.
  273. string database = 1;
  274. // The names of the documents to retrieve. In the format:
  275. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  276. // The request will fail if any of the document is not a child resource of the
  277. // given `database`. Duplicate names will be elided.
  278. repeated string documents = 2;
  279. // The fields to return. If not set, returns all fields.
  280. //
  281. // If a document has a field that is not present in this mask, that field will
  282. // not be returned in the response.
  283. DocumentMask mask = 3;
  284. // The consistency mode for this transaction.
  285. // If not set, defaults to strong consistency.
  286. oneof consistency_selector {
  287. // Reads documents in a transaction.
  288. bytes transaction = 4;
  289. // Starts a new transaction and reads the documents.
  290. // Defaults to a read-only transaction.
  291. // The new transaction ID will be returned as the first response in the
  292. // stream.
  293. TransactionOptions new_transaction = 5;
  294. // Reads documents as they were at the given time.
  295. // This may not be older than 60 seconds.
  296. google.protobuf.Timestamp read_time = 7;
  297. }
  298. }
  299. // The streamed response for [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
  300. message BatchGetDocumentsResponse {
  301. // A single result.
  302. // This can be empty if the server is just returning a transaction.
  303. oneof result {
  304. // A document that was requested.
  305. Document found = 1;
  306. // A document name that was requested but does not exist. In the format:
  307. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  308. string missing = 2;
  309. }
  310. // The transaction that was started as part of this request.
  311. // Will only be set in the first response, and only if
  312. // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction] was set in the request.
  313. bytes transaction = 3;
  314. // The time at which the document was read.
  315. // This may be monotically increasing, in this case the previous documents in
  316. // the result stream are guaranteed not to have changed between their
  317. // read_time and this one.
  318. google.protobuf.Timestamp read_time = 4;
  319. }
  320. // The request for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
  321. message BeginTransactionRequest {
  322. // The database name. In the format:
  323. // `projects/{project_id}/databases/{database_id}`.
  324. string database = 1;
  325. // The options for the transaction.
  326. // Defaults to a read-write transaction.
  327. TransactionOptions options = 2;
  328. }
  329. // The response for [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
  330. message BeginTransactionResponse {
  331. // The transaction that was started.
  332. bytes transaction = 1;
  333. }
  334. // The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit].
  335. message CommitRequest {
  336. // The database name. In the format:
  337. // `projects/{project_id}/databases/{database_id}`.
  338. string database = 1;
  339. // The writes to apply.
  340. //
  341. // Always executed atomically and in order.
  342. repeated Write writes = 2;
  343. // If set, applies all writes in this transaction, and commits it.
  344. bytes transaction = 3;
  345. }
  346. // The response for [Firestore.Commit][google.firestore.v1.Firestore.Commit].
  347. message CommitResponse {
  348. // The result of applying the writes.
  349. //
  350. // This i-th write result corresponds to the i-th write in the
  351. // request.
  352. repeated WriteResult write_results = 1;
  353. // The time at which the commit occurred.
  354. google.protobuf.Timestamp commit_time = 2;
  355. }
  356. // The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback].
  357. message RollbackRequest {
  358. // The database name. In the format:
  359. // `projects/{project_id}/databases/{database_id}`.
  360. string database = 1;
  361. // The transaction to roll back.
  362. bytes transaction = 2;
  363. }
  364. // The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
  365. message RunQueryRequest {
  366. // The parent resource name. In the format:
  367. // `projects/{project_id}/databases/{database_id}/documents` or
  368. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  369. // For example:
  370. // `projects/my-project/databases/my-database/documents` or
  371. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  372. string parent = 1;
  373. // The query to run.
  374. oneof query_type {
  375. // A structured query.
  376. StructuredQuery structured_query = 2;
  377. }
  378. // The consistency mode for this transaction.
  379. // If not set, defaults to strong consistency.
  380. oneof consistency_selector {
  381. // Reads documents in a transaction.
  382. bytes transaction = 5;
  383. // Starts a new transaction and reads the documents.
  384. // Defaults to a read-only transaction.
  385. // The new transaction ID will be returned as the first response in the
  386. // stream.
  387. TransactionOptions new_transaction = 6;
  388. // Reads documents as they were at the given time.
  389. // This may not be older than 60 seconds.
  390. google.protobuf.Timestamp read_time = 7;
  391. }
  392. }
  393. // The response for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
  394. message RunQueryResponse {
  395. // The transaction that was started as part of this request.
  396. // Can only be set in the first response, and only if
  397. // [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction] was set in the request.
  398. // If set, no other fields will be set in this response.
  399. bytes transaction = 2;
  400. // A query result.
  401. // Not set when reporting partial progress.
  402. Document document = 1;
  403. // The time at which the document was read. This may be monotonically
  404. // increasing; in this case, the previous documents in the result stream are
  405. // guaranteed not to have changed between their `read_time` and this one.
  406. //
  407. // If the query returns no results, a response with `read_time` and no
  408. // `document` will be sent, and this represents the time at which the query
  409. // was run.
  410. google.protobuf.Timestamp read_time = 3;
  411. // The number of results that have been skipped due to an offset between
  412. // the last response and the current response.
  413. int32 skipped_results = 4;
  414. }
  415. // The request for [Firestore.Write][google.firestore.v1.Firestore.Write].
  416. //
  417. // The first request creates a stream, or resumes an existing one from a token.
  418. //
  419. // When creating a new stream, the server replies with a response containing
  420. // only an ID and a token, to use in the next request.
  421. //
  422. // When resuming a stream, the server first streams any responses later than the
  423. // given token, then a response containing only an up-to-date token, to use in
  424. // the next request.
  425. message WriteRequest {
  426. // The database name. In the format:
  427. // `projects/{project_id}/databases/{database_id}`.
  428. // This is only required in the first message.
  429. string database = 1;
  430. // The ID of the write stream to resume.
  431. // This may only be set in the first message. When left empty, a new write
  432. // stream will be created.
  433. string stream_id = 2;
  434. // The writes to apply.
  435. //
  436. // Always executed atomically and in order.
  437. // This must be empty on the first request.
  438. // This may be empty on the last request.
  439. // This must not be empty on all other requests.
  440. repeated Write writes = 3;
  441. // A stream token that was previously sent by the server.
  442. //
  443. // The client should set this field to the token from the most recent
  444. // [WriteResponse][google.firestore.v1.WriteResponse] it has received. This acknowledges that the client has
  445. // received responses up to this token. After sending this token, earlier
  446. // tokens may not be used anymore.
  447. //
  448. // The server may close the stream if there are too many unacknowledged
  449. // responses.
  450. //
  451. // Leave this field unset when creating a new stream. To resume a stream at
  452. // a specific point, set this field and the `stream_id` field.
  453. //
  454. // Leave this field unset when creating a new stream.
  455. bytes stream_token = 4;
  456. // Labels associated with this write request.
  457. map<string, string> labels = 5;
  458. }
  459. // The response for [Firestore.Write][google.firestore.v1.Firestore.Write].
  460. message WriteResponse {
  461. // The ID of the stream.
  462. // Only set on the first message, when a new stream was created.
  463. string stream_id = 1;
  464. // A token that represents the position of this response in the stream.
  465. // This can be used by a client to resume the stream at this point.
  466. //
  467. // This field is always set.
  468. bytes stream_token = 2;
  469. // The result of applying the writes.
  470. //
  471. // This i-th write result corresponds to the i-th write in the
  472. // request.
  473. repeated WriteResult write_results = 3;
  474. // The time at which the commit occurred.
  475. google.protobuf.Timestamp commit_time = 4;
  476. }
  477. // A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen]
  478. message ListenRequest {
  479. // The database name. In the format:
  480. // `projects/{project_id}/databases/{database_id}`.
  481. string database = 1;
  482. // The supported target changes.
  483. oneof target_change {
  484. // A target to add to this stream.
  485. Target add_target = 2;
  486. // The ID of a target to remove from this stream.
  487. int32 remove_target = 3;
  488. }
  489. // Labels associated with this target change.
  490. map<string, string> labels = 4;
  491. }
  492. // The response for [Firestore.Listen][google.firestore.v1.Firestore.Listen].
  493. message ListenResponse {
  494. // The supported responses.
  495. oneof response_type {
  496. // Targets have changed.
  497. TargetChange target_change = 2;
  498. // A [Document][google.firestore.v1.Document] has changed.
  499. DocumentChange document_change = 3;
  500. // A [Document][google.firestore.v1.Document] has been deleted.
  501. DocumentDelete document_delete = 4;
  502. // A [Document][google.firestore.v1.Document] has been removed from a target (because it is no longer
  503. // relevant to that target).
  504. DocumentRemove document_remove = 6;
  505. // A filter to apply to the set of documents previously returned for the
  506. // given target.
  507. //
  508. // Returned when documents may have been removed from the given target, but
  509. // the exact documents are unknown.
  510. ExistenceFilter filter = 5;
  511. }
  512. }
  513. // A specification of a set of documents to listen to.
  514. message Target {
  515. // A target specified by a set of documents names.
  516. message DocumentsTarget {
  517. // The names of the documents to retrieve. In the format:
  518. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  519. // The request will fail if any of the document is not a child resource of
  520. // the given `database`. Duplicate names will be elided.
  521. repeated string documents = 2;
  522. }
  523. // A target specified by a query.
  524. message QueryTarget {
  525. // The parent resource name. In the format:
  526. // `projects/{project_id}/databases/{database_id}/documents` or
  527. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  528. // For example:
  529. // `projects/my-project/databases/my-database/documents` or
  530. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  531. string parent = 1;
  532. // The query to run.
  533. oneof query_type {
  534. // A structured query.
  535. StructuredQuery structured_query = 2;
  536. }
  537. }
  538. // The type of target to listen to.
  539. oneof target_type {
  540. // A target specified by a query.
  541. QueryTarget query = 2;
  542. // A target specified by a set of document names.
  543. DocumentsTarget documents = 3;
  544. }
  545. // When to start listening.
  546. //
  547. // If not specified, all matching Documents are returned before any
  548. // subsequent changes.
  549. oneof resume_type {
  550. // A resume token from a prior [TargetChange][google.firestore.v1.TargetChange] for an identical target.
  551. //
  552. // Using a resume token with a different target is unsupported and may fail.
  553. bytes resume_token = 4;
  554. // Start listening after a specific `read_time`.
  555. //
  556. // The client must know the state of matching documents at this time.
  557. google.protobuf.Timestamp read_time = 11;
  558. }
  559. // A client provided target ID.
  560. //
  561. // If not set, the server will assign an ID for the target.
  562. //
  563. // Used for resuming a target without changing IDs. The IDs can either be
  564. // client-assigned or be server-assigned in a previous stream. All targets
  565. // with client provided IDs must be added before adding a target that needs
  566. // a server-assigned id.
  567. int32 target_id = 5;
  568. // If the target should be removed once it is current and consistent.
  569. bool once = 6;
  570. }
  571. // Targets being watched have changed.
  572. message TargetChange {
  573. // The type of change.
  574. enum TargetChangeType {
  575. // No change has occurred. Used only to send an updated `resume_token`.
  576. NO_CHANGE = 0;
  577. // The targets have been added.
  578. ADD = 1;
  579. // The targets have been removed.
  580. REMOVE = 2;
  581. // The targets reflect all changes committed before the targets were added
  582. // to the stream.
  583. //
  584. // This will be sent after or with a `read_time` that is greater than or
  585. // equal to the time at which the targets were added.
  586. //
  587. // Listeners can wait for this change if read-after-write semantics
  588. // are desired.
  589. CURRENT = 3;
  590. // The targets have been reset, and a new initial state for the targets
  591. // will be returned in subsequent changes.
  592. //
  593. // After the initial state is complete, `CURRENT` will be returned even
  594. // if the target was previously indicated to be `CURRENT`.
  595. RESET = 4;
  596. }
  597. // The type of change that occurred.
  598. TargetChangeType target_change_type = 1;
  599. // The target IDs of targets that have changed.
  600. //
  601. // If empty, the change applies to all targets.
  602. //
  603. // For `target_change_type=ADD`, the order of the target IDs matches the order
  604. // of the requests to add the targets. This allows clients to unambiguously
  605. // associate server-assigned target IDs with added targets.
  606. //
  607. // For other states, the order of the target IDs is not defined.
  608. repeated int32 target_ids = 2;
  609. // The error that resulted in this change, if applicable.
  610. google.rpc.Status cause = 3;
  611. // A token that can be used to resume the stream for the given `target_ids`,
  612. // or all targets if `target_ids` is empty.
  613. //
  614. // Not set on every target change.
  615. bytes resume_token = 4;
  616. // The consistent `read_time` for the given `target_ids` (omitted when the
  617. // target_ids are not at a consistent snapshot).
  618. //
  619. // The stream is guaranteed to send a `read_time` with `target_ids` empty
  620. // whenever the entire stream reaches a new consistent snapshot. ADD,
  621. // CURRENT, and RESET messages are guaranteed to (eventually) result in a
  622. // new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
  623. //
  624. // For a given stream, `read_time` is guaranteed to be monotonically
  625. // increasing.
  626. google.protobuf.Timestamp read_time = 6;
  627. }
  628. // The request for [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
  629. message ListCollectionIdsRequest {
  630. // The parent document. In the format:
  631. // `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
  632. // For example:
  633. // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
  634. string parent = 1;
  635. // The maximum number of results to return.
  636. int32 page_size = 2;
  637. // A page token. Must be a value from
  638. // [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
  639. string page_token = 3;
  640. }
  641. // The response from [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
  642. message ListCollectionIdsResponse {
  643. // The collection ids.
  644. repeated string collection_ids = 1;
  645. // A page token that may be used to continue the list.
  646. string next_page_token = 2;
  647. }