module Aws.Ses.Commands.SetIdentityNotificationTopic
    ( SetIdentityNotificationTopic(..)
    , SetIdentityNotificationTopicResponse(..)
    , NotificationType(..)
    ) where

import Data.Text (Text)
import Control.Applicative
import Data.Maybe (maybeToList)
import Data.Text.Encoding as T (encodeUtf8)
import Data.Typeable
import Prelude
import Aws.Core
import Aws.Ses.Core

data NotificationType = Bounce | Complaint
    deriving (NotificationType -> NotificationType -> Bool
(NotificationType -> NotificationType -> Bool)
-> (NotificationType -> NotificationType -> Bool)
-> Eq NotificationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NotificationType -> NotificationType -> Bool
== :: NotificationType -> NotificationType -> Bool
$c/= :: NotificationType -> NotificationType -> Bool
/= :: NotificationType -> NotificationType -> Bool
Eq, Eq NotificationType
Eq NotificationType =>
(NotificationType -> NotificationType -> Ordering)
-> (NotificationType -> NotificationType -> Bool)
-> (NotificationType -> NotificationType -> Bool)
-> (NotificationType -> NotificationType -> Bool)
-> (NotificationType -> NotificationType -> Bool)
-> (NotificationType -> NotificationType -> NotificationType)
-> (NotificationType -> NotificationType -> NotificationType)
-> Ord NotificationType
NotificationType -> NotificationType -> Bool
NotificationType -> NotificationType -> Ordering
NotificationType -> NotificationType -> NotificationType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: NotificationType -> NotificationType -> Ordering
compare :: NotificationType -> NotificationType -> Ordering
$c< :: NotificationType -> NotificationType -> Bool
< :: NotificationType -> NotificationType -> Bool
$c<= :: NotificationType -> NotificationType -> Bool
<= :: NotificationType -> NotificationType -> Bool
$c> :: NotificationType -> NotificationType -> Bool
> :: NotificationType -> NotificationType -> Bool
$c>= :: NotificationType -> NotificationType -> Bool
>= :: NotificationType -> NotificationType -> Bool
$cmax :: NotificationType -> NotificationType -> NotificationType
max :: NotificationType -> NotificationType -> NotificationType
$cmin :: NotificationType -> NotificationType -> NotificationType
min :: NotificationType -> NotificationType -> NotificationType
Ord, Int -> NotificationType -> ShowS
[NotificationType] -> ShowS
NotificationType -> String
(Int -> NotificationType -> ShowS)
-> (NotificationType -> String)
-> ([NotificationType] -> ShowS)
-> Show NotificationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NotificationType -> ShowS
showsPrec :: Int -> NotificationType -> ShowS
$cshow :: NotificationType -> String
show :: NotificationType -> String
$cshowList :: [NotificationType] -> ShowS
showList :: [NotificationType] -> ShowS
Show, Typeable)

-- | Change or remove the Amazon SNS notification topic to which notification
-- of the given type are published.
data SetIdentityNotificationTopic =
    SetIdentityNotificationTopic
      { SetIdentityNotificationTopic -> Text
sntIdentity         :: Text
      -- ^ The identity for which the SNS topic will be changed.
      , SetIdentityNotificationTopic -> NotificationType
sntNotificationType :: NotificationType
      -- ^ The type of notifications that will be published to the topic.
      , SetIdentityNotificationTopic -> Maybe Text
sntSnsTopic         :: Maybe Text
      -- ^ @Just@ the ARN of the SNS topic or @Nothing@ to unset the topic.
      }
    deriving (SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
(SetIdentityNotificationTopic
 -> SetIdentityNotificationTopic -> Bool)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> Bool)
-> Eq SetIdentityNotificationTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
== :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$c/= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
/= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
Eq, Eq SetIdentityNotificationTopic
Eq SetIdentityNotificationTopic =>
(SetIdentityNotificationTopic
 -> SetIdentityNotificationTopic -> Ordering)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> Bool)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> Bool)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> Bool)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> Bool)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> SetIdentityNotificationTopic)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> SetIdentityNotificationTopic)
