# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Datastore.V1.Model.CommitRequest do
  @moduledoc """
  The request for Datastore.Commit.

  ## Attributes

  *   `databaseId` (*type:* `String.t`, *default:* `nil`) - The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
  *   `mode` (*type:* `String.t`, *default:* `nil`) - The type of commit to perform. Defaults to `TRANSACTIONAL`.
  *   `mutations` (*type:* `list(GoogleApi.Datastore.V1.Model.Mutation.t)`, *default:* `nil`) - The mutations to perform. When mode is `TRANSACTIONAL`, mutations affecting a single entity are applied in order. The following sequences of mutations affecting a single entity are not permitted in a single `Commit` request: - `insert` followed by `insert` - `update` followed by `insert` - `upsert` followed by `insert` - `delete` followed by `update` When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single entity.
  *   `singleUseTransaction` (*type:* `GoogleApi.Datastore.V1.Model.TransactionOptions.t`, *default:* `nil`) - Options for beginning a new transaction for this request. The transaction is committed when the request completes. If specified, TransactionOptions.mode must be TransactionOptions.ReadWrite.
  *   `transaction` (*type:* `String.t`, *default:* `nil`) - The identifier of the transaction associated with the commit. A transaction identifier is returned by a call to Datastore.BeginTransaction.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :databaseId => String.t() | nil,
          :mode => String.t() | nil,
          :mutations => list(GoogleApi.Datastore.V1.Model.Mutation.t()) | nil,
          :singleUseTransaction => GoogleApi.Datastore.V1.Model.TransactionOptions.t() | nil,
          :transaction => String.t() | nil
        }

  field(:databaseId)
  field(:mode)
  field(:mutations, as: GoogleApi.Datastore.V1.Model.Mutation, type: :list)
  field(:singleUseTransaction, as: GoogleApi.Datastore.V1.Model.TransactionOptions)
  field(:transaction)
end

defimpl Poison.Decoder, for: GoogleApi.Datastore.V1.Model.CommitRequest do
  def decode(value, options) do
    GoogleApi.Datastore.V1.Model.CommitRequest.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Datastore.V1.Model.CommitRequest do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
