1*d5c09012SAndroid Build Coastguard Worker// Copyright 2023 Google LLC 2*d5c09012SAndroid Build Coastguard Worker// 3*d5c09012SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*d5c09012SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*d5c09012SAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*d5c09012SAndroid Build Coastguard Worker// 7*d5c09012SAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*d5c09012SAndroid Build Coastguard Worker// 9*d5c09012SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*d5c09012SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*d5c09012SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*d5c09012SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*d5c09012SAndroid Build Coastguard Worker// limitations under the License. 14*d5c09012SAndroid Build Coastguard Worker 15*d5c09012SAndroid Build Coastguard Workersyntax = "proto3"; 16*d5c09012SAndroid Build Coastguard Worker 17*d5c09012SAndroid Build Coastguard Workerpackage google.firestore.v1; 18*d5c09012SAndroid Build Coastguard Worker 19*d5c09012SAndroid Build Coastguard Workerimport "google/firestore/v1/bloom_filter.proto"; 20*d5c09012SAndroid Build Coastguard Workerimport "google/firestore/v1/common.proto"; 21*d5c09012SAndroid Build Coastguard Workerimport "google/firestore/v1/document.proto"; 22*d5c09012SAndroid Build Coastguard Workerimport "google/protobuf/timestamp.proto"; 23*d5c09012SAndroid Build Coastguard Worker 24*d5c09012SAndroid Build Coastguard Workeroption csharp_namespace = "Google.Cloud.Firestore.V1"; 25*d5c09012SAndroid Build Coastguard Workeroption go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; 26*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true; 27*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "WriteProto"; 28*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.firestore.v1"; 29*d5c09012SAndroid Build Coastguard Workeroption objc_class_prefix = "GCFS"; 30*d5c09012SAndroid Build Coastguard Workeroption php_namespace = "Google\\Cloud\\Firestore\\V1"; 31*d5c09012SAndroid Build Coastguard Workeroption ruby_package = "Google::Cloud::Firestore::V1"; 32*d5c09012SAndroid Build Coastguard Worker 33*d5c09012SAndroid Build Coastguard Worker// A write on a document. 34*d5c09012SAndroid Build Coastguard Workermessage Write { 35*d5c09012SAndroid Build Coastguard Worker // The operation to execute. 36*d5c09012SAndroid Build Coastguard Worker oneof operation { 37*d5c09012SAndroid Build Coastguard Worker // A document to write. 38*d5c09012SAndroid Build Coastguard Worker Document update = 1; 39*d5c09012SAndroid Build Coastguard Worker 40*d5c09012SAndroid Build Coastguard Worker // A document name to delete. In the format: 41*d5c09012SAndroid Build Coastguard Worker // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. 42*d5c09012SAndroid Build Coastguard Worker string delete = 2; 43*d5c09012SAndroid Build Coastguard Worker 44*d5c09012SAndroid Build Coastguard Worker // Applies a transformation to a document. 45*d5c09012SAndroid Build Coastguard Worker DocumentTransform transform = 6; 46*d5c09012SAndroid Build Coastguard Worker } 47*d5c09012SAndroid Build Coastguard Worker 48*d5c09012SAndroid Build Coastguard Worker // The fields to update in this write. 49*d5c09012SAndroid Build Coastguard Worker // 50*d5c09012SAndroid Build Coastguard Worker // This field can be set only when the operation is `update`. 51*d5c09012SAndroid Build Coastguard Worker // If the mask is not set for an `update` and the document exists, any 52*d5c09012SAndroid Build Coastguard Worker // existing data will be overwritten. 53*d5c09012SAndroid Build Coastguard Worker // If the mask is set and the document on the server has fields not covered by 54*d5c09012SAndroid Build Coastguard Worker // the mask, they are left unchanged. 55*d5c09012SAndroid Build Coastguard Worker // Fields referenced in the mask, but not present in the input document, are 56*d5c09012SAndroid Build Coastguard Worker // deleted from the document on the server. 57*d5c09012SAndroid Build Coastguard Worker // The field paths in this mask must not contain a reserved field name. 58*d5c09012SAndroid Build Coastguard Worker DocumentMask update_mask = 3; 59*d5c09012SAndroid Build Coastguard Worker 60*d5c09012SAndroid Build Coastguard Worker // The transforms to perform after update. 61*d5c09012SAndroid Build Coastguard Worker // 62*d5c09012SAndroid Build Coastguard Worker // This field can be set only when the operation is `update`. If present, this 63*d5c09012SAndroid Build Coastguard Worker // write is equivalent to performing `update` and `transform` to the same 64*d5c09012SAndroid Build Coastguard Worker // document atomically and in order. 65*d5c09012SAndroid Build Coastguard Worker repeated DocumentTransform.FieldTransform update_transforms = 7; 66*d5c09012SAndroid Build Coastguard Worker 67*d5c09012SAndroid Build Coastguard Worker // An optional precondition on the document. 68*d5c09012SAndroid Build Coastguard Worker // 69*d5c09012SAndroid Build Coastguard Worker // The write will fail if this is set and not met by the target document. 70*d5c09012SAndroid Build Coastguard Worker Precondition current_document = 4; 71*d5c09012SAndroid Build Coastguard Worker} 72*d5c09012SAndroid Build Coastguard Worker 73*d5c09012SAndroid Build Coastguard Worker// A transformation of a document. 74*d5c09012SAndroid Build Coastguard Workermessage DocumentTransform { 75*d5c09012SAndroid Build Coastguard Worker // A transformation of a field of the document. 76*d5c09012SAndroid Build Coastguard Worker message FieldTransform { 77*d5c09012SAndroid Build Coastguard Worker // A value that is calculated by the server. 78*d5c09012SAndroid Build Coastguard Worker enum ServerValue { 79*d5c09012SAndroid Build Coastguard Worker // Unspecified. This value must not be used. 80*d5c09012SAndroid Build Coastguard Worker SERVER_VALUE_UNSPECIFIED = 0; 81*d5c09012SAndroid Build Coastguard Worker 82*d5c09012SAndroid Build Coastguard Worker // The time at which the server processed the request, with millisecond 83*d5c09012SAndroid Build Coastguard Worker // precision. If used on multiple fields (same or different documents) in 84*d5c09012SAndroid Build Coastguard Worker // a transaction, all the fields will get the same server timestamp. 85*d5c09012SAndroid Build Coastguard Worker REQUEST_TIME = 1; 86*d5c09012SAndroid Build Coastguard Worker } 87*d5c09012SAndroid Build Coastguard Worker 88*d5c09012SAndroid Build Coastguard Worker // The path of the field. See 89*d5c09012SAndroid Build Coastguard Worker // [Document.fields][google.firestore.v1.Document.fields] for the field path 90*d5c09012SAndroid Build Coastguard Worker // syntax reference. 91*d5c09012SAndroid Build Coastguard Worker string field_path = 1; 92*d5c09012SAndroid Build Coastguard Worker 93*d5c09012SAndroid Build Coastguard Worker // The transformation to apply on the field. 94*d5c09012SAndroid Build Coastguard Worker oneof transform_type { 95*d5c09012SAndroid Build Coastguard Worker // Sets the field to the given server value. 96*d5c09012SAndroid Build Coastguard Worker ServerValue set_to_server_value = 2; 97*d5c09012SAndroid Build Coastguard Worker 98*d5c09012SAndroid Build Coastguard Worker // Adds the given value to the field's current value. 99*d5c09012SAndroid Build Coastguard Worker // 100*d5c09012SAndroid Build Coastguard Worker // This must be an integer or a double value. 101*d5c09012SAndroid Build Coastguard Worker // If the field is not an integer or double, or if the field does not yet 102*d5c09012SAndroid Build Coastguard Worker // exist, the transformation will set the field to the given value. 103*d5c09012SAndroid Build Coastguard Worker // If either of the given value or the current field value are doubles, 104*d5c09012SAndroid Build Coastguard Worker // both values will be interpreted as doubles. Double arithmetic and 105*d5c09012SAndroid Build Coastguard Worker // representation of double values follow IEEE 754 semantics. 106*d5c09012SAndroid Build Coastguard Worker // If there is positive/negative integer overflow, the field is resolved 107*d5c09012SAndroid Build Coastguard Worker // to the largest magnitude positive/negative integer. 108*d5c09012SAndroid Build Coastguard Worker Value increment = 3; 109*d5c09012SAndroid Build Coastguard Worker 110*d5c09012SAndroid Build Coastguard Worker // Sets the field to the maximum of its current value and the given value. 111*d5c09012SAndroid Build Coastguard Worker // 112*d5c09012SAndroid Build Coastguard Worker // This must be an integer or a double value. 113*d5c09012SAndroid Build Coastguard Worker // If the field is not an integer or double, or if the field does not yet 114*d5c09012SAndroid Build Coastguard Worker // exist, the transformation will set the field to the given value. 115*d5c09012SAndroid Build Coastguard Worker // If a maximum operation is applied where the field and the input value 116*d5c09012SAndroid Build Coastguard Worker // are of mixed types (that is - one is an integer and one is a double) 117*d5c09012SAndroid Build Coastguard Worker // the field takes on the type of the larger operand. If the operands are 118*d5c09012SAndroid Build Coastguard Worker // equivalent (e.g. 3 and 3.0), the field does not change. 119*d5c09012SAndroid Build Coastguard Worker // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and 120*d5c09012SAndroid Build Coastguard Worker // zero input value is always the stored value. 121*d5c09012SAndroid Build Coastguard Worker // The maximum of any numeric value x and NaN is NaN. 122*d5c09012SAndroid Build Coastguard Worker Value maximum = 4; 123*d5c09012SAndroid Build Coastguard Worker 124*d5c09012SAndroid Build Coastguard Worker // Sets the field to the minimum of its current value and the given value. 125*d5c09012SAndroid Build Coastguard Worker // 126*d5c09012SAndroid Build Coastguard Worker // This must be an integer or a double value. 127*d5c09012SAndroid Build Coastguard Worker // If the field is not an integer or double, or if the field does not yet 128*d5c09012SAndroid Build Coastguard Worker // exist, the transformation will set the field to the input value. 129*d5c09012SAndroid Build Coastguard Worker // If a minimum operation is applied where the field and the input value 130*d5c09012SAndroid Build Coastguard Worker // are of mixed types (that is - one is an integer and one is a double) 131*d5c09012SAndroid Build Coastguard Worker // the field takes on the type of the smaller operand. If the operands are 132*d5c09012SAndroid Build Coastguard Worker // equivalent (e.g. 3 and 3.0), the field does not change. 133*d5c09012SAndroid Build Coastguard Worker // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and 134*d5c09012SAndroid Build Coastguard Worker // zero input value is always the stored value. 135*d5c09012SAndroid Build Coastguard Worker // The minimum of any numeric value x and NaN is NaN. 136*d5c09012SAndroid Build Coastguard Worker Value minimum = 5; 137*d5c09012SAndroid Build Coastguard Worker 138*d5c09012SAndroid Build Coastguard Worker // Append the given elements in order if they are not already present in 139*d5c09012SAndroid Build Coastguard Worker // the current field value. 140*d5c09012SAndroid Build Coastguard Worker // If the field is not an array, or if the field does not yet exist, it is 141*d5c09012SAndroid Build Coastguard Worker // first set to the empty array. 142*d5c09012SAndroid Build Coastguard Worker // 143*d5c09012SAndroid Build Coastguard Worker // Equivalent numbers of different types (e.g. 3L and 3.0) are 144*d5c09012SAndroid Build Coastguard Worker // considered equal when checking if a value is missing. 145*d5c09012SAndroid Build Coastguard Worker // NaN is equal to NaN, and Null is equal to Null. 146*d5c09012SAndroid Build Coastguard Worker // If the input contains multiple equivalent values, only the first will 147*d5c09012SAndroid Build Coastguard Worker // be considered. 148*d5c09012SAndroid Build Coastguard Worker // 149*d5c09012SAndroid Build Coastguard Worker // The corresponding transform_result will be the null value. 150*d5c09012SAndroid Build Coastguard Worker ArrayValue append_missing_elements = 6; 151*d5c09012SAndroid Build Coastguard Worker 152*d5c09012SAndroid Build Coastguard Worker // Remove all of the given elements from the array in the field. 153*d5c09012SAndroid Build Coastguard Worker // If the field is not an array, or if the field does not yet exist, it is 154*d5c09012SAndroid Build Coastguard Worker // set to the empty array. 155*d5c09012SAndroid Build Coastguard Worker // 156*d5c09012SAndroid Build Coastguard Worker // Equivalent numbers of the different types (e.g. 3L and 3.0) are 157*d5c09012SAndroid Build Coastguard Worker // considered equal when deciding whether an element should be removed. 158*d5c09012SAndroid Build Coastguard Worker // NaN is equal to NaN, and Null is equal to Null. 159*d5c09012SAndroid Build Coastguard Worker // This will remove all equivalent values if there are duplicates. 160*d5c09012SAndroid Build Coastguard Worker // 161*d5c09012SAndroid Build Coastguard Worker // The corresponding transform_result will be the null value. 162*d5c09012SAndroid Build Coastguard Worker ArrayValue remove_all_from_array = 7; 163*d5c09012SAndroid Build Coastguard Worker } 164*d5c09012SAndroid Build Coastguard Worker } 165*d5c09012SAndroid Build Coastguard Worker 166*d5c09012SAndroid Build Coastguard Worker // The name of the document to transform. 167*d5c09012SAndroid Build Coastguard Worker string document = 1; 168*d5c09012SAndroid Build Coastguard Worker 169*d5c09012SAndroid Build Coastguard Worker // The list of transformations to apply to the fields of the document, in 170*d5c09012SAndroid Build Coastguard Worker // order. 171*d5c09012SAndroid Build Coastguard Worker // This must not be empty. 172*d5c09012SAndroid Build Coastguard Worker repeated FieldTransform field_transforms = 2; 173*d5c09012SAndroid Build Coastguard Worker} 174*d5c09012SAndroid Build Coastguard Worker 175*d5c09012SAndroid Build Coastguard Worker// The result of applying a write. 176*d5c09012SAndroid Build Coastguard Workermessage WriteResult { 177*d5c09012SAndroid Build Coastguard Worker // The last update time of the document after applying the write. Not set 178*d5c09012SAndroid Build Coastguard Worker // after a `delete`. 179*d5c09012SAndroid Build Coastguard Worker // 180*d5c09012SAndroid Build Coastguard Worker // If the write did not actually change the document, this will be the 181*d5c09012SAndroid Build Coastguard Worker // previous update_time. 182*d5c09012SAndroid Build Coastguard Worker google.protobuf.Timestamp update_time = 1; 183*d5c09012SAndroid Build Coastguard Worker 184*d5c09012SAndroid Build Coastguard Worker // The results of applying each 185*d5c09012SAndroid Build Coastguard Worker // [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform], 186*d5c09012SAndroid Build Coastguard Worker // in the same order. 187*d5c09012SAndroid Build Coastguard Worker repeated Value transform_results = 2; 188*d5c09012SAndroid Build Coastguard Worker} 189*d5c09012SAndroid Build Coastguard Worker 190*d5c09012SAndroid Build Coastguard Worker// A [Document][google.firestore.v1.Document] has changed. 191*d5c09012SAndroid Build Coastguard Worker// 192*d5c09012SAndroid Build Coastguard Worker// May be the result of multiple [writes][google.firestore.v1.Write], including 193*d5c09012SAndroid Build Coastguard Worker// deletes, that ultimately resulted in a new value for the 194*d5c09012SAndroid Build Coastguard Worker// [Document][google.firestore.v1.Document]. 195*d5c09012SAndroid Build Coastguard Worker// 196*d5c09012SAndroid Build Coastguard Worker// Multiple [DocumentChange][google.firestore.v1.DocumentChange] messages may be 197*d5c09012SAndroid Build Coastguard Worker// returned for the same logical change, if multiple targets are affected. 198*d5c09012SAndroid Build Coastguard Workermessage DocumentChange { 199*d5c09012SAndroid Build Coastguard Worker // The new state of the [Document][google.firestore.v1.Document]. 200*d5c09012SAndroid Build Coastguard Worker // 201*d5c09012SAndroid Build Coastguard Worker // If `mask` is set, contains only fields that were updated or added. 202*d5c09012SAndroid Build Coastguard Worker Document document = 1; 203*d5c09012SAndroid Build Coastguard Worker 204*d5c09012SAndroid Build Coastguard Worker // A set of target IDs of targets that match this document. 205*d5c09012SAndroid Build Coastguard Worker repeated int32 target_ids = 5; 206*d5c09012SAndroid Build Coastguard Worker 207*d5c09012SAndroid Build Coastguard Worker // A set of target IDs for targets that no longer match this document. 208*d5c09012SAndroid Build Coastguard Worker repeated int32 removed_target_ids = 6; 209*d5c09012SAndroid Build Coastguard Worker} 210*d5c09012SAndroid Build Coastguard Worker 211*d5c09012SAndroid Build Coastguard Worker// A [Document][google.firestore.v1.Document] has been deleted. 212*d5c09012SAndroid Build Coastguard Worker// 213*d5c09012SAndroid Build Coastguard Worker// May be the result of multiple [writes][google.firestore.v1.Write], including 214*d5c09012SAndroid Build Coastguard Worker// updates, the last of which deleted the 215*d5c09012SAndroid Build Coastguard Worker// [Document][google.firestore.v1.Document]. 216*d5c09012SAndroid Build Coastguard Worker// 217*d5c09012SAndroid Build Coastguard Worker// Multiple [DocumentDelete][google.firestore.v1.DocumentDelete] messages may be 218*d5c09012SAndroid Build Coastguard Worker// returned for the same logical delete, if multiple targets are affected. 219*d5c09012SAndroid Build Coastguard Workermessage DocumentDelete { 220*d5c09012SAndroid Build Coastguard Worker // The resource name of the [Document][google.firestore.v1.Document] that was 221*d5c09012SAndroid Build Coastguard Worker // deleted. 222*d5c09012SAndroid Build Coastguard Worker string document = 1; 223*d5c09012SAndroid Build Coastguard Worker 224*d5c09012SAndroid Build Coastguard Worker // A set of target IDs for targets that previously matched this entity. 225*d5c09012SAndroid Build Coastguard Worker repeated int32 removed_target_ids = 6; 226*d5c09012SAndroid Build Coastguard Worker 227*d5c09012SAndroid Build Coastguard Worker // The read timestamp at which the delete was observed. 228*d5c09012SAndroid Build Coastguard Worker // 229*d5c09012SAndroid Build Coastguard Worker // Greater or equal to the `commit_time` of the delete. 230*d5c09012SAndroid Build Coastguard Worker google.protobuf.Timestamp read_time = 4; 231*d5c09012SAndroid Build Coastguard Worker} 232*d5c09012SAndroid Build Coastguard Worker 233*d5c09012SAndroid Build Coastguard Worker// A [Document][google.firestore.v1.Document] has been removed from the view of 234*d5c09012SAndroid Build Coastguard Worker// the targets. 235*d5c09012SAndroid Build Coastguard Worker// 236*d5c09012SAndroid Build Coastguard Worker// Sent if the document is no longer relevant to a target and is out of view. 237*d5c09012SAndroid Build Coastguard Worker// Can be sent instead of a DocumentDelete or a DocumentChange if the server 238*d5c09012SAndroid Build Coastguard Worker// can not send the new value of the document. 239*d5c09012SAndroid Build Coastguard Worker// 240*d5c09012SAndroid Build Coastguard Worker// Multiple [DocumentRemove][google.firestore.v1.DocumentRemove] messages may be 241*d5c09012SAndroid Build Coastguard Worker// returned for the same logical write or delete, if multiple targets are 242*d5c09012SAndroid Build Coastguard Worker// affected. 243*d5c09012SAndroid Build Coastguard Workermessage DocumentRemove { 244*d5c09012SAndroid Build Coastguard Worker // The resource name of the [Document][google.firestore.v1.Document] that has 245*d5c09012SAndroid Build Coastguard Worker // gone out of view. 246*d5c09012SAndroid Build Coastguard Worker string document = 1; 247*d5c09012SAndroid Build Coastguard Worker 248*d5c09012SAndroid Build Coastguard Worker // A set of target IDs for targets that previously matched this document. 249*d5c09012SAndroid Build Coastguard Worker repeated int32 removed_target_ids = 2; 250*d5c09012SAndroid Build Coastguard Worker 251*d5c09012SAndroid Build Coastguard Worker // The read timestamp at which the remove was observed. 252*d5c09012SAndroid Build Coastguard Worker // 253*d5c09012SAndroid Build Coastguard Worker // Greater or equal to the `commit_time` of the change/delete/remove. 254*d5c09012SAndroid Build Coastguard Worker google.protobuf.Timestamp read_time = 4; 255*d5c09012SAndroid Build Coastguard Worker} 256*d5c09012SAndroid Build Coastguard Worker 257*d5c09012SAndroid Build Coastguard Worker// A digest of all the documents that match a given target. 258*d5c09012SAndroid Build Coastguard Workermessage ExistenceFilter { 259*d5c09012SAndroid Build Coastguard Worker // The target ID to which this filter applies. 260*d5c09012SAndroid Build Coastguard Worker int32 target_id = 1; 261*d5c09012SAndroid Build Coastguard Worker 262*d5c09012SAndroid Build Coastguard Worker // The total count of documents that match 263*d5c09012SAndroid Build Coastguard Worker // [target_id][google.firestore.v1.ExistenceFilter.target_id]. 264*d5c09012SAndroid Build Coastguard Worker // 265*d5c09012SAndroid Build Coastguard Worker // If different from the count of documents in the client that match, the 266*d5c09012SAndroid Build Coastguard Worker // client must manually determine which documents no longer match the target. 267*d5c09012SAndroid Build Coastguard Worker // 268*d5c09012SAndroid Build Coastguard Worker // The client can use the `unchanged_names` bloom filter to assist with 269*d5c09012SAndroid Build Coastguard Worker // this determination by testing ALL the document names against the filter; 270*d5c09012SAndroid Build Coastguard Worker // if the document name is NOT in the filter, it means the document no 271*d5c09012SAndroid Build Coastguard Worker // longer matches the target. 272*d5c09012SAndroid Build Coastguard Worker int32 count = 2; 273*d5c09012SAndroid Build Coastguard Worker 274*d5c09012SAndroid Build Coastguard Worker // A bloom filter that, despite its name, contains the UTF-8 byte encodings of 275*d5c09012SAndroid Build Coastguard Worker // the resource names of ALL the documents that match 276*d5c09012SAndroid Build Coastguard Worker // [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form 277*d5c09012SAndroid Build Coastguard Worker // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. 278*d5c09012SAndroid Build Coastguard Worker // 279*d5c09012SAndroid Build Coastguard Worker // This bloom filter may be omitted at the server's discretion, such as if it 280*d5c09012SAndroid Build Coastguard Worker // is deemed that the client will not make use of it or if it is too 281*d5c09012SAndroid Build Coastguard Worker // computationally expensive to calculate or transmit. Clients must gracefully 282*d5c09012SAndroid Build Coastguard Worker // handle this field being absent by falling back to the logic used before 283*d5c09012SAndroid Build Coastguard Worker // this field existed; that is, re-add the target without a resume token to 284*d5c09012SAndroid Build Coastguard Worker // figure out which documents in the client's cache are out of sync. 285*d5c09012SAndroid Build Coastguard Worker BloomFilter unchanged_names = 3; 286*d5c09012SAndroid Build Coastguard Worker} 287