# 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.Storage.V1.Model.BucketRetentionPolicy do
  @moduledoc """
  The bucket's retention policy. The retention policy enforces a minimum retention time for all objects contained in the bucket, based on their creation time. Any attempt to overwrite or delete objects younger than the retention period will result in a PERMISSION_DENIED error. An unlocked retention policy can be modified or removed from the bucket via a storage.buckets.update operation. A locked retention policy cannot be removed or shortened in duration for the lifetime of the bucket. Attempting to remove or decrease period of a locked retention policy will result in a PERMISSION_DENIED error.

  ## Attributes

  *   `effectiveTime` (*type:* `DateTime.t`, *default:* `nil`) - Server-determined value that indicates the time from which policy was enforced and effective. This value is in RFC 3339 format.
  *   `isLocked` (*type:* `boolean()`, *default:* `nil`) - Once locked, an object retention policy cannot be modified.
  *   `retentionPeriod` (*type:* `String.t`, *default:* `nil`) - The duration in seconds that objects need to be retained. Retention duration must be greater than zero and less than 100 years. Note that enforcement of retention periods less than a day is not guaranteed. Such periods should only be used for testing purposes.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :effectiveTime => DateTime.t() | nil,
          :isLocked => boolean() | nil,
          :retentionPeriod => String.t() | nil
        }

  field(:effectiveTime, as: DateTime)
  field(:isLocked)
  field(:retentionPeriod)
end

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

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