module Aws.Ses.Commands.VerifyDomainIdentity
    ( VerifyDomainIdentity(..)
    , VerifyDomainIdentityResponse(..)
    ) where

import Data.Text (Text)
import Data.Text.Encoding as T (encodeUtf8)
import Data.Typeable
import Aws.Core
import Aws.Ses.Core
import Text.XML.Cursor (($//))

-- | Verify ownership of a domain.
data VerifyDomainIdentity  = VerifyDomainIdentity Text
    deriving (VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
(VerifyDomainIdentity -> VerifyDomainIdentity -> Bool)
-> (VerifyDomainIdentity -> VerifyDomainIdentity -> Bool)
-> Eq VerifyDomainIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
== :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
$c/= :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
/= :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
Eq, Eq VerifyDomainIdentity
Eq VerifyDomainIdentity =>
(VerifyDomainIdentity -> VerifyDomainIdentity -> Ordering)
-> (VerifyDomainIdentity -> VerifyDomainIdentity -> Bool)
-> (VerifyDomainIdentity -> VerifyDomainIdentity -> Bool)
-> (VerifyDomainIdentity -> VerifyDomainIdentity -> Bool)
-> (VerifyDomainIdentity -> VerifyDomainIdentity -> Bool)
-> (VerifyDomainIdentity
    -> VerifyDomainIdentity -> VerifyDomainIdentity)
-> (VerifyDomainIdentity
    -> VerifyDomainIdentity -> VerifyDomainIdentity)
-> Ord VerifyDomainIdentity
VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
VerifyDomainIdentity -> VerifyDomainIdentity -> Ordering
VerifyDomainIdentity
-> VerifyDomainIdentity -> VerifyDomainIdentity
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 :: VerifyDomainIdentity -> VerifyDomainIdentity -> Ordering
compare :: VerifyDomainIdentity -> VerifyDomainIdentity -> Ordering
$c< :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
< :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
$c<= :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
<= :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
$c> :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
> :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
$c>= :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
>= :: VerifyDomainIdentity -> VerifyDomainIdentity -> Bool
$cmax :: VerifyDomainIdentity
-> VerifyDomainIdentity -> VerifyDomainIdentity
max :: VerifyDomainIdentity
-> VerifyDomainIdentity -> VerifyDomainIdentity
$cmin :: VerifyDomainIdentity
-> VerifyDomainIdentity -> VerifyDomainIdentity
min :: VerifyDomainIdentity
-> VerifyDomainIdentity -> VerifyDomainIdentity
Ord, Int -> VerifyDomainIdentity -> ShowS
[VerifyDomainIdentity] -> ShowS
VerifyDomainIdentity -> String
(Int -> VerifyDomainIdentity -> ShowS)
-> (VerifyDomainIdentity -> String)
-> ([VerifyDomainIdentity] -> ShowS)
-> Show VerifyDomainIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VerifyDomainIdentity -> ShowS
showsPrec :: Int -> VerifyDomainIdentity -> ShowS
$cshow :: VerifyDomainIdentity -> String
show :: VerifyDomainIdentity -> String
$cshowList :: [VerifyDomainIdentity] -> ShowS
showList :: [VerifyDomainIdentity] -> ShowS
Show, Typeable)

-- | ServiceConfiguration: 'SesConfiguration'
instance SignQuery VerifyDomainIdentity where
    type ServiceConfiguration VerifyDomainIdentity = SesConfiguration
    signQuery :: forall queryType.
VerifyDomainIdentity
-> ServiceConfiguration VerifyDomainIdentity queryType
-> SignatureData
-> SignedQuery
signQuery (VerifyDomainIdentity Text
domain) =
        [(ByteString, ByteString)]
-> SesConfiguration queryType -> SignatureData -> SignedQuery
forall qt.
[(ByteString, ByteString)]
-> SesConfiguration qt -> SignatureData -> SignedQuery
sesSignQuery [ (ByteString
"Action", ByteString
"VerifyDomainIdentity")
                     , (ByteString
"Domain", Text -> ByteString
T.encodeUtf8 Text
domain)
                     ]

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

instance ResponseConsumer VerifyDomainIdentity VerifyDomainIdentityResponse where
    type ResponseMetadata VerifyDomainIdentityResponse = SesMetadata
    responseConsumer :: Request
-> VerifyDomainIdentity
-> IORef (ResponseMetadata VerifyDomainIdentityResponse)
-> HTTPResponseConsumer VerifyDomainIdentityResponse
responseConsumer Request
_ VerifyDomainIdentity
_ =
      (Cursor -> Response SesMetadata VerifyDomainIdentityResponse)
-> IORef SesMetadata
-> HTTPResponseConsumer VerifyDomainIdentityResponse
forall a.
(Cursor -> Response SesMetadata a)
-> IORef SesMetadata -> HTTPResponseConsumer a
sesResponseConsumer ((Cursor -> Response SesMetadata VerifyDomainIdentityResponse)
 -> IORef SesMetadata
 -> HTTPResponseConsumer VerifyDomainIdentityResponse)
-> (Cursor -> Response SesMetadata VerifyDomainIdentityResponse)
-> IORef SesMetadata
-> HTTPResponseConsumer VerifyDomainIdentityResponse
forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
        Text
token <- String -> [Text] -> Response SesMetadata Text
forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Verification token not found" ([Text] -> Response SesMetadata Text)
-> [Text] -> Response SesMetadata Text
forall a b. (a -> b) -> a -> b
$ Cursor
cursor Cursor -> (Cursor -> [Text]) -> [Text]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [Text]
elContent Text
"VerificationToken"
        VerifyDomainIdentityResponse
-> Response SesMetadata VerifyDomainIdentityResponse
forall a. a -> Response SesMetadata a
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> VerifyDomainIdentityResponse
VerifyDomainIdentityResponse Text
token)

instance Transaction VerifyDomainIdentity VerifyDomainIdentityResponse where

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