{-# 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.IntelligentTieringAndOperator
-- 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.IntelligentTieringAndOperator 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.Tag

-- | A container for specifying S3 Intelligent-Tiering filters. The filters
-- determine the subset of objects to which the rule applies.
--
-- /See:/ 'newIntelligentTieringAndOperator' smart constructor.
data IntelligentTieringAndOperator = IntelligentTieringAndOperator'
  { -- | An object key name prefix that identifies the subset of objects to which
    -- the configuration applies.
    IntelligentTieringAndOperator -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | All of these tags must exist in the object\'s tag set in order for the
    -- configuration to apply.
    IntelligentTieringAndOperator -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (IntelligentTieringAndOperator
-> IntelligentTieringAndOperator -> Bool
(IntelligentTieringAndOperator
 -> IntelligentTieringAndOperator -> Bool)
-> (IntelligentTieringAndOperator
    -> IntelligentTieringAndOperator -> Bool)
-> Eq IntelligentTieringAndOperator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntelligentTieringAndOperator
-> IntelligentTieringAndOperator -> Bool
$c/= :: IntelligentTieringAndOperator
-> IntelligentTieringAndOperator -> Bool
== :: IntelligentTieringAndOperator
-> IntelligentTieringAndOperator -> Bool
$c== :: IntelligentTieringAndOperator
-> IntelligentTieringAndOperator -> Bool
Prelude.Eq, ReadPrec [IntelligentTieringAndOperator]
ReadPrec IntelligentTieringAndOperator
Int -> ReadS IntelligentTieringAndOperator
ReadS [IntelligentTieringAndOperator]
(Int -> ReadS IntelligentTieringAndOperator)
-> ReadS [IntelligentTieringAndOperator]
-> ReadPrec IntelligentTieringAndOperator
-> ReadPrec [IntelligentTieringAndOperator]
-> Read IntelligentTieringAndOperator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IntelligentTieringAndOperator]
$creadListPrec :: ReadPrec [IntelligentTieringAndOperator]
readPrec :: ReadPrec IntelligentTieringAndOperator
$creadPrec :: ReadPrec IntelligentTieringAndOperator
readList :: ReadS [IntelligentTieringAndOperator]
$creadList :: ReadS [IntelligentTieringAndOperator]
readsPrec :: Int -> ReadS IntelligentTieringAndOperator
$creadsPrec :: Int -> ReadS IntelligentTieringAndOperator
Prelude.Read, Int -> IntelligentTieringAndOperator -> ShowS
[IntelligentTieringAndOperator] -> ShowS
IntelligentTieringAndOperator -> String
(Int -> IntelligentTieringAndOperator -> ShowS)
-> (IntelligentTieringAndOperator -> String)
-> ([IntelligentTieringAndOperator] -> ShowS)
-> Show IntelligentTieringAndOperator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IntelligentTieringAndOperator] -> ShowS
$cshowList :: [IntelligentTieringAndOperator] -> ShowS
show :: IntelligentTieringAndOperator -> String
$cshow :: IntelligentTieringAndOperator -> String
showsPrec :: Int -> IntelligentTieringAndOperator -> ShowS
$cshowsPrec :: Int -> IntelligentTieringAndOperator -> ShowS
Prelude.Show, (forall x.
 IntelligentTieringAndOperator
 -> Rep IntelligentTieringAndOperator x)
-> (forall x.
    Rep IntelligentTieringAndOperator x
    -> IntelligentTieringAndOperator)
-> Generic IntelligentTieringAndOperator
forall x.
Rep IntelligentTieringAndOperator x
-> IntelligentTieringAndOperator
forall x.
IntelligentTieringAndOperator
-> Rep IntelligentTieringAndOperator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IntelligentTieringAndOperator x
-> IntelligentTieringAndOperator
$cfrom :: forall x.
IntelligentTieringAndOperator
-> Rep IntelligentTieringAndOperator x
Prelude.Generic)

-- |
-- Create a value of 'IntelligentTieringAndOperator' 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:
--
-- 'prefix', 'intelligentTieringAndOperator_prefix' - An object key name prefix that identifies the subset of objects to which
-- the configuration applies.
--
-- 'tags', 'intelligentTieringAndOperator_tags' - All of these tags must exist in the object\'s tag set in order for the
-- configuration to apply.
newIntelligentTieringAndOperator ::
  IntelligentTieringAndOperator
