{-# 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.NoncurrentVersionTransition
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.S3.Types.NoncurrentVersionTransition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.TransitionStorageClass

-- | Container for the transition rule that describes when noncurrent objects
-- transition to the @STANDARD_IA@, @ONEZONE_IA@, @INTELLIGENT_TIERING@,
-- @GLACIER_IR@, @GLACIER@, or @DEEP_ARCHIVE@ storage class. If your bucket
-- is versioning-enabled (or versioning is suspended), you can set this
-- action to request that Amazon S3 transition noncurrent object versions
-- to the @STANDARD_IA@, @ONEZONE_IA@, @INTELLIGENT_TIERING@, @GLACIER_IR@,
-- @GLACIER@, or @DEEP_ARCHIVE@ storage class at a specific period in the
-- object\'s lifetime.
--
-- /See:/ 'newNoncurrentVersionTransition' smart constructor.
data NoncurrentVersionTransition = NoncurrentVersionTransition'
  { -- | Specifies how many noncurrent versions Amazon S3 will retain. If there
    -- are this many more recent noncurrent versions, Amazon S3 will take the
    -- associated action. For more information about noncurrent versions, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html Lifecycle configuration elements>
    -- in the /Amazon S3 User Guide/.
    NoncurrentVersionTransition -> Maybe Int
newerNoncurrentVersions' :: Prelude.Maybe Prelude.Int,
    -- | 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 How Long an Object Has Been Noncurrent>
    -- in the /Amazon S3 User Guide/.
    NoncurrentVersionTransition -> Int
noncurrentDays :: Prelude.Int,
    -- | The class of storage used to store the object.
    NoncurrentVersionTransition -> TransitionStorageClass
storageClass :: TransitionStorageClass
  }
  deriving (NoncurrentVersionTransition -> NoncurrentVersionTransition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NoncurrentVersionTransition -> NoncurrentVersionTransition -> Bool
$c/= :: NoncurrentVersionTransition -> NoncurrentVersionTransition -> Bool
== :: NoncurrentVersionTransition -> NoncurrentVersionTransition -> Bool
$c== :: NoncurrentVersionTransition -> NoncurrentVersionTransition -> Bool
Prelude.Eq, ReadPrec [NoncurrentVersionTransition]
ReadPrec NoncurrentVersionTransition
Int -> ReadS NoncurrentVersionTransition
ReadS [NoncurrentVersionTransition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NoncurrentVersionTransition]
$creadListPrec :: ReadPrec [NoncurrentVersionTransition]
readPrec :: ReadPrec NoncurrentVersionTransition
$creadPrec :: ReadPrec NoncurrentVersionTransition
readList :: ReadS [NoncurrentVersionTransition]
$creadList :: ReadS [NoncurrentVersionTransition]
readsPrec :: Int -> ReadS NoncurrentVersionTransition
$creadsPrec :: Int -> ReadS NoncurrentVersionTransition
Prelude.Read, Int -> NoncurrentVersionTransition -> ShowS
[NoncurrentVersionTransition] -> ShowS
NoncurrentVersionTransition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NoncurrentVersionTransition] -> ShowS
$cshowList :: [NoncurrentVersionTransition] -> ShowS
show :: NoncurrentVersionTransition -> String
$cshow :: NoncurrentVersionTransition -> String
showsPrec :: Int -> NoncurrentVersionTransition -> ShowS
$cshowsPrec :: Int -> NoncurrentVersionTransition -> ShowS
Prelude.Show, forall x.
Rep NoncurrentVersionTransition x -> NoncurrentVersionTransition
forall x.
NoncurrentVersionTransition -> Rep NoncurrentVersionTransition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NoncurrentVersionTransition x -> NoncurrentVersionTransition
$cfrom :: forall x.
NoncurrentVersionTransition -> Rep NoncurrentVersionTransition x
Prelude.Generic)

-- |
-- Create a value of 'NoncurrentVersionTransition' 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:
--
-- 'newerNoncurrentVersions'', 'noncurrentVersionTransition_newerNoncurrentVersions' - Specifies how many noncurrent versions Amazon S3 will retain. If there
-- are this many more recent noncurrent versions, Amazon S3 will take the
-- associated action. For more information about noncurrent versions, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html Lifecycle configuration elements>
-- in the /Amazon S3 User Guide/.
--
-- 'noncurrentDays', 'noncurrentVersionTransition_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 How Long an Object Has Been Noncurrent>
-- in the /Amazon S3 User Guide/.
--
-- 'storageClass', 'noncurrentVersionTransition_storageClass' - The class of storage used to store the object.
newNoncurrentVersionTransition ::
  -- | 'noncurrentDays'
  Prelude.Int ->
  -- | 'storageClass'
  TransitionStorageClass ->
  NoncurrentVersionTransition
newNoncurrentVersionTransition :: Int -> TransitionStorageClass -> NoncurrentVersionTransition
newNoncurrentVersionTransition
  Int
pNoncurrentDays_
  TransitionStorageClass
pStorageClass_ =
    NoncurrentVersionTransition'
      { $sel:newerNoncurrentVersions':NoncurrentVersionTransition' :: Maybe Int
newerNoncurrentVersions' =
          forall a. Maybe a
Prelude.Nothing,
        $sel:noncurrentDays:NoncurrentVersionTransition' :: Int
noncurrentDays = Int
pNoncurrentDays_,
        $sel:storageClass:NoncurrentVersionTransition' :: TransitionStorageClass
storageClass = TransitionStorageClass
pStorageClass_
      }