-> Ord SetIdentityNotificationTopic
SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Ordering
SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Ordering
compare :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Ordering
$c< :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
< :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$c<= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
<= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$c> :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
> :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$c>= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
>= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$cmax :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
max :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
$cmin :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
min :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
Ord, Int -> SetIdentityNotificationTopic -> ShowS
[SetIdentityNotificationTopic] -> ShowS
SetIdentityNotificationTopic -> String
(Int -> SetIdentityNotificationTopic -> ShowS)
-> (SetIdentityNotificationTopic -> String)
-> ([SetIdentityNotificationTopic] -> ShowS)
-> Show SetIdentityNotificationTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetIdentityNotificationTopic -> ShowS
showsPrec :: Int -> SetIdentityNotificationTopic -> ShowS
$cshow :: SetIdentityNotificationTopic -> String
show :: SetIdentityNotificationTopic -> String
$cshowList :: [SetIdentityNotificationTopic] -> ShowS
showList :: [SetIdentityNotificationTopic] -> ShowS
Show, Typeable)

-- | ServiceConfiguration: 'SesConfiguration'
instance SignQuery SetIdentityNotificationTopic where
    type ServiceConfiguration SetIdentityNotificationTopic = SesConfiguration
    signQuery :: forall queryType.
SetIdentityNotificationTopic
-> ServiceConfiguration SetIdentityNotificationTopic queryType
-> SignatureData
-> SignedQuery
signQuery SetIdentityNotificationTopic{Maybe Text
Text
NotificationType
sntIdentity :: SetIdentityNotificationTopic -> Text
sntNotificationType :: SetIdentityNotificationTopic -> NotificationType
sntSnsTopic :: SetIdentityNotificationTopic -> Maybe Text
sntIdentity :: Text
sntNotificationType :: NotificationType
sntSnsTopic :: Maybe Text
..} =
        let notificationType :: ByteString
notificationType = case NotificationType
sntNotificationType of
                                  NotificationType
Bounce    -> ByteString
"Bounce"
                                  NotificationType
Complaint -> ByteString
"Complaint"
            snsTopic :: Maybe (ByteString, ByteString)
snsTopic = (ByteString
"SnsTopic",) (ByteString -> (ByteString, ByteString))
-> (Text -> ByteString) -> Text -> (ByteString, ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
T.encodeUtf8 (Text -> (ByteString, ByteString))
-> Maybe Text -> Maybe (ByteString, ByteString)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
sntSnsTopic
        in [(ByteString, ByteString)]
-> SesConfiguration queryType -> SignatureData -> SignedQuery
forall qt.
[(ByteString, ByteString)]
-> SesConfiguration qt -> SignatureData -> SignedQuery
sesSignQuery ([(ByteString, ByteString)]
 -> SesConfiguration queryType -> SignatureData -> SignedQuery)
-> [(ByteString, ByteString)]
-> SesConfiguration queryType
-> SignatureData
-> SignedQuery
forall a b. (a -> b) -> a -> b
$ [ (ByteString
"Action", ByteString
"SetIdentityNotificationTopic")
                          , (ByteString
"Identity",     Text -> ByteString
T.encodeUtf8 Text
sntIdentity)
                          , (ByteString
"NotificationType",     ByteString
notificationType)
                          ] [(ByteString, ByteString)]
-> [(ByteString, ByteString)] -> [(ByteString, ByteString)]
forall a. [a] -> [a] -> [a]
++ Maybe (ByteString, ByteString) -> [(ByteString, ByteString)]
forall a. Maybe a -> [a]
maybeToList Maybe (ByteString, ByteString)
snsTopic

-- | The response sent back by SES after the 'SetIdentityNotificationTopic'
-- command.
data SetIdentityNotificationTopicResponse = SetIdentityNotificationTopicResponse
    deriving (SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
(SetIdentityNotificationTopicResponse
 -> SetIdentityNotificationTopicResponse -> Bool)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse -> Bool)
-> Eq SetIdentityNotificationTopicResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
== :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c/= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
/= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
Eq, Eq SetIdentityNotificationTopicResponse
Eq SetIdentityNotificationTopicResponse =>
(SetIdentityNotificationTopicResponse
 -> SetIdentityNotificationTopicResponse -> Ordering)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse -> Bool)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse -> Bool)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse -> Bool)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse -> Bool)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse)
