xref: /aosp_15_r20/external/googleapis/google/firestore/v1/common.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
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.firestore.v1;
18
19import "google/protobuf/timestamp.proto";
20
21option csharp_namespace = "Google.Cloud.Firestore.V1";
22option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb";
23option java_multiple_files = true;
24option java_outer_classname = "CommonProto";
25option java_package = "com.google.firestore.v1";
26option objc_class_prefix = "GCFS";
27option php_namespace = "Google\\Cloud\\Firestore\\V1";
28option ruby_package = "Google::Cloud::Firestore::V1";
29
30// A set of field paths on a document.
31// Used to restrict a get or update operation on a document to a subset of its
32// fields.
33// This is different from standard field masks, as this is always scoped to a
34// [Document][google.firestore.v1.Document], and takes in account the dynamic
35// nature of [Value][google.firestore.v1.Value].
36message DocumentMask {
37  // The list of field paths in the mask. See
38  // [Document.fields][google.firestore.v1.Document.fields] for a field path
39  // syntax reference.
40  repeated string field_paths = 1;
41}
42
43// A precondition on a document, used for conditional operations.
44message Precondition {
45  // The type of precondition.
46  oneof condition_type {
47    // When set to `true`, the target document must exist.
48    // When set to `false`, the target document must not exist.
49    bool exists = 1;
50
51    // When set, the target document must exist and have been last updated at
52    // that time. Timestamp must be microsecond aligned.
53    google.protobuf.Timestamp update_time = 2;
54  }
55}
56
57// Options for creating a new transaction.
58message TransactionOptions {
59  // Options for a transaction that can be used to read and write documents.
60  //
61  // Firestore does not allow 3rd party auth requests to create read-write.
62  // transactions.
63  message ReadWrite {
64    // An optional transaction to retry.
65    bytes retry_transaction = 1;
66  }
67
68  // Options for a transaction that can only be used to read documents.
69  message ReadOnly {
70    // The consistency mode for this transaction. If not set, defaults to strong
71    // consistency.
72    oneof consistency_selector {
73      // Reads documents at the given time.
74      //
75      // This must be a microsecond precision timestamp within the past one
76      // hour, or if Point-in-Time Recovery is enabled, can additionally be a
77      // whole minute timestamp within the past 7 days.
78      google.protobuf.Timestamp read_time = 2;
79    }
80  }
81
82  // The mode of the transaction.
83  oneof mode {
84    // The transaction can only be used for read operations.
85    ReadOnly read_only = 2;
86
87    // The transaction can be used for both read and write operations.
88    ReadWrite read_write = 3;
89  }
90}
91