# 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.MutationResult do
  @moduledoc """
  The result of applying a mutation.

  ## Attributes

  *   `conflictDetected` (*type:* `boolean()`, *default:* `nil`) - Whether a conflict was detected for this mutation. Always false when a conflict detection strategy field is not set in the mutation.
  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - The create time of the entity. This field will not be set after a 'delete'.
  *   `key` (*type:* `GoogleApi.Datastore.V1.Model.Key.t`, *default:* `nil`) - The automatically allocated key. Set only when the mutation allocated a key.
  *   `transformResults` (*type:* `list(GoogleApi.Datastore.V1.Model.Value.t)`, *default:* `nil`) - The results of applying each PropertyTransform, in the same order of the request.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - The update time of the entity on the server after processing the mutation. If the mutation doesn't change anything on the server, then the timestamp will be the update timestamp of the current entity. This field will not be set after a 'delete'.
  *   `version` (*type:* `String.t`, *default:* `nil`) - The version of the entity on the server after processing the mutation. If the mutation doesn't change anything on the server, then the version will be the version of the current entity or, if no entity is present, a version that is strictly greater than the version of any previous entity and less than the version of any possible future entity.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :conflictDetected => boolean() | nil,
          :createTime => DateTime.t() | nil,
          :key => GoogleApi.Datastore.V1.Model.Key.t() | nil,
          :transformResults => list(GoogleApi.Datastore.V1.Model.Value.t()) | nil,
          :updateTime => DateTime.t() | nil,
          :version => String.t() | nil
        }

  field(:conflictDetected)
  field(:createTime, as: DateTime)
  field(:key, as: GoogleApi.Datastore.V1.Model.Key)
  field(:transformResults, as: GoogleApi.Datastore.V1.Model.Value, type: :list)
  field(:updateTime, as: DateTime)
  field(:version)
end

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

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