# 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.PubSub.V1.Model.Snapshot do
  @moduledoc """
  A snapshot resource. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.

  ## Attributes

  *   `expireTime` (*type:* `DateTime.t`, *default:* `nil`) - Optional. The snapshot is guaranteed to exist up until this time. A newly-created snapshot expires no later than 7 days from the time of its creation. Its exact lifetime is determined at creation by the existing backlog in the source subscription. Specifically, the lifetime of the snapshot is `7 days - (age of oldest unacked message in the subscription)`. For example, consider a subscription whose oldest unacked message is 3 days old. If a snapshot is created from this subscription, the snapshot -- which will always capture this 3-day-old backlog as long as the snapshot exists -- will expire in 4 days. The service will refuse to create a snapshot that would expire in less than 1 hour after creation.
  *   `labels` (*type:* `map()`, *default:* `nil`) - Optional. See [Creating and managing labels] (https://cloud.google.com/pubsub/docs/labels).
  *   `name` (*type:* `String.t`, *default:* `nil`) - Optional. The name of the snapshot.
  *   `topic` (*type:* `String.t`, *default:* `nil`) - Optional. The name of the topic from which this snapshot is retaining messages.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :expireTime => DateTime.t() | nil,
          :labels => map() | nil,
          :name => String.t() | nil,
          :topic => String.t() | nil
        }

  field(:expireTime, as: DateTime)
  field(:labels, type: :map)
  field(:name)
  field(:topic)
end

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

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