1*d5c09012SAndroid Build Coastguard Worker// Copyright 2022 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.spanner.v1; 18*d5c09012SAndroid Build Coastguard Worker 19*d5c09012SAndroid Build Coastguard Workerimport "google/api/field_behavior.proto"; 20*d5c09012SAndroid Build Coastguard Workerimport "google/protobuf/struct.proto"; 21*d5c09012SAndroid Build Coastguard Workerimport "google/spanner/v1/keys.proto"; 22*d5c09012SAndroid Build Coastguard Worker 23*d5c09012SAndroid Build Coastguard Workeroption csharp_namespace = "Google.Cloud.Spanner.V1"; 24*d5c09012SAndroid Build Coastguard Workeroption go_package = "cloud.google.com/go/spanner/apiv1/spannerpb;spannerpb"; 25*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true; 26*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "MutationProto"; 27*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.spanner.v1"; 28*d5c09012SAndroid Build Coastguard Workeroption php_namespace = "Google\\Cloud\\Spanner\\V1"; 29*d5c09012SAndroid Build Coastguard Workeroption ruby_package = "Google::Cloud::Spanner::V1"; 30*d5c09012SAndroid Build Coastguard Worker 31*d5c09012SAndroid Build Coastguard Worker// A modification to one or more Cloud Spanner rows. Mutations can be 32*d5c09012SAndroid Build Coastguard Worker// applied to a Cloud Spanner database by sending them in a 33*d5c09012SAndroid Build Coastguard Worker// [Commit][google.spanner.v1.Spanner.Commit] call. 34*d5c09012SAndroid Build Coastguard Workermessage Mutation { 35*d5c09012SAndroid Build Coastguard Worker // Arguments to [insert][google.spanner.v1.Mutation.insert], [update][google.spanner.v1.Mutation.update], [insert_or_update][google.spanner.v1.Mutation.insert_or_update], and 36*d5c09012SAndroid Build Coastguard Worker // [replace][google.spanner.v1.Mutation.replace] operations. 37*d5c09012SAndroid Build Coastguard Worker message Write { 38*d5c09012SAndroid Build Coastguard Worker // Required. The table whose rows will be written. 39*d5c09012SAndroid Build Coastguard Worker string table = 1 [(google.api.field_behavior) = REQUIRED]; 40*d5c09012SAndroid Build Coastguard Worker 41*d5c09012SAndroid Build Coastguard Worker // The names of the columns in [table][google.spanner.v1.Mutation.Write.table] to be written. 42*d5c09012SAndroid Build Coastguard Worker // 43*d5c09012SAndroid Build Coastguard Worker // The list of columns must contain enough columns to allow 44*d5c09012SAndroid Build Coastguard Worker // Cloud Spanner to derive values for all primary key columns in the 45*d5c09012SAndroid Build Coastguard Worker // row(s) to be modified. 46*d5c09012SAndroid Build Coastguard Worker repeated string columns = 2; 47*d5c09012SAndroid Build Coastguard Worker 48*d5c09012SAndroid Build Coastguard Worker // The values to be written. `values` can contain more than one 49*d5c09012SAndroid Build Coastguard Worker // list of values. If it does, then multiple rows are written, one 50*d5c09012SAndroid Build Coastguard Worker // for each entry in `values`. Each list in `values` must have 51*d5c09012SAndroid Build Coastguard Worker // exactly as many entries as there are entries in [columns][google.spanner.v1.Mutation.Write.columns] 52*d5c09012SAndroid Build Coastguard Worker // above. Sending multiple lists is equivalent to sending multiple 53*d5c09012SAndroid Build Coastguard Worker // `Mutation`s, each containing one `values` entry and repeating 54*d5c09012SAndroid Build Coastguard Worker // [table][google.spanner.v1.Mutation.Write.table] and [columns][google.spanner.v1.Mutation.Write.columns]. Individual values in each list are 55*d5c09012SAndroid Build Coastguard Worker // encoded as described [here][google.spanner.v1.TypeCode]. 56*d5c09012SAndroid Build Coastguard Worker repeated google.protobuf.ListValue values = 3; 57*d5c09012SAndroid Build Coastguard Worker } 58*d5c09012SAndroid Build Coastguard Worker 59*d5c09012SAndroid Build Coastguard Worker // Arguments to [delete][google.spanner.v1.Mutation.delete] operations. 60*d5c09012SAndroid Build Coastguard Worker message Delete { 61*d5c09012SAndroid Build Coastguard Worker // Required. The table whose rows will be deleted. 62*d5c09012SAndroid Build Coastguard Worker string table = 1 [(google.api.field_behavior) = REQUIRED]; 63*d5c09012SAndroid Build Coastguard Worker 64*d5c09012SAndroid Build Coastguard Worker // Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. The 65*d5c09012SAndroid Build Coastguard Worker // primary keys must be specified in the order in which they appear in the 66*d5c09012SAndroid Build Coastguard Worker // `PRIMARY KEY()` clause of the table's equivalent DDL statement (the DDL 67*d5c09012SAndroid Build Coastguard Worker // statement used to create the table). 68*d5c09012SAndroid Build Coastguard Worker // Delete is idempotent. The transaction will succeed even if some or all 69*d5c09012SAndroid Build Coastguard Worker // rows do not exist. 70*d5c09012SAndroid Build Coastguard Worker KeySet key_set = 2 [(google.api.field_behavior) = REQUIRED]; 71*d5c09012SAndroid Build Coastguard Worker } 72*d5c09012SAndroid Build Coastguard Worker 73*d5c09012SAndroid Build Coastguard Worker // Required. The operation to perform. 74*d5c09012SAndroid Build Coastguard Worker oneof operation { 75*d5c09012SAndroid Build Coastguard Worker // Insert new rows in a table. If any of the rows already exist, 76*d5c09012SAndroid Build Coastguard Worker // the write or transaction fails with error `ALREADY_EXISTS`. 77*d5c09012SAndroid Build Coastguard Worker Write insert = 1; 78*d5c09012SAndroid Build Coastguard Worker 79*d5c09012SAndroid Build Coastguard Worker // Update existing rows in a table. If any of the rows does not 80*d5c09012SAndroid Build Coastguard Worker // already exist, the transaction fails with error `NOT_FOUND`. 81*d5c09012SAndroid Build Coastguard Worker Write update = 2; 82*d5c09012SAndroid Build Coastguard Worker 83*d5c09012SAndroid Build Coastguard Worker // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, then 84*d5c09012SAndroid Build Coastguard Worker // its column values are overwritten with the ones provided. Any 85*d5c09012SAndroid Build Coastguard Worker // column values not explicitly written are preserved. 86*d5c09012SAndroid Build Coastguard Worker // 87*d5c09012SAndroid Build Coastguard Worker // When using [insert_or_update][google.spanner.v1.Mutation.insert_or_update], just as when using [insert][google.spanner.v1.Mutation.insert], all `NOT 88*d5c09012SAndroid Build Coastguard Worker // NULL` columns in the table must be given a value. This holds true 89*d5c09012SAndroid Build Coastguard Worker // even when the row already exists and will therefore actually be updated. 90*d5c09012SAndroid Build Coastguard Worker Write insert_or_update = 3; 91*d5c09012SAndroid Build Coastguard Worker 92*d5c09012SAndroid Build Coastguard Worker // Like [insert][google.spanner.v1.Mutation.insert], except that if the row already exists, it is 93*d5c09012SAndroid Build Coastguard Worker // deleted, and the column values provided are inserted 94*d5c09012SAndroid Build Coastguard Worker // instead. Unlike [insert_or_update][google.spanner.v1.Mutation.insert_or_update], this means any values not 95*d5c09012SAndroid Build Coastguard Worker // explicitly written become `NULL`. 96*d5c09012SAndroid Build Coastguard Worker // 97*d5c09012SAndroid Build Coastguard Worker // In an interleaved table, if you create the child table with the 98*d5c09012SAndroid Build Coastguard Worker // `ON DELETE CASCADE` annotation, then replacing a parent row 99*d5c09012SAndroid Build Coastguard Worker // also deletes the child rows. Otherwise, you must delete the 100*d5c09012SAndroid Build Coastguard Worker // child rows before you replace the parent row. 101*d5c09012SAndroid Build Coastguard Worker Write replace = 4; 102*d5c09012SAndroid Build Coastguard Worker 103*d5c09012SAndroid Build Coastguard Worker // Delete rows from a table. Succeeds whether or not the named 104*d5c09012SAndroid Build Coastguard Worker // rows were present. 105*d5c09012SAndroid Build Coastguard Worker Delete delete = 5; 106*d5c09012SAndroid Build Coastguard Worker } 107*d5c09012SAndroid Build Coastguard Worker} 108