{-# 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.IntelligentTieringConfiguration
-- 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.IntelligentTieringConfiguration 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.IntelligentTieringFilter
import Amazonka.S3.Types.IntelligentTieringStatus
import Amazonka.S3.Types.Tiering

-- | Specifies the S3 Intelligent-Tiering configuration for an Amazon S3
-- bucket.
--
-- For information about the S3 Intelligent-Tiering storage class, 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>.
--
-- /See:/ 'newIntelligentTieringConfiguration' smart constructor.
data IntelligentTieringConfiguration = IntelligentTieringConfiguration'
  { -- | Specifies a bucket filter. The configuration only includes objects that
    -- meet the filter\'s criteria.
    IntelligentTieringConfiguration -> Maybe IntelligentTieringFilter
filter' :: Prelude.Maybe IntelligentTieringFilter,
    -- | The ID used to identify the S3 Intelligent-Tiering configuration.
    IntelligentTieringConfiguration -> Text
id :: Prelude.Text,
    -- | Specifies the status of the configuration.
    IntelligentTieringConfiguration -> IntelligentTieringStatus
status :: IntelligentTieringStatus,
    -- | Specifies the S3 Intelligent-Tiering storage class tier of the
    -- configuration.
    IntelligentTieringConfiguration -> [Tiering]
tierings :: [Tiering]
  }
  deriving (IntelligentTieringConfiguration
-> IntelligentTieringConfiguration -> Bool
(IntelligentTieringConfiguration
 -> IntelligentTieringConfiguration -> Bool)
-> (IntelligentTieringConfiguration
    -> IntelligentTieringConfiguration -> Bool)
-> Eq IntelligentTieringConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntelligentTieringConfiguration
-> IntelligentTieringConfiguration -> Bool
$c/= :: IntelligentTieringConfiguration
-> IntelligentTieringConfiguration -> Bool
== :: IntelligentTieringConfiguration
-> IntelligentTieringConfiguration -> Bool
$c== :: IntelligentTieringConfiguration
-> IntelligentTieringConfiguration -> Bool
Prelude.Eq, ReadPrec [IntelligentTieringConfiguration]
ReadPrec IntelligentTieringConfiguration
Int -> ReadS IntelligentTieringConfiguration
ReadS [IntelligentTieringConfiguration]
(Int -> ReadS IntelligentTieringConfiguration)
-> ReadS [IntelligentTieringConfiguration]
-> ReadPrec IntelligentTieringConfiguration
-> ReadPrec [IntelligentTieringConfiguration]
-> Read IntelligentTieringConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IntelligentTieringConfiguration]
$creadListPrec :: ReadPrec [IntelligentTieringConfiguration]
readPrec :: ReadPrec IntelligentTieringConfiguration
$creadPrec :: ReadPrec IntelligentTieringConfiguration
readList :: ReadS [IntelligentTieringConfiguration]
$creadList :: ReadS [IntelligentTieringConfiguration]
readsPrec :: Int -> ReadS IntelligentTieringConfiguration
$creadsPrec :: Int -> ReadS IntelligentTieringConfiguration
Prelude.Read, Int -> IntelligentTieringConfiguration -> ShowS
[IntelligentTieringConfiguration] -> ShowS
IntelligentTieringConfiguration -> String
(Int -> IntelligentTieringConfiguration -> ShowS)
-> (IntelligentTieringConfiguration -> String)
-> ([IntelligentTieringConfiguration] -> ShowS)
-> Show IntelligentTieringConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntelligentTieringConfiguration] -> ShowS
$cshowList :: [IntelligentTieringConfiguration] -> ShowS
show :: IntelligentTieringConfiguration -> String
$cshow :: IntelligentTieringConfiguration -> String
showsPrec :: Int -> IntelligentTieringConfiguration -> ShowS
$cshowsPrec :: Int -> IntelligentTieringConfiguration -> ShowS
Prelude.Show, (forall x.
 IntelligentTieringConfiguration
 -> Rep IntelligentTieringConfiguration x)
-> (forall x.
    Rep IntelligentTieringConfiguration x
    -> IntelligentTieringConfiguration)
-> Generic IntelligentTieringConfiguration
forall x.
Rep IntelligentTieringConfiguration x
-> IntelligentTieringConfiguration
forall x.
IntelligentTieringConfiguration
-> Rep IntelligentTieringConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IntelligentTieringConfiguration x
-> IntelligentTieringConfiguration
$cfrom :: forall x.
IntelligentTieringConfiguration
-> Rep IntelligentTieringConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'IntelligentTieringConfiguration' 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:
--
-- 'filter'', 'intelligentTieringConfiguration_filter' - Specifies a bucket filter. The configuration only includes objects that
-- meet the filter\'s criteria.
--
-- 'id', 'intelligentTieringConfiguration_id' - The ID used to identify the S3 Intelligent-Tiering configuration.
--
-- 'status', 'intelligentTieringConfiguration_status' - Specifies the status of the configuration.
--
-- 'tierings', 'intelligentTieringConfiguration_tierings' - Specifies the S3 Intelligent-Tiering storage class tier of the
-- configuration.
newIntelligentTieringConfiguration ::
  -- | 'id'
  Prelude.Text ->
  -- | 'status'
  IntelligentTieringStatus ->
  IntelligentTieringConfiguration
