# 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.Mutation do
  @moduledoc """
  A mutation to apply to an entity.

  ## Attributes

  *   `baseVersion` (*type:* `String.t`, *default:* `nil`) - The version of the entity that this mutation is being applied to. If this does not match the current version on the server, the mutation conflicts.
  *   `conflictResolutionStrategy` (*type:* `String.t`, *default:* `nil`) - The strategy to use when a conflict is detected. Defaults to `SERVER_VALUE`. If this is set, then `conflict_detection_strategy` must also be set.
  *   `delete` (*type:* `GoogleApi.Datastore.V1.Model.Key.t`, *default:* `nil`) - The key of the entity to delete. The entity may or may not already exist. Must have a complete key path and must not be reserved/read-only.
  *   `insert` (*type:* `GoogleApi.Datastore.V1.Model.Entity.t`, *default:* `nil`) - The entity to insert. The entity must not already exist. The entity key's final path element may be incomplete.
  *   `propertyMask` (*type:* `GoogleApi.Datastore.V1.Model.PropertyMask.t`, *default:* `nil`) - The properties to write in this mutation. None of the properties in the mask may have a reserved name, except for `__key__`. This field is ignored for `delete`. If the entity already exists, only properties referenced in the mask are updated, others are left untouched. Properties referenced in the mask but not in the entity are deleted.
  *   `propertyTransforms` (*type:* `list(GoogleApi.Datastore.V1.Model.PropertyTransform.t)`, *default:* `nil`) - Optional. The transforms to perform on the entity. This field can be set only when the operation is `insert`, `update`, or `upsert`. If present, the transforms are be applied to the entity regardless of the property mask, in order, after the operation.
  *   `update` (*type:* `GoogleApi.Datastore.V1.Model.Entity.t`, *default:* `nil`) - The entity to update. The entity must already exist. Must have a complete key path.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - The update time of the entity that this mutation is being applied to. If this does not match the current update time on the server, the mutation conflicts.
  *   `upsert` (*type:* `GoogleApi.Datastore.V1.Model.Entity.t`, *default:* `nil`) - The entity to upsert. The entity may or may not already exist. The entity key's final path element may be incomplete.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :baseVersion => String.t() | nil,
          :conflictResolutionStrategy => String.t() | nil,
          :delete => GoogleApi.Datastore.V1.Model.Key.t() | nil,
          :insert => GoogleApi.Datastore.V1.Model.Entity.t() | nil,
          :propertyMask => GoogleApi.Datastore.V1.Model.PropertyMask.t() | nil,
          :propertyTransforms => list(GoogleApi.Datastore.V1.Model.PropertyTransform.t()) | nil,
          :update => GoogleApi.Datastore.V1.Model.Entity.t() | nil,
          :updateTime => DateTime.t() | nil,
          :upsert => GoogleApi.Datastore.V1.Model.Entity.t() | nil
        }

  field(:baseVersion)
  field(:conflictResolutionStrategy)
  field(:delete, as: GoogleApi.Datastore.V1.Model.Key)
  field(:insert, as: GoogleApi.Datastore.V1.Model.Entity)
  field(:propertyMask, as: GoogleApi.Datastore.V1.Model.PropertyMask)
  field(:propertyTransforms, as: GoogleApi.Datastore.V1.Model.PropertyTransform, type: :list)
  field(:update, as: GoogleApi.Datastore.V1.Model.Entity)
  field(:updateTime, as: DateTime)
  field(:upsert, as: GoogleApi.Datastore.V1.Model.Entity)
end

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

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