{-# 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.Tiering
-- 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.Tiering 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.IntelligentTieringAccessTier

-- | The S3 Intelligent-Tiering storage class is designed to optimize storage
-- costs by automatically moving data to the most cost-effective storage
-- access tier, without additional operational overhead.
--
-- /See:/ 'newTiering' smart constructor.
data Tiering = Tiering'
  { -- | The number of consecutive days of no access after which an object will
    -- be eligible to be transitioned to the corresponding tier. The minimum
    -- number of days specified for Archive Access tier must be at least 90
    -- days and Deep Archive Access tier must be at least 180 days. The maximum
    -- can be up to 2 years (730 days).
    Tiering -> Int
days :: Prelude.Int,
    -- | S3 Intelligent-Tiering access tier. See
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html#sc-dynamic-data-access Storage class for automatically optimizing frequently and infrequently accessed objects>
    -- for a list of access tiers in the S3 Intelligent-Tiering storage class.
    Tiering -> IntelligentTieringAccessTier
accessTier :: IntelligentTieringAccessTier
  }
  deriving (Tiering -> Tiering -> Bool
(Tiering -> Tiering -> Bool)
-> (Tiering -> Tiering -> Bool) -> Eq Tiering
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tiering -> Tiering -> Bool
$c/= :: Tiering -> Tiering -> Bool
== :: Tiering -> Tiering -> Bool
$c== :: Tiering -> Tiering -> Bool
Prelude.Eq, ReadPrec [Tiering]
ReadPrec Tiering
Int -> ReadS Tiering
ReadS [Tiering]
(Int -> ReadS Tiering)
-> ReadS [Tiering]
-> ReadPrec Tiering
-> ReadPrec [Tiering]
-> Read Tiering
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tiering]
$creadListPrec :: ReadPrec [Tiering]
readPrec :: ReadPrec Tiering
$creadPrec :: ReadPrec Tiering
readList :: ReadS [Tiering]
$creadList :: ReadS [Tiering]
readsPrec :: Int -> ReadS Tiering
$creadsPrec :: Int -> ReadS Tiering
Prelude.Read, Int -> Tiering -> ShowS
[Tiering] -> ShowS
Tiering -> String
(Int -> Tiering -> ShowS)
-> (Tiering -> String) -> ([Tiering] -> ShowS) -> Show Tiering
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tiering] -> ShowS
$cshowList :: [Tiering] -> ShowS
show :: Tiering -> String
$cshow :: Tiering -> String
showsPrec :: Int -> Tiering -> ShowS
$cshowsPrec :: Int -> Tiering -> ShowS
Prelude.Show, (forall x. Tiering -> Rep Tiering x)
-> (forall x. Rep Tiering x -> Tiering) -> Generic Tiering
forall x. Rep Tiering x -> Tiering
forall x. Tiering -> Rep Tiering x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tiering x -> Tiering
$cfrom :: forall x. Tiering -> Rep Tiering x
Prelude.Generic)

-- |
-- Create a value of 'Tiering' 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:
--
-- 'days', 'tiering_days' - The number of consecutive days of no access after which an object will
-- be eligible to be transitioned to the corresponding tier. The minimum
-- number of days specified for Archive Access tier must be at least 90
-- days and Deep Archive Access tier must be at least 180 days. The maximum
-- can be up to 2 years (730 days).
--
-- 'accessTier', 'tiering_accessTier' - S3 Intelligent-Tiering access tier. See
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html#sc-dynamic-data-access Storage class for automatically optimizing frequently and infrequently accessed objects>
-- for a list of access tiers in the S3 Intelligent-Tiering storage class.
newTiering ::
  -- | 'days'
  Prelude.Int ->
  -- | 'accessTier'
  IntelligentTieringAccessTier ->
  Tiering
newTiering :: Int -> IntelligentTieringAccessTier -> Tiering
newTiering Int
pDays_ IntelligentTieringAccessTier
pAccessTier_ =
  Tiering' :: Int -> IntelligentTieringAccessTier -> Tiering
Tiering' {$sel:days:Tiering' :: Int
days = Int
pDays_, $sel:accessTier:Tiering' :: IntelligentTieringAccessTier
accessTier = IntelligentTieringAccessTier
pAccessTier_}

-- | The number of consecutive days of no access after which an object will
-- be eligible to be transitioned to the corresponding tier. The minimum
-- number of days specified for Archive Access tier must be at least 90
-- days and Deep Archive Access tier must be at least 180 days. The maximum
-- can be up to 2 years (730 days).
tiering_days :: Lens.Lens' Tiering Prelude.Int
tiering_days :: (Int -> f Int) -> Tiering -> f Tiering
tiering_days = (Tiering -> Int)
-> (Tiering -> Int -> Tiering) -> Lens Tiering Tiering Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tiering' {Int
days :: Int
$sel:days:Tiering' :: Tiering -> Int
days} -> Int
days) (\s :: Tiering
s@Tiering' {} Int
a -> Tiering
s {$sel:days:Tiering' :: Int
days = Int
a} :: Tiering)

-- | S3 Intelligent-Tiering access tier. See
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html#sc-dynamic-data-access Storage class for automatically optimizing frequently and infrequently accessed objects>
-- for a list of access tiers in the S3 Intelligent-Tiering storage class.
tiering_accessTier :: Lens.Lens' Tiering IntelligentTieringAccessTier
tiering_accessTier :: (IntelligentTieringAccessTier -> f IntelligentTieringAccessTier)
-> Tiering -> f Tiering
tiering_accessTier = (Tiering -> IntelligentTieringAccessTier)
-> (Tiering -> IntelligentTieringAccessTier -> Tiering)
-> Lens
     Tiering
     Tiering
     IntelligentTieringAccessTier
     IntelligentTieringAccessTier
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tiering' {IntelligentTieringAccessTier
accessTier :: IntelligentTieringAccessTier
$sel:accessTier:Tiering' :: Tiering -> IntelligentTieringAccessTier
accessTier} -> IntelligentTieringAccessTier
accessTier) (\s :: Tiering
s@Tiering' {} IntelligentTieringAccessTier
a -> Tiering
s {$sel:accessTier:Tiering' :: IntelligentTieringAccessTier
accessTier = IntelligentTieringAccessTier
a} :: Tiering)

instance Core.FromXML Tiering where
  parseXML :: [Node] -> Either String Tiering
parseXML [Node]
x =
    Int -> IntelligentTieringAccessTier -> Tiering
Tiering'
      (Int -> IntelligentTieringAccessTier -> Tiering)
-> Either String Int
-> Either String (IntelligentTieringAccessTier -> Tiering)
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
"Days")
      Either String (IntelligentTieringAccessTier -> Tiering)
-> Either String IntelligentTieringAccessTier
-> Either String Tiering
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String IntelligentTieringAccessTier
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"AccessTier")

instance Prelude.Hashable Tiering

instance Prelude.NFData Tiering

instance Core.ToXML Tiering where
  toXML :: Tiering -> XML
toXML Tiering' {Int
IntelligentTieringAccessTier
accessTier :: IntelligentTieringAccessTier
days :: Int
$sel:accessTier:Tiering' :: Tiering -> IntelligentTieringAccessTier
$sel:days:Tiering' :: Tiering -> Int
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Days" Name -> Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Int
days,
        Name
"AccessTier" Name -> IntelligentTieringAccessTier -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= IntelligentTieringAccessTier
accessTier
      ]