-- | Specifies how many noncurrent versions Amazon S3 will retain. If there
-- are this many more recent noncurrent versions, Amazon S3 will take the
-- associated action. For more information about noncurrent versions, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/intro-lifecycle-rules.html Lifecycle configuration elements>
-- in the /Amazon S3 User Guide/.
noncurrentVersionTransition_newerNoncurrentVersions :: Lens.Lens' NoncurrentVersionTransition (Prelude.Maybe Prelude.Int)
noncurrentVersionTransition_newerNoncurrentVersions :: Lens' NoncurrentVersionTransition (Maybe Int)
noncurrentVersionTransition_newerNoncurrentVersions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NoncurrentVersionTransition' {Maybe Int
newerNoncurrentVersions' :: Maybe Int
$sel:newerNoncurrentVersions':NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Maybe Int
newerNoncurrentVersions'} -> Maybe Int
newerNoncurrentVersions') (\s :: NoncurrentVersionTransition
s@NoncurrentVersionTransition' {} Maybe Int
a -> NoncurrentVersionTransition
s {$sel:newerNoncurrentVersions':NoncurrentVersionTransition' :: Maybe Int
newerNoncurrentVersions' = Maybe Int
a} :: NoncurrentVersionTransition)

-- | 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 How Long an Object Has Been Noncurrent>
-- in the /Amazon S3 User Guide/.
noncurrentVersionTransition_noncurrentDays :: Lens.Lens' NoncurrentVersionTransition Prelude.Int
noncurrentVersionTransition_noncurrentDays :: Lens' NoncurrentVersionTransition Int
noncurrentVersionTransition_noncurrentDays = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NoncurrentVersionTransition' {Int
noncurrentDays :: Int
$sel:noncurrentDays:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Int
noncurrentDays} -> Int
noncurrentDays) (\s :: NoncurrentVersionTransition
s@NoncurrentVersionTransition' {} Int
a -> NoncurrentVersionTransition
s {$sel:noncurrentDays:NoncurrentVersionTransition' :: Int
noncurrentDays = Int
a} :: NoncurrentVersionTransition)

-- | The class of storage used to store the object.
noncurrentVersionTransition_storageClass :: Lens.Lens' NoncurrentVersionTransition TransitionStorageClass
noncurrentVersionTransition_storageClass :: Lens' NoncurrentVersionTransition TransitionStorageClass
noncurrentVersionTransition_storageClass = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NoncurrentVersionTransition' {TransitionStorageClass
storageClass :: TransitionStorageClass
$sel:storageClass:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> TransitionStorageClass
storageClass} -> TransitionStorageClass
storageClass) (\s :: NoncurrentVersionTransition
s@NoncurrentVersionTransition' {} TransitionStorageClass
a -> NoncurrentVersionTransition
s {$sel:storageClass:NoncurrentVersionTransition' :: TransitionStorageClass
storageClass = TransitionStorageClass
a} :: NoncurrentVersionTransition)

instance Data.FromXML NoncurrentVersionTransition where
  parseXML :: [Node] -> Either String NoncurrentVersionTransition
parseXML [Node]
x =
    Maybe Int
-> Int -> TransitionStorageClass -> NoncurrentVersionTransition
NoncurrentVersionTransition'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"NewerNoncurrentVersions")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"NoncurrentDays")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"StorageClass")

instance Prelude.Hashable NoncurrentVersionTransition where
  hashWithSalt :: Int -> NoncurrentVersionTransition -> Int
hashWithSalt Int
_salt NoncurrentVersionTransition' {Int
Maybe Int
TransitionStorageClass
storageClass :: TransitionStorageClass
noncurrentDays :: Int
newerNoncurrentVersions' :: Maybe Int
$sel:storageClass:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> TransitionStorageClass
$sel:noncurrentDays:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Int
$sel:newerNoncurrentVersions':NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
newerNoncurrentVersions'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
noncurrentDays
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TransitionStorageClass
storageClass

instance Prelude.NFData NoncurrentVersionTransition where
  rnf :: NoncurrentVersionTransition -> ()
rnf NoncurrentVersionTransition' {Int
Maybe Int
TransitionStorageClass
storageClass :: TransitionStorageClass
noncurrentDays :: Int
newerNoncurrentVersions' :: Maybe Int
$sel:storageClass:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> TransitionStorageClass
$sel:noncurrentDays:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Int
$sel:newerNoncurrentVersions':NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
newerNoncurrentVersions'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
noncurrentDays
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TransitionStorageClass
storageClass

instance Data.ToXML NoncurrentVersionTransition where
  toXML :: NoncurrentVersionTransition -> XML
toXML NoncurrentVersionTransition' {Int
Maybe Int
TransitionStorageClass
storageClass :: TransitionStorageClass
noncurrentDays :: Int
newerNoncurrentVersions' :: Maybe Int
$sel:storageClass:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> TransitionStorageClass
$sel:noncurrentDays:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Int
$sel:newerNoncurrentVersions':NoncurrentVersionTransition' :: NoncurrentVersionTransition -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"NewerNoncurrentVersions"
          forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Int
newerNoncurrentVersions',
        Name
"NoncurrentDays" forall a. ToXML a => Name -> a -> XML
Data.@= Int
noncurrentDays,
        Name
"StorageClass" forall a. ToXML a => Name -> a -> XML
Data.@= TransitionStorageClass
storageClass
      ]