newIntelligentTieringConfiguration :: Text -> IntelligentTieringStatus -> IntelligentTieringConfiguration
newIntelligentTieringConfiguration Text
pId_ IntelligentTieringStatus
pStatus_ =
  IntelligentTieringConfiguration' :: Maybe IntelligentTieringFilter
-> Text
-> IntelligentTieringStatus
-> [Tiering]
-> IntelligentTieringConfiguration
IntelligentTieringConfiguration'
    { $sel:filter':IntelligentTieringConfiguration' :: Maybe IntelligentTieringFilter
filter' =
        Maybe IntelligentTieringFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:id:IntelligentTieringConfiguration' :: Text
id = Text
pId_,
      $sel:status:IntelligentTieringConfiguration' :: IntelligentTieringStatus
status = IntelligentTieringStatus
pStatus_,
      $sel:tierings:IntelligentTieringConfiguration' :: [Tiering]
tierings = [Tiering]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Specifies a bucket filter. The configuration only includes objects that
-- meet the filter\'s criteria.
intelligentTieringConfiguration_filter :: Lens.Lens' IntelligentTieringConfiguration (Prelude.Maybe IntelligentTieringFilter)
intelligentTieringConfiguration_filter :: (Maybe IntelligentTieringFilter
 -> f (Maybe IntelligentTieringFilter))
-> IntelligentTieringConfiguration
-> f IntelligentTieringConfiguration
intelligentTieringConfiguration_filter = (IntelligentTieringConfiguration -> Maybe IntelligentTieringFilter)
-> (IntelligentTieringConfiguration
    -> Maybe IntelligentTieringFilter
    -> IntelligentTieringConfiguration)
-> Lens
     IntelligentTieringConfiguration
     IntelligentTieringConfiguration
     (Maybe IntelligentTieringFilter)
     (Maybe IntelligentTieringFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntelligentTieringConfiguration' {Maybe IntelligentTieringFilter
filter' :: Maybe IntelligentTieringFilter
$sel:filter':IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> Maybe IntelligentTieringFilter
filter'} -> Maybe IntelligentTieringFilter
filter') (\s :: IntelligentTieringConfiguration
s@IntelligentTieringConfiguration' {} Maybe IntelligentTieringFilter
a -> IntelligentTieringConfiguration
s {$sel:filter':IntelligentTieringConfiguration' :: Maybe IntelligentTieringFilter
filter' = Maybe IntelligentTieringFilter
a} :: IntelligentTieringConfiguration)

-- | The ID used to identify the S3 Intelligent-Tiering configuration.
intelligentTieringConfiguration_id :: Lens.Lens' IntelligentTieringConfiguration Prelude.Text
intelligentTieringConfiguration_id :: (Text -> f Text)
-> IntelligentTieringConfiguration
-> f IntelligentTieringConfiguration
intelligentTieringConfiguration_id = (IntelligentTieringConfiguration -> Text)
-> (IntelligentTieringConfiguration
    -> Text -> IntelligentTieringConfiguration)
-> Lens
     IntelligentTieringConfiguration
     IntelligentTieringConfiguration
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntelligentTieringConfiguration' {Text
id :: Text
$sel:id:IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> Text
id} -> Text
id) (\s :: IntelligentTieringConfiguration
s@IntelligentTieringConfiguration' {} Text
a -> IntelligentTieringConfiguration
s {$sel:id:IntelligentTieringConfiguration' :: Text
id = Text
a} :: IntelligentTieringConfiguration)

-- | Specifies the status of the configuration.
intelligentTieringConfiguration_status :: Lens.Lens' IntelligentTieringConfiguration IntelligentTieringStatus
intelligentTieringConfiguration_status :: (IntelligentTieringStatus -> f IntelligentTieringStatus)
-> IntelligentTieringConfiguration
-> f IntelligentTieringConfiguration
intelligentTieringConfiguration_status = (IntelligentTieringConfiguration -> IntelligentTieringStatus)
-> (IntelligentTieringConfiguration
    -> IntelligentTieringStatus -> IntelligentTieringConfiguration)
-> Lens
     IntelligentTieringConfiguration
     IntelligentTieringConfiguration
     IntelligentTieringStatus
     IntelligentTieringStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntelligentTieringConfiguration' {IntelligentTieringStatus
