{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.S3.Types.NoncurrentVersionExpiration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.S3.Types.NoncurrentVersionExpiration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal

-- | Specifies when noncurrent object versions expire. Upon expiration,
-- Amazon S3 permanently deletes the noncurrent object versions. You set
-- this lifecycle configuration action on a bucket that has versioning
-- enabled (or suspended) to request that Amazon S3 delete noncurrent
-- object versions at a specific period in the object\'s lifetime.
--
-- /See:/ 'newNoncurrentVersionExpiration' smart constructor.
data NoncurrentVersionExpiration = NoncurrentVersionExpiration'
  { -- | Specifies the number of days an object is noncurrent before Amazon S3
    -- can perform the associated action. For information about the noncurrent
    -- days calculations, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html#non-current-days-calculations How Amazon S3 Calculates When an Object Became Noncurrent>
    -- in the /Amazon S3 User Guide/.
    NoncurrentVersionExpiration -> Int
noncurrentDays :: Prelude.Int
  }
  deriving (NoncurrentVersionExpiration -> NoncurrentVersionExpiration -> Bool
(NoncurrentVersionExpiration
 -> NoncurrentVersionExpiration -> Bool)
-> (NoncurrentVersionExpiration
    -> NoncurrentVersionExpiration -> Bool)
-> Eq NoncurrentVersionExpiration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NoncurrentVersionExpiration -> NoncurrentVersionExpiration -> Bool
$c/= :: NoncurrentVersionExpiration -> NoncurrentVersionExpiration -> Bool
== :: NoncurrentVersionExpiration -> NoncurrentVersionExpiration -> Bool
$c== :: NoncurrentVersionExpiration -> NoncurrentVersionExpiration -> Bool
Prelude.Eq, ReadPrec [NoncurrentVersionExpiration]
ReadPrec NoncurrentVersionExpiration
Int -> ReadS NoncurrentVersionExpiration
ReadS [NoncurrentVersionExpiration]
(Int -> ReadS NoncurrentVersionExpiration)
-> ReadS [NoncurrentVersionExpiration]
-> ReadPrec NoncurrentVersionExpiration
-> ReadPrec [NoncurrentVersionExpiration]
-> Read NoncurrentVersionExpiration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NoncurrentVersionExpiration]
$creadListPrec :: ReadPrec [NoncurrentVersionExpiration]
readPrec :: ReadPrec NoncurrentVersionExpiration
$creadPrec :: ReadPrec NoncurrentVersionExpiration
readList :: ReadS [NoncurrentVersionExpiration]
$creadList :: ReadS [NoncurrentVersionExpiration]
readsPrec :: Int -> ReadS NoncurrentVersionExpiration
$creadsPrec :: Int -> ReadS NoncurrentVersionExpiration
Prelude.Read, Int -> NoncurrentVersionExpiration -> ShowS
[NoncurrentVersionExpiration] -> ShowS
NoncurrentVersionExpiration -> String
(Int -> NoncurrentVersionExpiration -> ShowS)
-> (NoncurrentVersionExpiration -> String)
-> ([NoncurrentVersionExpiration] -> ShowS)
-> Show NoncurrentVersionExpiration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NoncurrentVersionExpiration] -> ShowS
$cshowList :: [NoncurrentVersionExpiration] -> ShowS
show :: NoncurrentVersionExpiration -> String
$cshow :: NoncurrentVersionExpiration -> String
showsPrec :: Int -> NoncurrentVersionExpiration -> ShowS
$cshowsPrec :: Int -> NoncurrentVersionExpiration -> ShowS
Prelude.Show, (forall x.
 NoncurrentVersionExpiration -> Rep NoncurrentVersionExpiration x)
-> (forall x.
    Rep NoncurrentVersionExpiration x -> NoncurrentVersionExpiration)
-> Generic NoncurrentVersionExpiration
forall x.
Rep NoncurrentVersionExpiration x -> NoncurrentVersionExpiration
forall x.
NoncurrentVersionExpiration -> Rep NoncurrentVersionExpiration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NoncurrentVersionExpiration x -> NoncurrentVersionExpiration
$cfrom :: forall x.
NoncurrentVersionExpiration -> Rep NoncurrentVersionExpiration x
Prelude.Generic)

-- |
-- Create a value of 'NoncurrentVersionExpiration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'noncurrentDays', 'noncurrentVersionExpiration_noncurrentDays' - Specifies the number of days an object is noncurrent before Amazon S3
-- can perform the associated action. For information about the noncurrent
-- days calculations, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html#non-current-days-calculations How Amazon S3 Calculates When an Object Became Noncurrent>
-- in the /Amazon S3 User Guide/.
newNoncurrentVersionExpiration ::
  -- | 'noncurrentDays'
  Prelude.Int ->
  NoncurrentVersionExpiration
newNoncurrentVersionExpiration :: Int -> NoncurrentVersionExpiration
newNoncurrentVersionExpiration Int
pNoncurrentDays_ =
  NoncurrentVersionExpiration' :: Int -> NoncurrentVersionExpiration
NoncurrentVersionExpiration'
    { $sel:noncurrentDays:NoncurrentVersionExpiration' :: Int
noncurrentDays =
        Int
pNoncurrentDays_
    }

-- | Specifies the number of days an object is noncurrent before Amazon S3
-- can perform the associated action. For information about the noncurrent
-- days calculations, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html#non-current-days-calculations How Amazon S3 Calculates When an Object Became Noncurrent>
-- in the /Amazon S3 User Guide/.
noncurrentVersionExpiration_noncurrentDays :: Lens.Lens' NoncurrentVersionExpiration Prelude.Int
noncurrentVersionExpiration_noncurrentDays :: (Int -> f Int)
-> NoncurrentVersionExpiration -> f NoncurrentVersionExpiration
noncurrentVersionExpiration_noncurrentDays = (NoncurrentVersionExpiration -> Int)
-> (NoncurrentVersionExpiration
    -> Int -> NoncurrentVersionExpiration)
-> Lens
     NoncurrentVersionExpiration NoncurrentVersionExpiration Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NoncurrentVersionExpiration' {Int
noncurrentDays :: Int
$sel:noncurrentDays:NoncurrentVersionExpiration' :: NoncurrentVersionExpiration -> Int
noncurrentDays} -> Int
noncurrentDays) (\s :: NoncurrentVersionExpiration
s@NoncurrentVersionExpiration' {} Int
a -> NoncurrentVersionExpiration
s {$sel:noncurrentDays:NoncurrentVersionExpiration' :: Int
noncurrentDays = Int
a} :: NoncurrentVersionExpiration)

instance Core.FromXML NoncurrentVersionExpiration where
  parseXML :: [Node] -> Either String NoncurrentVersionExpiration
parseXML [Node]
x =
    Int -> NoncurrentVersionExpiration
NoncurrentVersionExpiration'
      (Int -> NoncurrentVersionExpiration)
-> Either String Int -> Either String NoncurrentVersionExpiration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Int
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"NoncurrentDays")

instance Prelude.Hashable NoncurrentVersionExpiration

instance Prelude.NFData NoncurrentVersionExpiration

instance Core.ToXML NoncurrentVersionExpiration where
  toXML :: NoncurrentVersionExpiration -> XML
toXML NoncurrentVersionExpiration' {Int
noncurrentDays :: Int
$sel:noncurrentDays:NoncurrentVersionExpiration' :: NoncurrentVersionExpiration -> Int
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"NoncurrentDays" Name -> Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Int
noncurrentDays]