{-# 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-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.NoncurrentVersionTransition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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@, 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@, or
-- @DEEP_ARCHIVE@ storage class at a specific period in the object\'s
-- lifetime.
--
-- /See:/ 'newNoncurrentVersionTransition' smart constructor.
data NoncurrentVersionTransition = 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 -> Int
noncurrentDays :: Prelude.Int,
    -- | The class of storage used to store the object.
    NoncurrentVersionTransition -> TransitionStorageClass
storageClass :: TransitionStorageClass
  }
  deriving (NoncurrentVersionTransition -> NoncurrentVersionTransition -> Bool
(NoncurrentVersionTransition
 -> NoncurrentVersionTransition -> Bool)
-> (NoncurrentVersionTransition
    -> NoncurrentVersionTransition -> Bool)
-> Eq NoncurrentVersionTransition
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]
(Int -> ReadS NoncurrentVersionTransition)
-> ReadS [NoncurrentVersionTransition]
-> ReadPrec NoncurrentVersionTransition
-> ReadPrec [NoncurrentVersionTransition]
-> Read 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
(Int -> NoncurrentVersionTransition -> ShowS)
-> (NoncurrentVersionTransition -> String)
-> ([NoncurrentVersionTransition] -> ShowS)
-> Show NoncurrentVersionTransition
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.
 NoncurrentVersionTransition -> Rep NoncurrentVersionTransition x)
-> (forall x.
    Rep NoncurrentVersionTransition x -> NoncurrentVersionTransition)
-> Generic NoncurrentVersionTransition
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:
--
-- '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' :: Int -> TransitionStorageClass -> NoncurrentVersionTransition
NoncurrentVersionTransition'
      { $sel:noncurrentDays:NoncurrentVersionTransition' :: Int
noncurrentDays =
          Int
pNoncurrentDays_,
        $sel:storageClass:NoncurrentVersionTransition' :: TransitionStorageClass
storageClass = TransitionStorageClass
pStorageClass_
      }

-- | 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 :: (Int -> f Int)
-> NoncurrentVersionTransition -> f NoncurrentVersionTransition
noncurrentVersionTransition_noncurrentDays = (NoncurrentVersionTransition -> Int)
-> (NoncurrentVersionTransition
    -> Int -> NoncurrentVersionTransition)
-> Lens
     NoncurrentVersionTransition NoncurrentVersionTransition Int Int
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 :: (TransitionStorageClass -> f TransitionStorageClass)
-> NoncurrentVersionTransition -> f NoncurrentVersionTransition
noncurrentVersionTransition_storageClass = (NoncurrentVersionTransition -> TransitionStorageClass)
-> (NoncurrentVersionTransition
    -> TransitionStorageClass -> NoncurrentVersionTransition)
-> Lens
     NoncurrentVersionTransition
     NoncurrentVersionTransition
     TransitionStorageClass
     TransitionStorageClass
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 Core.FromXML NoncurrentVersionTransition where
  parseXML :: [Node] -> Either String NoncurrentVersionTransition
parseXML [Node]
x =
    Int -> TransitionStorageClass -> NoncurrentVersionTransition
NoncurrentVersionTransition'
      (Int -> TransitionStorageClass -> NoncurrentVersionTransition)
-> Either String Int
-> Either
     String (TransitionStorageClass -> NoncurrentVersionTransition)
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")
      Either
  String (TransitionStorageClass -> NoncurrentVersionTransition)
-> Either String TransitionStorageClass
-> Either String NoncurrentVersionTransition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String TransitionStorageClass
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"StorageClass")

instance Prelude.Hashable NoncurrentVersionTransition

instance Prelude.NFData NoncurrentVersionTransition

instance Core.ToXML NoncurrentVersionTransition where
  toXML :: NoncurrentVersionTransition -> XML
toXML NoncurrentVersionTransition' {Int
TransitionStorageClass
storageClass :: TransitionStorageClass
noncurrentDays :: Int
$sel:storageClass:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> TransitionStorageClass
$sel:noncurrentDays:NoncurrentVersionTransition' :: NoncurrentVersionTransition -> 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,
        Name
"StorageClass" Name -> TransitionStorageClass -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= TransitionStorageClass
storageClass
      ]