1*d5c09012SAndroid Build Coastguard Worker// Copyright 2021 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.v1beta1; 18*d5c09012SAndroid Build Coastguard Worker 19*d5c09012SAndroid Build Coastguard Workerimport "google/firestore/v1beta1/common.proto"; 20*d5c09012SAndroid Build Coastguard Workerimport "google/firestore/v1beta1/document.proto"; 21*d5c09012SAndroid Build Coastguard Workerimport "google/protobuf/timestamp.proto"; 22*d5c09012SAndroid Build Coastguard Worker 23*d5c09012SAndroid Build Coastguard Workeroption csharp_namespace = "Google.Cloud.Firestore.V1Beta1"; 24*d5c09012SAndroid Build Coastguard Workeroption go_package = "cloud.google.com/go/firestore/apiv1beta1/firestorepb;firestorepb"; 25*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true; 26*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "WriteProto"; 27*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.firestore.v1beta1"; 28*d5c09012SAndroid Build Coastguard Workeroption objc_class_prefix = "GCFS"; 29*d5c09012SAndroid Build Coastguard Workeroption php_namespace = "Google\\Cloud\\Firestore\\V1beta1"; 30*d5c09012SAndroid Build Coastguard Workeroption ruby_package = "Google::Cloud::Firestore::V1beta1"; 31*d5c09012SAndroid Build Coastguard Worker 32*d5c09012SAndroid Build Coastguard Worker// A write on a document. 33*d5c09012SAndroid Build Coastguard Workermessage Write { 34*d5c09012SAndroid Build Coastguard Worker // The operation to execute. 35*d5c09012SAndroid Build Coastguard Worker oneof operation { 36*d5c09012SAndroid Build Coastguard Worker // A document to write. 37*d5c09012SAndroid Build Coastguard Worker Document update = 1; 38*d5c09012SAndroid Build Coastguard Worker 39*d5c09012SAndroid Build Coastguard Worker // A document name to delete. In the format: 40*d5c09012SAndroid Build Coastguard Worker // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. 41*d5c09012SAndroid Build Coastguard Worker string delete = 2; 42*d5c09012SAndroid Build Coastguard Worker 43*d5c09012SAndroid Build Coastguard Worker // Applies a transformation to a document. 44*d5c09012SAndroid Build Coastguard Worker DocumentTransform transform = 6; 45*d5c09012SAndroid Build Coastguard Worker } 46*d5c09012SAndroid Build Coastguard Worker 47*d5c09012SAndroid Build Coastguard Worker // The fields to update in this write. 48*d5c09012SAndroid Build Coastguard Worker // 49*d5c09012SAndroid Build Coastguard Worker // This field can be set only when the operation is `update`. 50*d5c09012SAndroid Build Coastguard Worker // If the mask is not set for an `update` and the document exists, any 51*d5c09012SAndroid Build Coastguard Worker // existing data will be overwritten. 52*d5c09012SAndroid Build Coastguard Worker // If the mask is set and the document on the server has fields not covered by 53*d5c09012SAndroid Build Coastguard Worker // the mask, they are left unchanged. 54*d5c09012SAndroid Build Coastguard Worker // Fields referenced in the mask, but not present in the input document, are 55*d5c09012SAndroid Build Coastguard Worker // deleted from the document on the server. 56*d5c09012SAndroid Build Coastguard Worker // The field paths in this mask must not contain a reserved field name. 57*d5c09012SAndroid Build Coastguard Worker DocumentMask update_mask = 3; 58*d5c09012SAndroid Build Coastguard Worker 59*d5c09012SAndroid Build Coastguard Worker // The transforms to perform after update. 60*d5c09012SAndroid Build Coastguard Worker // 61*d5c09012SAndroid Build Coastguard Worker // This field can be set only when the operation is `update`. If present, this 62*d5c09012SAndroid Build Coastguard Worker // write is equivalent to performing `update` and `transform` to the same 63*d5c09012SAndroid Build Coastguard Worker // document atomically and in order. 64*d5c09012SAndroid Build Coastguard Worker repeated DocumentTransform.FieldTransform update_transforms = 7; 65*d5c09012SAndroid Build Coastguard Worker 66*d5c09012SAndroid Build Coastguard Worker // An optional precondition on the document. 67*d5c09012SAndroid Build Coastguard Worker // 68*d5c09012SAndroid Build Coastguard Worker // The write will fail if this is set and not met by the target document. 69*d5c09012SAndroid Build Coastguard Worker Precondition current_document = 4; 70*d5c09012SAndroid Build Coastguard Worker} 71*d5c09012SAndroid Build Coastguard Worker 72*d5c09012SAndroid Build Coastguard Worker// A transformation of a document. 73*d5c09012SAndroid Build Coastguard Workermessage DocumentTransform { 74*d5c09012SAndroid Build Coastguard Worker // A transformation of a field of the document. 75*d5c09012SAndroid Build Coastguard Worker message FieldTransform { 76*d5c09012SAndroid Build Coastguard Worker // A value that is calculated by the server. 77*d5c09012SAndroid Build Coastguard Worker enum ServerValue { 78*d5c09012SAndroid Build Coastguard Worker // Unspecified. This value must not be used. 79*d5c09012SAndroid Build Coastguard Worker SERVER_VALUE_UNSPECIFIED = 0; 80*d5c09012SAndroid Build Coastguard Worker 81*d5c09012SAndroid Build Coastguard Worker // The time at which the server processed the request, with millisecond 82*d5c09012SAndroid Build Coastguard Worker // precision. If used on multiple fields (same or different documents) in 83*d5c09012SAndroid Build Coastguard Worker // a transaction, all the fields will get the same server timestamp. 84*d5c09012SAndroid Build Coastguard Worker REQUEST_TIME = 1; 85*d5c09012SAndroid Build Coastguard Worker } 86*d5c09012SAndroid Build Coastguard Worker 87*d5c09012SAndroid Build Coastguard Worker // The path of the field. See [Document.fields][google.firestore.v1beta1.Document.fields] for the field path syntax 88*d5c09012SAndroid Build Coastguard Worker // reference. 89*d5c09012SAndroid Build Coastguard Worker string field_path = 1; 90*d5c09012SAndroid Build Coastguard Worker 91*d5c09012SAndroid Build Coastguard Worker // The transformation to apply on the field. 92*d5c09012SAndroid Build Coastguard Worker oneof transform_type { 93*d5c09012SAndroid Build Coastguard Worker // Sets the field to the given server value. 94*d5c09012SAndroid Build Coastguard Worker ServerValue set_to_server_value = 2; 95*d5c09012SAndroid Build Coastguard Worker 96*d5c09012SAndroid Build Coastguard Worker // Adds the given value to the field's current value. 97*d5c09012SAndroid Build Coastguard Worker // 98*d5c09012SAndroid Build Coastguard Worker // This must be an integer or a double value. 99*d5c09012SAndroid Build Coastguard Worker // If the field is not an integer or double, or if the field does not yet 100*d5c09012SAndroid Build Coastguard Worker // exist, the transformation will set the field to the given value. 101*d5c09012SAndroid Build Coastguard Worker // If either of the given value or the current field value are doubles, 102*d5c09012SAndroid Build Coastguard Worker // both values will be interpreted as doubles. Double arithmetic and 103*d5c09012SAndroid Build Coastguard Worker // representation of double values follow IEEE 754 semantics. 104*d5c09012SAndroid Build Coastguard Worker // If there is positive/negative integer overflow, the field is resolved 105*d5c09012SAndroid Build Coastguard Worker // to the largest magnitude positive/negative integer. 106*d5c09012SAndroid Build Coastguard Worker Value increment = 3; 107*d5c09012SAndroid Build Coastguard Worker 108*d5c09012SAndroid Build Coastguard Worker // Sets the field to the maximum of its current value and the given value. 109*d5c09012SAndroid Build Coastguard Worker // 110*d5c09012SAndroid Build Coastguard Worker // This must be an integer or a double value. 111*d5c09012SAndroid Build Coastguard Worker // If the field is not an integer or double, or if the field does not yet 112*d5c09012SAndroid Build Coastguard Worker // exist, the transformation will set the field to the given value. 113*d5c09012SAndroid Build Coastguard Worker // If a maximum operation is applied where the field and the input value 114*d5c09012SAndroid Build Coastguard Worker // are of mixed types (that is - one is an integer and one is a double) 115*d5c09012SAndroid Build Coastguard Worker // the field takes on the type of the larger operand. If the operands are 116*d5c09012SAndroid Build Coastguard Worker // equivalent (e.g. 3 and 3.0), the field does not change. 117*d5c09012SAndroid Build Coastguard Worker // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and 118*d5c09012SAndroid Build Coastguard Worker // zero input value is always the stored value. 119*d5c09012SAndroid Build Coastguard Worker // The maximum of any numeric value x and NaN is NaN. 120*d5c09012SAndroid Build Coastguard Worker Value maximum = 4; 121*d5c09012SAndroid Build Coastguard Worker 122*d5c09012SAndroid Build Coastguard Worker // Sets the field to the minimum of its current value and the given value. 123*d5c09012SAndroid Build Coastguard Worker // 124*d5c09012SAndroid Build Coastguard Worker // This must be an integer or a double value. 125*d5c09012SAndroid Build Coastguard Worker // If the field is not an integer or double, or if the field does not yet 126*d5c09012SAndroid Build Coastguard Worker // exist, the transformation will set the field to the input value. 127*d5c09012SAndroid Build Coastguard Worker // If a minimum operation is applied where the field and the input value 128*d5c09012SAndroid Build Coastguard Worker // are of mixed types (that is - one is an integer and one is a double) 129*d5c09012SAndroid Build Coastguard Worker // the field takes on the type of the smaller operand. If the operands are 130*d5c09012SAndroid Build Coastguard Worker // equivalent (e.g. 3 and 3.0), the field does not change. 131*d5c09012SAndroid Build Coastguard Worker // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and 132*d5c09012SAndroid Build Coastguard Worker // zero input value is always the stored value. 133*d5c09012SAndroid Build Coastguard Worker // The minimum of any numeric value x and NaN is NaN. 134*d5c09012SAndroid Build Coastguard Worker Value minimum = 5; 135*d5c09012SAndroid Build Coastguard Worker 136*d5c09012SAndroid Build Coastguard Worker // Append the given elements in order if they are not already present in 137*d5c09012SAndroid Build Coastguard Worker // the current field value. 138*d5c09012SAndroid Build Coastguard Worker // If the field is not an array, or if the field does not yet exist, it is 139*d5c09012SAndroid Build Coastguard Worker // first set to the empty array. 140*d5c09012SAndroid Build Coastguard Worker // 141*d5c09012SAndroid Build Coastguard Worker // Equivalent numbers of different types (e.g. 3L and 3.0) are 142*d5c09012SAndroid Build Coastguard Worker // considered equal when checking if a value is missing. 143*d5c09012SAndroid Build Coastguard Worker // NaN is equal to NaN, and Null is equal to Null. 144*d5c09012SAndroid Build Coastguard Worker // If the input contains multiple equivalent values, only the first will 145*d5c09012SAndroid Build Coastguard Worker // be considered. 146*d5c09012SAndroid Build Coastguard Worker // 147*d5c09012SAndroid Build Coastguard Worker // The corresponding transform_result will be the null value. 148*d5c09012SAndroid Build Coastguard Worker ArrayValue append_missing_elements = 6; 149*d5c09012SAndroid Build Coastguard Worker 150*d5c09012SAndroid Build Coastguard Worker // Remove all of the given elements from the array in the field. 151*d5c09012SAndroid Build Coastguard Worker // If the field is not an array, or if the field does not yet exist, it is 152*d5c09012SAndroid Build Coastguard Worker // set to the empty array. 153*d5c09012SAndroid Build Coastguard Worker // 154*d5c09012SAndroid Build Coastguard Worker // Equivalent numbers of the different types (e.g. 3L and 3.0) are 155*d5c09012SAndroid Build Coastguard Worker // considered equal when deciding whether an element should be removed. 156*d5c09012SAndroid Build Coastguard Worker // NaN is equal to NaN, and Null is equal to Null. 157*d5c09012SAndroid Build Coastguard Worker // This will remove all equivalent values if there are duplicates. 158*d5c09012SAndroid Build Coastguard Worker // 159*d5c09012SAndroid Build Coastguard Worker // The corresponding transform_result will be the null value. 160*d5c09012SAndroid Build Coastguard Worker ArrayValue remove_all_from_array = 7; 161*d5c09012SAndroid Build Coastguard Worker } 162*d5c09012SAndroid Build Coastguard Worker } 163*d5c09012SAndroid Build Coastguard Worker 164*d5c09012SAndroid Build Coastguard Worker // The name of the document to transform. 165*d5c09012SAndroid Build Coastguard Worker string document = 1; 166*d5c09012SAndroid Build Coastguard Worker 167*d5c09012SAndroid Build Coastguard Worker // The list of transformations to apply to the fields of the document, in 168*d5c09012SAndroid Build Coastguard Worker // order. 169*d5c09012SAndroid Build Coastguard Worker // This must not be empty. 170*d5c09012SAndroid Build Coastguard Worker repeated FieldTransform field_transforms = 2; 171*d5c09012SAndroid Build Coastguard Worker} 172*d5c09012SAndroid Build Coastguard Worker 173*d5c09012SAndroid Build Coastguard Worker// The result of applying a write. 174*d5c09012SAndroid Build Coastguard Workermessage WriteResult { 175*d5c09012SAndroid Build Coastguard Worker // The last update time of the document after applying the write. Not set 176*d5c09012SAndroid Build Coastguard Worker // after a `delete`. 177*d5c09012SAndroid Build Coastguard Worker // 178*d5c09012SAndroid Build Coastguard Worker // If the write did not actually change the document, this will be the 179*d5c09012SAndroid Build Coastguard Worker // previous update_time. 180*d5c09012SAndroid Build Coastguard Worker google.protobuf.Timestamp update_time = 1; 181*d5c09012SAndroid Build Coastguard Worker 182*d5c09012SAndroid Build Coastguard Worker // The results of applying each [DocumentTransform.FieldTransform][google.firestore.v1beta1.DocumentTransform.FieldTransform], in the 183*d5c09012SAndroid Build Coastguard Worker // same order. 184*d5c09012SAndroid Build Coastguard Worker repeated Value transform_results = 2; 185*d5c09012SAndroid Build Coastguard Worker} 186*d5c09012SAndroid Build Coastguard Worker 187*d5c09012SAndroid Build Coastguard Worker// A [Document][google.firestore.v1beta1.Document] has changed. 188*d5c09012SAndroid Build Coastguard Worker// 189*d5c09012SAndroid Build Coastguard Worker// May be the result of multiple [writes][google.firestore.v1beta1.Write], including deletes, that 190*d5c09012SAndroid Build Coastguard Worker// ultimately resulted in a new value for the [Document][google.firestore.v1beta1.Document]. 191*d5c09012SAndroid Build Coastguard Worker// 192*d5c09012SAndroid Build Coastguard Worker// Multiple [DocumentChange][google.firestore.v1beta1.DocumentChange] messages may be returned for the same logical 193*d5c09012SAndroid Build Coastguard Worker// change, if multiple targets are affected. 194*d5c09012SAndroid Build Coastguard Workermessage DocumentChange { 195*d5c09012SAndroid Build Coastguard Worker // The new state of the [Document][google.firestore.v1beta1.Document]. 196*d5c09012SAndroid Build Coastguard Worker // 197*d5c09012SAndroid Build Coastguard Worker // If `mask` is set, contains only fields that were updated or added. 198*d5c09012SAndroid Build Coastguard Worker Document document = 1; 199*d5c09012SAndroid Build Coastguard Worker 200*d5c09012SAndroid Build Coastguard Worker // A set of target IDs of targets that match this document. 201*d5c09012SAndroid Build Coastguard Worker repeated int32 target_ids = 5; 202*d5c09012SAndroid Build Coastguard Worker 203*d5c09012SAndroid Build Coastguard Worker // A set of target IDs for targets that no longer match this document. 204*d5c09012SAndroid Build Coastguard Worker repeated int32 removed_target_ids = 6; 205*d5c09012SAndroid Build Coastguard Worker} 206*d5c09012SAndroid Build Coastguard Worker 207*d5c09012SAndroid Build Coastguard Worker// A [Document][google.firestore.v1beta1.Document] has been deleted. 208*d5c09012SAndroid Build Coastguard Worker// 209*d5c09012SAndroid Build Coastguard Worker// May be the result of multiple [writes][google.firestore.v1beta1.Write], including updates, the 210*d5c09012SAndroid Build Coastguard Worker// last of which deleted the [Document][google.firestore.v1beta1.Document]. 211*d5c09012SAndroid Build Coastguard Worker// 212*d5c09012SAndroid Build Coastguard Worker// Multiple [DocumentDelete][google.firestore.v1beta1.DocumentDelete] messages may be returned for the same logical 213*d5c09012SAndroid Build Coastguard Worker// delete, if multiple targets are affected. 214*d5c09012SAndroid Build Coastguard Workermessage DocumentDelete { 215*d5c09012SAndroid Build Coastguard Worker // The resource name of the [Document][google.firestore.v1beta1.Document] that was deleted. 216*d5c09012SAndroid Build Coastguard Worker string document = 1; 217*d5c09012SAndroid Build Coastguard Worker 218*d5c09012SAndroid Build Coastguard Worker // A set of target IDs for targets that previously matched this entity. 219*d5c09012SAndroid Build Coastguard Worker repeated int32 removed_target_ids = 6; 220*d5c09012SAndroid Build Coastguard Worker 221*d5c09012SAndroid Build Coastguard Worker // The read timestamp at which the delete was observed. 222*d5c09012SAndroid Build Coastguard Worker // 223*d5c09012SAndroid Build Coastguard Worker // Greater or equal to the `commit_time` of the delete. 224*d5c09012SAndroid Build Coastguard Worker google.protobuf.Timestamp read_time = 4; 225*d5c09012SAndroid Build Coastguard Worker} 226*d5c09012SAndroid Build Coastguard Worker 227*d5c09012SAndroid Build Coastguard Worker// A [Document][google.firestore.v1beta1.Document] has been removed from the view of the targets. 228*d5c09012SAndroid Build Coastguard Worker// 229*d5c09012SAndroid Build Coastguard Worker// Sent if the document is no longer relevant to a target and is out of view. 230*d5c09012SAndroid Build Coastguard Worker// Can be sent instead of a DocumentDelete or a DocumentChange if the server 231*d5c09012SAndroid Build Coastguard Worker// can not send the new value of the document. 232*d5c09012SAndroid Build Coastguard Worker// 233*d5c09012SAndroid Build Coastguard Worker// Multiple [DocumentRemove][google.firestore.v1beta1.DocumentRemove] messages may be returned for the same logical 234*d5c09012SAndroid Build Coastguard Worker// write or delete, if multiple targets are affected. 235*d5c09012SAndroid Build Coastguard Workermessage DocumentRemove { 236*d5c09012SAndroid Build Coastguard Worker // The resource name of the [Document][google.firestore.v1beta1.Document] that has gone out of view. 237*d5c09012SAndroid Build Coastguard Worker string document = 1; 238*d5c09012SAndroid Build Coastguard Worker 239*d5c09012SAndroid Build Coastguard Worker // A set of target IDs for targets that previously matched this document. 240*d5c09012SAndroid Build Coastguard Worker repeated int32 removed_target_ids = 2; 241*d5c09012SAndroid Build Coastguard Worker 242*d5c09012SAndroid Build Coastguard Worker // The read timestamp at which the remove was observed. 243*d5c09012SAndroid Build Coastguard Worker // 244*d5c09012SAndroid Build Coastguard Worker // Greater or equal to the `commit_time` of the change/delete/remove. 245*d5c09012SAndroid Build Coastguard Worker google.protobuf.Timestamp read_time = 4; 246*d5c09012SAndroid Build Coastguard Worker} 247*d5c09012SAndroid Build Coastguard Worker 248*d5c09012SAndroid Build Coastguard Worker// A digest of all the documents that match a given target. 249*d5c09012SAndroid Build Coastguard Workermessage ExistenceFilter { 250*d5c09012SAndroid Build Coastguard Worker // The target ID to which this filter applies. 251*d5c09012SAndroid Build Coastguard Worker int32 target_id = 1; 252*d5c09012SAndroid Build Coastguard Worker 253*d5c09012SAndroid Build Coastguard Worker // The total count of documents that match [target_id][google.firestore.v1beta1.ExistenceFilter.target_id]. 254*d5c09012SAndroid Build Coastguard Worker // 255*d5c09012SAndroid Build Coastguard Worker // If different from the count of documents in the client that match, the 256*d5c09012SAndroid Build Coastguard Worker // client must manually determine which documents no longer match the target. 257*d5c09012SAndroid Build Coastguard Worker int32 count = 2; 258*d5c09012SAndroid Build Coastguard Worker} 259