{-# 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 #-}
module Amazonka.S3.Types.LoggingEnabled 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.TargetGrant
data LoggingEnabled = LoggingEnabled'
{
LoggingEnabled -> Maybe [TargetGrant]
targetGrants :: Prelude.Maybe [TargetGrant],
LoggingEnabled -> Text
targetBucket :: Prelude.Text,
LoggingEnabled -> Text
targetPrefix :: Prelude.Text
}
deriving (LoggingEnabled -> LoggingEnabled -> Bool
(LoggingEnabled -> LoggingEnabled -> Bool)
-> (LoggingEnabled -> LoggingEnabled -> Bool) -> Eq LoggingEnabled
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoggingEnabled -> LoggingEnabled -> Bool
$c/= :: LoggingEnabled -> LoggingEnabled -> Bool
== :: LoggingEnabled -> LoggingEnabled -> Bool
$c== :: LoggingEnabled -> LoggingEnabled -> Bool
Prelude.Eq, ReadPrec [LoggingEnabled]
ReadPrec LoggingEnabled
Int -> ReadS LoggingEnabled
ReadS [LoggingEnabled]
(Int -> ReadS LoggingEnabled)
-> ReadS [LoggingEnabled]
-> ReadPrec LoggingEnabled
-> ReadPrec [LoggingEnabled]
-> Read LoggingEnabled
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoggingEnabled]
$creadListPrec :: ReadPrec [LoggingEnabled]
readPrec :: ReadPrec LoggingEnabled
$creadPrec :: ReadPrec LoggingEnabled
readList :: ReadS [LoggingEnabled]
$creadList :: ReadS [LoggingEnabled]
readsPrec :: Int -> ReadS LoggingEnabled
$creadsPrec :: Int -> ReadS LoggingEnabled
Prelude.Read, Int -> LoggingEnabled -> ShowS
[LoggingEnabled] -> ShowS
LoggingEnabled -> String
(Int -> LoggingEnabled -> ShowS)
-> (LoggingEnabled -> String)
-> ([LoggingEnabled] -> ShowS)
-> Show LoggingEnabled
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoggingEnabled] -> ShowS
$cshowList :: [LoggingEnabled] -> ShowS
show :: LoggingEnabled -> String
$cshow :: LoggingEnabled -> String
showsPrec :: Int -> LoggingEnabled -> ShowS
$cshowsPrec :: Int -> LoggingEnabled -> ShowS
Prelude.Show, (forall x. LoggingEnabled -> Rep LoggingEnabled x)
-> (forall x. Rep LoggingEnabled x -> LoggingEnabled)
-> Generic LoggingEnabled
forall x. Rep LoggingEnabled x -> LoggingEnabled
forall x. LoggingEnabled -> Rep LoggingEnabled x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoggingEnabled x -> LoggingEnabled
$cfrom :: forall x. LoggingEnabled -> Rep LoggingEnabled x
Prelude.Generic)
newLoggingEnabled ::
Prelude.Text ->
Prelude.Text ->
LoggingEnabled
newLoggingEnabled :: Text -> Text -> LoggingEnabled
newLoggingEnabled Text
pTargetBucket_ Text
pTargetPrefix_ =
LoggingEnabled' :: Maybe [TargetGrant] -> Text -> Text -> LoggingEnabled
LoggingEnabled'
{ $sel:targetGrants:LoggingEnabled' :: Maybe [TargetGrant]
targetGrants = Maybe [TargetGrant]
forall a. Maybe a
Prelude.Nothing,
$sel:targetBucket:LoggingEnabled' :: Text
targetBucket = Text
pTargetBucket_,
$sel:targetPrefix:LoggingEnabled' :: Text
targetPrefix = Text
pTargetPrefix_
}
loggingEnabled_targetGrants :: Lens.Lens' LoggingEnabled (Prelude.Maybe [TargetGrant])
loggingEnabled_targetGrants :: (Maybe [TargetGrant] -> f (Maybe [TargetGrant]))
-> LoggingEnabled -> f LoggingEnabled
loggingEnabled_targetGrants = (LoggingEnabled -> Maybe [TargetGrant])
-> (LoggingEnabled -> Maybe [TargetGrant] -> LoggingEnabled)
-> Lens
LoggingEnabled
LoggingEnabled
(Maybe [TargetGrant])
(Maybe [TargetGrant])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingEnabled' {Maybe [TargetGrant]
targetGrants :: Maybe [TargetGrant]
$sel:targetGrants:LoggingEnabled' :: LoggingEnabled -> Maybe [TargetGrant]
targetGrants} -> Maybe [TargetGrant]
targetGrants) (\s :: LoggingEnabled
s@LoggingEnabled' {} Maybe [TargetGrant]
a -> LoggingEnabled
s {$sel:targetGrants:LoggingEnabled' :: Maybe [TargetGrant]
targetGrants = Maybe [TargetGrant]
a} :: LoggingEnabled) ((Maybe [TargetGrant] -> f (Maybe [TargetGrant]))
-> LoggingEnabled -> f LoggingEnabled)
-> ((Maybe [TargetGrant] -> f (Maybe [TargetGrant]))
-> Maybe [TargetGrant] -> f (Maybe [TargetGrant]))
-> (Maybe [TargetGrant] -> f (Maybe [TargetGrant]))
-> LoggingEnabled
-> f LoggingEnabled
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TargetGrant] [TargetGrant] [TargetGrant] [TargetGrant]
-> Iso
(Maybe [TargetGrant])
(Maybe [TargetGrant])
(Maybe [TargetGrant])
(Maybe [TargetGrant])
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 [TargetGrant] [TargetGrant] [TargetGrant] [TargetGrant]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
loggingEnabled_targetBucket :: Lens.Lens' LoggingEnabled Prelude.Text
loggingEnabled_targetBucket :: (Text -> f Text) -> LoggingEnabled -> f LoggingEnabled
loggingEnabled_targetBucket = (LoggingEnabled -> Text)
-> (LoggingEnabled -> Text -> LoggingEnabled)
-> Lens LoggingEnabled LoggingEnabled Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingEnabled' {Text
targetBucket :: Text
$sel:targetBucket:LoggingEnabled' :: LoggingEnabled -> Text
targetBucket} -> Text
targetBucket) (\s :: LoggingEnabled
s@LoggingEnabled' {} Text
a -> LoggingEnabled
s {$sel:targetBucket:LoggingEnabled' :: Text
targetBucket = Text
a} :: LoggingEnabled)
loggingEnabled_targetPrefix :: Lens.Lens' LoggingEnabled Prelude.Text
loggingEnabled_targetPrefix :: (Text -> f Text) -> LoggingEnabled -> f LoggingEnabled
loggingEnabled_targetPrefix = (LoggingEnabled -> Text)
-> (LoggingEnabled -> Text -> LoggingEnabled)
-> Lens LoggingEnabled LoggingEnabled Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoggingEnabled' {Text
targetPrefix :: Text
$sel:targetPrefix:LoggingEnabled' :: LoggingEnabled -> Text
targetPrefix} -> Text
targetPrefix) (\s :: LoggingEnabled
s@LoggingEnabled' {} Text
a -> LoggingEnabled
s {$sel:targetPrefix:LoggingEnabled' :: Text
targetPrefix = Text
a} :: LoggingEnabled)
instance Core.FromXML LoggingEnabled where
parseXML :: [Node] -> Either String LoggingEnabled
parseXML [Node]
x =
Maybe [TargetGrant] -> Text -> Text -> LoggingEnabled
LoggingEnabled'
(Maybe [TargetGrant] -> Text -> Text -> LoggingEnabled)
-> Either String (Maybe [TargetGrant])
-> Either String (Text -> Text -> LoggingEnabled)
forall (f :: * -> *) a b. Functor 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
"TargetGrants" 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 [TargetGrant]))
-> Either String (Maybe [TargetGrant])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [TargetGrant])
-> [Node] -> Either String (Maybe [TargetGrant])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [TargetGrant]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Grant")
)
Either String (Text -> Text -> LoggingEnabled)
-> Either String Text -> Either String (Text -> LoggingEnabled)
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
"TargetBucket")
Either String (Text -> LoggingEnabled)
-> Either String Text -> Either String LoggingEnabled
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
"TargetPrefix")
instance Prelude.Hashable LoggingEnabled
instance Prelude.NFData LoggingEnabled
instance Core.ToXML LoggingEnabled where
toXML :: LoggingEnabled -> XML
toXML LoggingEnabled' {Maybe [TargetGrant]
Text
targetPrefix :: Text
targetBucket :: Text
targetGrants :: Maybe [TargetGrant]
$sel:targetPrefix:LoggingEnabled' :: LoggingEnabled -> Text
$sel:targetBucket:LoggingEnabled' :: LoggingEnabled -> Text
$sel:targetGrants:LoggingEnabled' :: LoggingEnabled -> Maybe [TargetGrant]
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"TargetGrants"
Name -> XML -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe XML -> XML
forall a. ToXML a => a -> XML
Core.toXML
(Name -> [TargetGrant] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Grant" ([TargetGrant] -> XML) -> Maybe [TargetGrant] -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TargetGrant]
targetGrants),
Name
"TargetBucket" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
targetBucket,
Name
"TargetPrefix" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
targetPrefix
]