# 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.Value do
  @moduledoc """
  A message that can hold any of the supported value types and associated metadata.

  ## Attributes

  *   `arrayValue` (*type:* `GoogleApi.Datastore.V1.Model.ArrayValue.t`, *default:* `nil`) - An array value. Cannot contain another array value. A `Value` instance that sets field `array_value` must not set fields `meaning` or `exclude_from_indexes`.
  *   `blobValue` (*type:* `String.t`, *default:* `nil`) - A blob value. May have at most 1,000,000 bytes. When `exclude_from_indexes` is false, may have at most 1500 bytes. In JSON requests, must be base64-encoded.
  *   `booleanValue` (*type:* `boolean()`, *default:* `nil`) - A boolean value.
  *   `doubleValue` (*type:* `float()`, *default:* `nil`) - A double value.
  *   `entityValue` (*type:* `GoogleApi.Datastore.V1.Model.Entity.t`, *default:* `nil`) - An entity value. - May have no key. - May have a key with an incomplete key path. - May have a reserved/read-only key.
  *   `excludeFromIndexes` (*type:* `boolean()`, *default:* `nil`) - If the value should be excluded from all indexes including those defined explicitly.
  *   `geoPointValue` (*type:* `GoogleApi.Datastore.V1.Model.LatLng.t`, *default:* `nil`) - A geo point value representing a point on the surface of Earth.
  *   `integerValue` (*type:* `String.t`, *default:* `nil`) - An integer value.
  *   `keyValue` (*type:* `GoogleApi.Datastore.V1.Model.Key.t`, *default:* `nil`) - A key value.
  *   `meaning` (*type:* `integer()`, *default:* `nil`) - The `meaning` field should only be populated for backwards compatibility.
  *   `nullValue` (*type:* `String.t`, *default:* `nil`) - A null value.
  *   `stringValue` (*type:* `String.t`, *default:* `nil`) - A UTF-8 encoded string value. When `exclude_from_indexes` is false (it is indexed) , may have at most 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
  *   `timestampValue` (*type:* `DateTime.t`, *default:* `nil`) - A timestamp value. When stored in the Datastore, precise only to microseconds; any additional precision is rounded down.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :arrayValue => GoogleApi.Datastore.V1.Model.ArrayValue.t() | nil,
          :blobValue => String.t() | nil,
          :booleanValue => boolean() | nil,
          :doubleValue => float() | nil,
          :entityValue => GoogleApi.Datastore.V1.Model.Entity.t() | nil,
          :excludeFromIndexes => boolean() | nil,
          :geoPointValue => GoogleApi.Datastore.V1.Model.LatLng.t() | nil,
          :integerValue => String.t() | nil,
          :keyValue => GoogleApi.Datastore.V1.Model.Key.t() | nil,
          :meaning => integer() | nil,
          :nullValue => String.t() | nil,
          :stringValue => String.t() | nil,
          :timestampValue => DateTime.t() | nil
        }

  field(:arrayValue, as: GoogleApi.Datastore.V1.Model.ArrayValue)
  field(:blobValue)
  field(:booleanValue)
  field(:doubleValue)
  field(:entityValue, as: GoogleApi.Datastore.V1.Model.Entity)
  field(:excludeFromIndexes)
  field(:geoPointValue, as: GoogleApi.Datastore.V1.Model.LatLng)
  field(:integerValue)
  field(:keyValue, as: GoogleApi.Datastore.V1.Model.Key)
  field(:meaning)
  field(:nullValue)
  field(:stringValue)
  field(:timestampValue, as: DateTime)
end

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

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