-> (SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse
    -> SetIdentityNotificationTopicResponse)
-> Ord SetIdentityNotificationTopicResponse
SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Ordering
SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Ordering
compare :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Ordering
$c< :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
< :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c<= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
<= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c> :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
> :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c>= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
>= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$cmax :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
max :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
$cmin :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
min :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
Ord, Int -> SetIdentityNotificationTopicResponse -> ShowS
[SetIdentityNotificationTopicResponse] -> ShowS
SetIdentityNotificationTopicResponse -> String
(Int -> SetIdentityNotificationTopicResponse -> ShowS)
-> (SetIdentityNotificationTopicResponse -> String)
-> ([SetIdentityNotificationTopicResponse] -> ShowS)
-> Show SetIdentityNotificationTopicResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetIdentityNotificationTopicResponse -> ShowS
showsPrec :: Int -> SetIdentityNotificationTopicResponse -> ShowS
$cshow :: SetIdentityNotificationTopicResponse -> String
show :: SetIdentityNotificationTopicResponse -> String
$cshowList :: [SetIdentityNotificationTopicResponse] -> ShowS
showList :: [SetIdentityNotificationTopicResponse] -> ShowS
Show, Typeable)

instance ResponseConsumer SetIdentityNotificationTopic SetIdentityNotificationTopicResponse where
    type ResponseMetadata SetIdentityNotificationTopicResponse = SesMetadata
    responseConsumer :: Request
-> SetIdentityNotificationTopic
-> IORef (ResponseMetadata SetIdentityNotificationTopicResponse)
-> HTTPResponseConsumer SetIdentityNotificationTopicResponse
responseConsumer Request
_ SetIdentityNotificationTopic
_
        = (Cursor
 -> Response SesMetadata SetIdentityNotificationTopicResponse)
-> IORef SesMetadata
-> HTTPResponseConsumer SetIdentityNotificationTopicResponse
forall a.
(Cursor -> Response SesMetadata a)
-> IORef SesMetadata -> HTTPResponseConsumer a
sesResponseConsumer ((Cursor
  -> Response SesMetadata SetIdentityNotificationTopicResponse)
 -> IORef SesMetadata
 -> HTTPResponseConsumer SetIdentityNotificationTopicResponse)
-> (Cursor
    -> Response SesMetadata SetIdentityNotificationTopicResponse)
-> IORef SesMetadata
-> HTTPResponseConsumer SetIdentityNotificationTopicResponse
forall a b. (a -> b) -> a -> b
$ \Cursor
_ -> SetIdentityNotificationTopicResponse
-> Response SesMetadata SetIdentityNotificationTopicResponse
forall a. a -> Response SesMetadata a
forall (m :: * -> *) a. Monad m => a -> m a
return SetIdentityNotificationTopicResponse
SetIdentityNotificationTopicResponse

instance Transaction SetIdentityNotificationTopic SetIdentityNotificationTopicResponse

instance AsMemoryResponse SetIdentityNotificationTopicResponse where
    type MemoryResponse SetIdentityNotificationTopicResponse = SetIdentityNotificationTopicResponse
    loadToMemory :: SetIdentityNotificationTopicResponse
-> ResourceT
     IO (MemoryResponse SetIdentityNotificationTopicResponse)
loadToMemory = SetIdentityNotificationTopicResponse
-> ResourceT
     IO (MemoryResponse SetIdentityNotificationTopicResponse)
SetIdentityNotificationTopicResponse
-> ResourceT IO SetIdentityNotificationTopicResponse
forall a. a -> ResourceT IO a
forall (m :: * -> *) a. Monad m => a -> m a
return