{-# 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.TopicConfiguration 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.Event
import Amazonka.S3.Types.NotificationConfigurationFilter
data TopicConfiguration = TopicConfiguration'
{ TopicConfiguration -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
TopicConfiguration -> Maybe NotificationConfigurationFilter
filter' :: Prelude.Maybe NotificationConfigurationFilter,
TopicConfiguration -> Text
topicArn :: Prelude.Text,
TopicConfiguration -> [Event]
events :: [Event]
}
deriving (TopicConfiguration -> TopicConfiguration -> Bool
(TopicConfiguration -> TopicConfiguration -> Bool)
-> (TopicConfiguration -> TopicConfiguration -> Bool)
-> Eq TopicConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TopicConfiguration -> TopicConfiguration -> Bool
$c/= :: TopicConfiguration -> TopicConfiguration -> Bool
== :: TopicConfiguration -> TopicConfiguration -> Bool
$c== :: TopicConfiguration -> TopicConfiguration -> Bool
Prelude.Eq, ReadPrec [TopicConfiguration]
ReadPrec TopicConfiguration
Int -> ReadS TopicConfiguration
ReadS [TopicConfiguration]
(Int -> ReadS TopicConfiguration)
-> ReadS [TopicConfiguration]
-> ReadPrec TopicConfiguration
-> ReadPrec [TopicConfiguration]
-> Read TopicConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TopicConfiguration]
$creadListPrec :: ReadPrec [TopicConfiguration]
readPrec :: ReadPrec TopicConfiguration
$creadPrec :: ReadPrec TopicConfiguration
readList :: ReadS [TopicConfiguration]
$creadList :: ReadS [TopicConfiguration]
readsPrec :: Int -> ReadS TopicConfiguration
$creadsPrec :: Int -> ReadS TopicConfiguration
Prelude.Read, Int -> TopicConfiguration -> ShowS
[TopicConfiguration] -> ShowS
TopicConfiguration -> String
(Int -> TopicConfiguration -> ShowS)
-> (TopicConfiguration -> String)
-> ([TopicConfiguration] -> ShowS)
-> Show TopicConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TopicConfiguration] -> ShowS
$cshowList :: [TopicConfiguration] -> ShowS
show :: TopicConfiguration -> String
$cshow :: TopicConfiguration -> String
showsPrec :: Int -> TopicConfiguration -> ShowS
$cshowsPrec :: Int -> TopicConfiguration -> ShowS
Prelude.Show, (forall x. TopicConfiguration -> Rep TopicConfiguration x)
-> (forall x. Rep TopicConfiguration x -> TopicConfiguration)
-> Generic TopicConfiguration
forall x. Rep TopicConfiguration x -> TopicConfiguration
forall x. TopicConfiguration -> Rep TopicConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TopicConfiguration x -> TopicConfiguration
$cfrom :: forall x. TopicConfiguration -> Rep TopicConfiguration x
Prelude.Generic)
newTopicConfiguration ::
Prelude.Text ->
TopicConfiguration
newTopicConfiguration :: Text -> TopicConfiguration
newTopicConfiguration Text
pTopicArn_ =
TopicConfiguration' :: Maybe Text
-> Maybe NotificationConfigurationFilter
-> Text
-> [Event]
-> TopicConfiguration
TopicConfiguration'
{ $sel:id:TopicConfiguration' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:filter':TopicConfiguration' :: Maybe NotificationConfigurationFilter
filter' = Maybe NotificationConfigurationFilter
forall a. Maybe a
Prelude.Nothing,
$sel:topicArn:TopicConfiguration' :: Text
topicArn = Text
pTopicArn_,
$sel:events:TopicConfiguration' :: [Event]
events = [Event]
forall a. Monoid a => a
Prelude.mempty
}
topicConfiguration_id :: Lens.Lens' TopicConfiguration (Prelude.Maybe Prelude.Text)
topicConfiguration_id :: (Maybe Text -> f (Maybe Text))
-> TopicConfiguration -> f TopicConfiguration
topicConfiguration_id = (TopicConfiguration -> Maybe Text)
-> (TopicConfiguration -> Maybe Text -> TopicConfiguration)
-> Lens
TopicConfiguration TopicConfiguration (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicConfiguration' {Maybe Text
id :: Maybe Text
$sel:id:TopicConfiguration' :: TopicConfiguration -> Maybe Text
id} -> Maybe Text
id) (\s :: TopicConfiguration
s@TopicConfiguration' {} Maybe Text
a -> TopicConfiguration
s {$sel:id:TopicConfiguration' :: Maybe Text
id = Maybe Text
a} :: TopicConfiguration)
topicConfiguration_filter :: Lens.Lens' TopicConfiguration (Prelude.Maybe NotificationConfigurationFilter)
topicConfiguration_filter :: (Maybe NotificationConfigurationFilter
-> f (Maybe NotificationConfigurationFilter))
-> TopicConfiguration -> f TopicConfiguration
topicConfiguration_filter = (TopicConfiguration -> Maybe NotificationConfigurationFilter)
-> (TopicConfiguration
-> Maybe NotificationConfigurationFilter -> TopicConfiguration)
-> Lens
TopicConfiguration
TopicConfiguration
(Maybe NotificationConfigurationFilter)
(Maybe NotificationConfigurationFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicConfiguration' {Maybe NotificationConfigurationFilter
filter' :: Maybe NotificationConfigurationFilter
$sel:filter':TopicConfiguration' :: TopicConfiguration -> Maybe NotificationConfigurationFilter
filter'} -> Maybe NotificationConfigurationFilter
filter') (\s :: TopicConfiguration
s@TopicConfiguration' {} Maybe NotificationConfigurationFilter
a -> TopicConfiguration
s {$sel:filter':TopicConfiguration' :: Maybe NotificationConfigurationFilter
filter' = Maybe NotificationConfigurationFilter
a} :: TopicConfiguration)
topicConfiguration_topicArn :: Lens.Lens' TopicConfiguration Prelude.Text
topicConfiguration_topicArn :: (Text -> f Text) -> TopicConfiguration -> f TopicConfiguration
topicConfiguration_topicArn = (TopicConfiguration -> Text)
-> (TopicConfiguration -> Text -> TopicConfiguration)
-> Lens TopicConfiguration TopicConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicConfiguration' {Text
topicArn :: Text
$sel:topicArn:TopicConfiguration' :: TopicConfiguration -> Text
topicArn} -> Text
topicArn) (\s :: TopicConfiguration
s@TopicConfiguration' {} Text
a -> TopicConfiguration
s {$sel:topicArn:TopicConfiguration' :: Text
topicArn = Text
a} :: TopicConfiguration)
topicConfiguration_events :: Lens.Lens' TopicConfiguration [Event]
topicConfiguration_events :: ([Event] -> f [Event])
-> TopicConfiguration -> f TopicConfiguration
topicConfiguration_events = (TopicConfiguration -> [Event])
-> (TopicConfiguration -> [Event] -> TopicConfiguration)
-> Lens TopicConfiguration TopicConfiguration [Event] [Event]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TopicConfiguration' {[Event]
events :: [Event]
$sel:events:TopicConfiguration' :: TopicConfiguration -> [Event]
events} -> [Event]
events) (\s :: TopicConfiguration
s@TopicConfiguration' {} [Event]
a -> TopicConfiguration
s {$sel:events:TopicConfiguration' :: [Event]
events = [Event]
a} :: TopicConfiguration) (([Event] -> f [Event])
-> TopicConfiguration -> f TopicConfiguration)
-> (([Event] -> f [Event]) -> [Event] -> f [Event])
-> ([Event] -> f [Event])
-> TopicConfiguration
-> f TopicConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Event] -> f [Event]) -> [Event] -> f [Event]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromXML TopicConfiguration where
parseXML :: [Node] -> Either String TopicConfiguration
parseXML [Node]
x =
Maybe Text
-> Maybe NotificationConfigurationFilter
-> Text
-> [Event]
-> TopicConfiguration
TopicConfiguration'
(Maybe Text
-> Maybe NotificationConfigurationFilter
-> Text
-> [Event]
-> TopicConfiguration)
-> Either String (Maybe Text)
-> Either
String
(Maybe NotificationConfigurationFilter
-> Text -> [Event] -> TopicConfiguration)
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
"Id")
Either
String
(Maybe NotificationConfigurationFilter
-> Text -> [Event] -> TopicConfiguration)
-> Either String (Maybe NotificationConfigurationFilter)
-> Either String (Text -> [Event] -> TopicConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text -> Either String (Maybe NotificationConfigurationFilter)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Filter")
Either String (Text -> [Event] -> TopicConfiguration)
-> Either String Text
-> Either String ([Event] -> TopicConfiguration)
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
"Topic")
Either String ([Event] -> TopicConfiguration)
-> Either String [Event] -> Either String TopicConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Text -> [Node] -> Either String [Event]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Event" [Node]
x)
instance Prelude.Hashable TopicConfiguration
instance Prelude.NFData TopicConfiguration
instance Core.ToXML TopicConfiguration where
toXML :: TopicConfiguration -> XML
toXML TopicConfiguration' {[Event]
Maybe Text
Maybe NotificationConfigurationFilter
Text
events :: [Event]
topicArn :: Text
filter' :: Maybe NotificationConfigurationFilter
id :: Maybe Text
$sel:events:TopicConfiguration' :: TopicConfiguration -> [Event]
$sel:topicArn:TopicConfiguration' :: TopicConfiguration -> Text
$sel:filter':TopicConfiguration' :: TopicConfiguration -> Maybe NotificationConfigurationFilter
$sel:id:TopicConfiguration' :: TopicConfiguration -> Maybe Text
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"Id" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
id,
Name
"Filter" Name -> Maybe NotificationConfigurationFilter -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe NotificationConfigurationFilter
filter',
Name
"Topic" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
topicArn,
Name -> [Event] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Event" [Event]
events
]