newIntelligentTieringAndOperator :: IntelligentTieringAndOperator
newIntelligentTieringAndOperator =
  IntelligentTieringAndOperator' :: Maybe Text -> Maybe [Tag] -> IntelligentTieringAndOperator
IntelligentTieringAndOperator'
    { $sel:prefix:IntelligentTieringAndOperator' :: Maybe Text
prefix =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:IntelligentTieringAndOperator' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing
    }

-- | An object key name prefix that identifies the subset of objects to which
-- the configuration applies.
intelligentTieringAndOperator_prefix :: Lens.Lens' IntelligentTieringAndOperator (Prelude.Maybe Prelude.Text)
intelligentTieringAndOperator_prefix :: (Maybe Text -> f (Maybe Text))
-> IntelligentTieringAndOperator -> f IntelligentTieringAndOperator
intelligentTieringAndOperator_prefix = (IntelligentTieringAndOperator -> Maybe Text)
-> (IntelligentTieringAndOperator
    -> Maybe Text -> IntelligentTieringAndOperator)
-> Lens
     IntelligentTieringAndOperator
     IntelligentTieringAndOperator
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntelligentTieringAndOperator' {Maybe Text
prefix :: Maybe Text
$sel:prefix:IntelligentTieringAndOperator' :: IntelligentTieringAndOperator -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: IntelligentTieringAndOperator
s@IntelligentTieringAndOperator' {} Maybe Text
a -> IntelligentTieringAndOperator
s {$sel:prefix:IntelligentTieringAndOperator' :: Maybe Text
prefix = Maybe Text
a} :: IntelligentTieringAndOperator)

-- | All of these tags must exist in the object\'s tag set in order for the
-- configuration to apply.
intelligentTieringAndOperator_tags :: Lens.Lens' IntelligentTieringAndOperator (Prelude.Maybe [Tag])
intelligentTieringAndOperator_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> IntelligentTieringAndOperator -> f IntelligentTieringAndOperator
intelligentTieringAndOperator_tags = (IntelligentTieringAndOperator -> Maybe [Tag])
-> (IntelligentTieringAndOperator
    -> Maybe [Tag] -> IntelligentTieringAndOperator)
-> Lens
     IntelligentTieringAndOperator
     IntelligentTieringAndOperator
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IntelligentTieringAndOperator' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:IntelligentTieringAndOperator' :: IntelligentTieringAndOperator -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: IntelligentTieringAndOperator
s@IntelligentTieringAndOperator' {} Maybe [Tag]
a -> IntelligentTieringAndOperator
s {$sel:tags:IntelligentTieringAndOperator' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: IntelligentTieringAndOperator) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> IntelligentTieringAndOperator
 -> f IntelligentTieringAndOperator)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> IntelligentTieringAndOperator
-> f IntelligentTieringAndOperator
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML IntelligentTieringAndOperator where
  parseXML :: [Node] -> Either String IntelligentTieringAndOperator
parseXML [Node]
x =
    Maybe Text -> Maybe [Tag] -> IntelligentTieringAndOperator
IntelligentTieringAndOperator'
      (Maybe Text -> Maybe [Tag] -> IntelligentTieringAndOperator)
-> Either String (Maybe Text)
-> Either String (Maybe [Tag] -> IntelligentTieringAndOperator)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Prefix")
      Either String (Maybe [Tag] -> IntelligentTieringAndOperator)
-> Either String (Maybe [Tag])
-> Either String IntelligentTieringAndOperator
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Tag" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Tag]))
-> Either String (Maybe [Tag])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Tag])
-> [Node] -> Either String (Maybe [Tag])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Tag]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Tag")
                  )

instance
  Prelude.Hashable
    IntelligentTieringAndOperator

instance Prelude.NFData IntelligentTieringAndOperator

instance Core.ToXML IntelligentTieringAndOperator where
  toXML :: IntelligentTieringAndOperator -> XML
toXML IntelligentTieringAndOperator' {Maybe [Tag]
Maybe Text
tags :: Maybe [Tag]
prefix :: Maybe Text
$sel:tags:IntelligentTieringAndOperator' :: IntelligentTieringAndOperator -> Maybe [Tag]
$sel:prefix:IntelligentTieringAndOperator' :: IntelligentTieringAndOperator -> Maybe Text
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Prefix" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
prefix,
        Name
"Tag"
          Name -> XML -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe XML -> XML
forall a. ToXML a => a -> XML
Core.toXML (Name -> [Tag] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Tag" ([Tag] -> XML) -> Maybe [Tag] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags)
      ]