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 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
/= :: NotificationType -> NotificationType -> Bool
$c/= :: NotificationType -> NotificationType -> Bool
== :: NotificationType -> NotificationType -> Bool
$c== :: 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
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
$cp1Ord :: Eq 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
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
(SetIdentityNotificationTopic
 -> SetIdentityNotificationTopic -> Bool)
-> (SetIdentityNotificationTopic
    -> SetIdentityNotificationTopic -> Bool)
-> Eq SetIdentityNotificationTopic
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
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
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
$cp1Ord :: Eq 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
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 :: 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",) (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
/= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c/= :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
== :: SetIdentityNotificationTopicResponse
-> SetIdentityNotificationTopicResponse -> Bool
$c== :: 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
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
$cp1Ord :: Eq 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
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
_
        = (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 (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)
forall (m :: * -> *) a. Monad m => a -> m a
return