# 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.EntityResult do
  @moduledoc """
  The result of fetching an entity from Datastore.

  ## Attributes

  *   `createTime` (*type:* `DateTime.t`, *default:* `nil`) - The time at which the entity was created. This field is set for `FULL` entity results. If this entity is missing, this field will not be set.
  *   `cursor` (*type:* `String.t`, *default:* `nil`) - A cursor that points to the position after the result entity. Set only when the `EntityResult` is part of a `QueryResultBatch` message.
  *   `entity` (*type:* `GoogleApi.Datastore.V1.Model.Entity.t`, *default:* `nil`) - The resulting entity.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - The time at which the entity was last changed. This field is set for `FULL` entity results. If this entity is missing, this field will not be set.
  *   `version` (*type:* `String.t`, *default:* `nil`) - The version of the entity, a strictly positive number that monotonically increases with changes to the entity. This field is set for `FULL` entity results. For missing entities in `LookupResponse`, this is the version of the snapshot that was used to look up the entity, and it is always set except for eventually consistent reads.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :createTime => DateTime.t() | nil,
          :cursor => String.t() | nil,
          :entity => GoogleApi.Datastore.V1.Model.Entity.t() | nil,
          :updateTime => DateTime.t() | nil,
          :version => String.t() | nil
        }

  field(:createTime, as: DateTime)
  field(:cursor)
  field(:entity, as: GoogleApi.Datastore.V1.Model.Entity)
  field(:updateTime, as: DateTime)
  field(:version)
end

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

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