status :: IntelligentTieringStatus
$sel:status:IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> IntelligentTieringStatus
status} -> IntelligentTieringStatus
status) (\s :: IntelligentTieringConfiguration
s@IntelligentTieringConfiguration' {} IntelligentTieringStatus
a -> IntelligentTieringConfiguration
s {$sel:status:IntelligentTieringConfiguration' :: IntelligentTieringStatus
status = IntelligentTieringStatus
a} :: IntelligentTieringConfiguration)

-- | Specifies the S3 Intelligent-Tiering storage class tier of the
-- configuration.
intelligentTieringConfiguration_tierings :: Lens.Lens' IntelligentTieringConfiguration [Tiering]
intelligentTieringConfiguration_tierings :: ([Tiering] -> f [Tiering])
-> IntelligentTieringConfiguration
-> f IntelligentTieringConfiguration
intelligentTieringConfiguration_tierings = (IntelligentTieringConfiguration -> [Tiering])
-> (IntelligentTieringConfiguration
    -> [Tiering] -> IntelligentTieringConfiguration)
-> Lens
     IntelligentTieringConfiguration
     IntelligentTieringConfiguration
     [Tiering]
     [Tiering]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntelligentTieringConfiguration' {[Tiering]
tierings :: [Tiering]
$sel:tierings:IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> [Tiering]
tierings} -> [Tiering]
tierings) (\s :: IntelligentTieringConfiguration
s@IntelligentTieringConfiguration' {} [Tiering]
a -> IntelligentTieringConfiguration
s {$sel:tierings:IntelligentTieringConfiguration' :: [Tiering]
tierings = [Tiering]
a} :: IntelligentTieringConfiguration) (([Tiering] -> f [Tiering])
 -> IntelligentTieringConfiguration
 -> f IntelligentTieringConfiguration)
-> (([Tiering] -> f [Tiering]) -> [Tiering] -> f [Tiering])
-> ([Tiering] -> f [Tiering])
-> IntelligentTieringConfiguration
-> f IntelligentTieringConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Tiering] -> f [Tiering]) -> [Tiering] -> f [Tiering]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML IntelligentTieringConfiguration where
  parseXML :: [Node] -> Either String IntelligentTieringConfiguration
parseXML [Node]
x =
    Maybe IntelligentTieringFilter
-> Text
-> IntelligentTieringStatus
-> [Tiering]
-> IntelligentTieringConfiguration
IntelligentTieringConfiguration'
      (Maybe IntelligentTieringFilter
 -> Text
 -> IntelligentTieringStatus
 -> [Tiering]
 -> IntelligentTieringConfiguration)
-> Either String (Maybe IntelligentTieringFilter)
-> Either
     String
     (Text
      -> IntelligentTieringStatus
      -> [Tiering]
      -> IntelligentTieringConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe IntelligentTieringFilter)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Filter")
      Either
  String
  (Text
   -> IntelligentTieringStatus
   -> [Tiering]
   -> IntelligentTieringConfiguration)
-> Either String Text
-> Either
     String
     (IntelligentTieringStatus
      -> [Tiering] -> IntelligentTieringConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either
  String
  (IntelligentTieringStatus
   -> [Tiering] -> IntelligentTieringConfiguration)
-> Either String IntelligentTieringStatus
-> Either String ([Tiering] -> IntelligentTieringConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String IntelligentTieringStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Status")
      Either String ([Tiering] -> IntelligentTieringConfiguration)
-> Either String [Tiering]
-> Either String IntelligentTieringConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Text -> [Node] -> Either String [Tiering]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Tiering" [Node]
x)

instance
  Prelude.Hashable
    IntelligentTieringConfiguration

instance
  Prelude.NFData
    IntelligentTieringConfiguration

instance Core.ToXML IntelligentTieringConfiguration where
  toXML :: IntelligentTieringConfiguration -> XML
toXML IntelligentTieringConfiguration' {[Tiering]
Maybe IntelligentTieringFilter
Text
IntelligentTieringStatus
tierings :: [Tiering]
status :: IntelligentTieringStatus
id :: Text
filter' :: Maybe IntelligentTieringFilter
$sel:tierings:IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> [Tiering]
$sel:status:IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> IntelligentTieringStatus
$sel:id:IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> Text
$sel:filter':IntelligentTieringConfiguration' :: IntelligentTieringConfiguration -> Maybe IntelligentTieringFilter
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Filter" Name -> Maybe IntelligentTieringFilter -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe IntelligentTieringFilter
filter',
        Name
"Id" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
id,
        Name
"Status" Name -> IntelligentTieringStatus -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= IntelligentTieringStatus
status,
        Name -> [Tiering] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Tiering" [Tiering]
tierings
      ]