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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NotificationType -> NotificationType -> Bool
$c/= :: NotificationType -> NotificationType -> Bool
== :: NotificationType -> NotificationType -> Bool
$c== :: NotificationType -> NotificationType -> Bool
Eq, Eq 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
min :: NotificationType -> NotificationType -> NotificationType
$cmin :: NotificationType -> NotificationType -> NotificationType
max :: NotificationType -> NotificationType -> NotificationType
$cmax :: NotificationType -> NotificationType -> NotificationType
>= :: NotificationType -> NotificationType -> Bool
$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
compare :: NotificationType -> NotificationType -> Ordering
$ccompare :: NotificationType -> NotificationType -> Ordering
Ord, Int -> NotificationType -> ShowS
[NotificationType] -> ShowS
NotificationType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NotificationType] -> ShowS
$cshowList :: [NotificationType] -> ShowS
show :: NotificationType -> String
$cshow :: NotificationType -> String
showsPrec :: Int -> NotificationType -> ShowS
$cshowsPrec :: Int -> 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$c/= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
== :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$c== :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
Eq, Eq 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
min :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
$cmin :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
max :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
$cmax :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> SetIdentityNotificationTopic
>= :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Bool
$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
compare :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Ordering
$ccompare :: SetIdentityNotificationTopic
-> SetIdentityNotificationTopic -> Ordering
Ord, Int -> SetIdentityNotificationTopic -> ShowS
[SetIdentityNotificationTopic] -> ShowS
SetIdentityNotificationTopic -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetIdentityNotificationTopic] -> ShowS
$cshowList :: [SetIdentityNotificationTopic] -> ShowS
show :: SetIdentityNotificationTopic -> String
$cshow :: SetIdentityNotificationTopic -> String
showsPrec :: Int -> SetIdentityNotificationTopic -> ShowS
$cshowsPrec :: Int -> 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
sntSnsTopic :: Maybe Text
sntNotificationType :: NotificationType
sntIdentity :: Text
sntSnsTopic :: SetIdentityNotificationTopic -> Maybe Text
sntNotificationType :: SetIdentityNotificationTopic -> NotificationType
sntIdentity :: SetIdentityNotificationTopic -> Text
..} =
        let notificationType :: ByteString
notificationType = case NotificationType
sntNotificationType of
                                  NotificationType
Bounce    -> ByteString
"Bounce"
                                  NotificationType
Complaint -> ByteString
"Complaint"
            snsTopic :: Maybe (ByteString, ByteString)
snsTopic = (ByteString
"SnsTopic",) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
sntSnsTopic
        in forall qt.
[(ByteString, ByteString)]
-> SesConfiguration qt -> SignatureData -> SignedQuery
sesSignQuery forall a b. (a -> b) -> a -> b
$ [ (ByteString
"Action", ByteString
"SetIdentityNotificationTopic")
                          , (ByteString
"Identity",     Text -> ByteString
T.encodeUtf8 Text
sntIdentity)
                          , (ByteString
"NotificationType",     ByteString
notificationType)
                          ] forall a. [a] -> [a] -> [a]
++ 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c/= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
== :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c== :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
Eq, Eq 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
min :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
$cmin :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
max :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
$cmax :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse
>= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$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
compare :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Ordering
$ccompare :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Ordering
Ord, Int -> SetIdentityNotificationTopicResponse -> ShowS
[SetIdentityNotificationTopicResponse] -> ShowS
SetIdentityNotificationTopicResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetIdentityNotificationTopicResponse] -> ShowS
$cshowList :: [SetIdentityNotificationTopicResponse] -> ShowS
show :: SetIdentityNotificationTopicResponse -> String
$cshow :: SetIdentityNotificationTopicResponse -> String
showsPrec :: Int -> SetIdentityNotificationTopicResponse -> ShowS
$cshowsPrec :: Int -> SetIdentityNotificationTopicResponse -> ShowS
Show, Typeable)

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