module Aws.Ses.Commands.GetIdentityDkimAttributes
    ( GetIdentityDkimAttributes(..)
    , GetIdentityDkimAttributesResponse(..)
    , IdentityDkimAttributes(..)
    ) where

import qualified Data.ByteString.Char8 as BS
import           Data.Text             (Text)
import           Data.Text             as T (toCaseFold)
import           Data.Text.Encoding    as T (encodeUtf8)
import           Data.Typeable
import           Text.XML.Cursor       (laxElement, ($/), ($//), (&/), (&|))
import           Control.Applicative
import           Prelude

import           Aws.Core
import           Aws.Ses.Core

-- | Get notification settings for the given identities.
data GetIdentityDkimAttributes = GetIdentityDkimAttributes [Text]
    deriving (GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
$c/= :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
== :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
$c== :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
Eq, Eq GetIdentityDkimAttributes
GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Ordering
GetIdentityDkimAttributes
-> GetIdentityDkimAttributes -> GetIdentityDkimAttributes
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 :: GetIdentityDkimAttributes
-> GetIdentityDkimAttributes -> GetIdentityDkimAttributes
$cmin :: GetIdentityDkimAttributes
-> GetIdentityDkimAttributes -> GetIdentityDkimAttributes
max :: GetIdentityDkimAttributes
-> GetIdentityDkimAttributes -> GetIdentityDkimAttributes
$cmax :: GetIdentityDkimAttributes
-> GetIdentityDkimAttributes -> GetIdentityDkimAttributes
>= :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
$c>= :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
> :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
$c> :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
<= :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
$c<= :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
< :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
$c< :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Bool
compare :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Ordering
$ccompare :: GetIdentityDkimAttributes -> GetIdentityDkimAttributes -> Ordering
Ord, Int -> GetIdentityDkimAttributes -> ShowS
[GetIdentityDkimAttributes] -> ShowS
GetIdentityDkimAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIdentityDkimAttributes] -> ShowS
$cshowList :: [GetIdentityDkimAttributes] -> ShowS
show :: GetIdentityDkimAttributes -> String
$cshow :: GetIdentityDkimAttributes -> String
showsPrec :: Int -> GetIdentityDkimAttributes -> ShowS
$cshowsPrec :: Int -> GetIdentityDkimAttributes -> ShowS
Show, Typeable)

-- | ServiceConfiguration: 'SesConfiguration'
instance SignQuery GetIdentityDkimAttributes where
    type ServiceConfiguration GetIdentityDkimAttributes = SesConfiguration
    signQuery :: forall queryType.
GetIdentityDkimAttributes
-> ServiceConfiguration GetIdentityDkimAttributes queryType
-> SignatureData
-> SignedQuery
signQuery (GetIdentityDkimAttributes [Text]
identities) =
        forall qt.
[(ByteString, ByteString)]
-> SesConfiguration qt -> SignatureData -> SignedQuery
sesSignQuery forall a b. (a -> b) -> a -> b
$ (ByteString
"Action", ByteString
"GetIdentityDkimAttributes")
                     forall a. a -> [a] -> [a]
: forall a b. [a] -> [b] -> [(a, b)]
zip (Int -> ByteString
enumMember forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int
1..]) (Text -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
identities)
            where enumMember :: Int -> ByteString
enumMember (Int
n :: Int) = ByteString -> ByteString -> ByteString
BS.append ByteString
"Identities.member." (String -> ByteString
BS.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
n)


data IdentityDkimAttributes =
    IdentityDkimAttributes
      { IdentityDkimAttributes -> Text
idIdentity                :: Text
      , IdentityDkimAttributes -> Bool
idDkimEnabled             :: Bool
      , IdentityDkimAttributes -> [Text]
idDkimTokens              :: [Text]
      , IdentityDkimAttributes -> Text
idDkimVerirficationStatus :: Text }
    deriving (IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c/= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
== :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c== :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
Eq, Eq IdentityDkimAttributes
IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
IdentityDkimAttributes -> IdentityDkimAttributes -> Ordering
IdentityDkimAttributes
-> IdentityDkimAttributes -> IdentityDkimAttributes
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 :: IdentityDkimAttributes
-> IdentityDkimAttributes -> IdentityDkimAttributes
$cmin :: IdentityDkimAttributes
-> IdentityDkimAttributes -> IdentityDkimAttributes
max :: IdentityDkimAttributes
-> IdentityDkimAttributes -> IdentityDkimAttributes
$cmax :: IdentityDkimAttributes
-> IdentityDkimAttributes -> IdentityDkimAttributes
>= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c>= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
> :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c> :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
<= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c<= :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
< :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
$c< :: IdentityDkimAttributes -> IdentityDkimAttributes -> Bool
compare :: IdentityDkimAttributes -> IdentityDkimAttributes -> Ordering
$ccompare :: IdentityDkimAttributes -> IdentityDkimAttributes -> Ordering
Ord, Int -> IdentityDkimAttributes -> ShowS
[IdentityDkimAttributes] -> ShowS
IdentityDkimAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityDkimAttributes] -> ShowS
$cshowList :: [IdentityDkimAttributes] -> ShowS
show :: IdentityDkimAttributes -> String
$cshow :: IdentityDkimAttributes -> String
showsPrec :: Int -> IdentityDkimAttributes -> ShowS
$cshowsPrec :: Int -> IdentityDkimAttributes -> ShowS
Show, Typeable)

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

instance ResponseConsumer GetIdentityDkimAttributes GetIdentityDkimAttributesResponse where
    type ResponseMetadata GetIdentityDkimAttributesResponse = SesMetadata
    responseConsumer :: Request
-> GetIdentityDkimAttributes
-> IORef (ResponseMetadata GetIdentityDkimAttributesResponse)
-> HTTPResponseConsumer GetIdentityDkimAttributesResponse
responseConsumer Request
_ GetIdentityDkimAttributes
_ = forall a.
(Cursor -> Response SesMetadata a)
-> IORef SesMetadata -> HTTPResponseConsumer a
sesResponseConsumer forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
        let buildAttr :: Cursor -> m IdentityDkimAttributes
buildAttr Cursor
e = do
              Text
idIdentity <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Key" forall a b. (a -> b) -> a -> b
$ Cursor
e forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [Text]
elContent Text
"key"
              Text
enabled <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing DkimEnabled" forall a b. (a -> b) -> a -> b
$ Cursor
e forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [Text]
elContent Text
"DkimEnabled"
              Text
idDkimVerirficationStatus <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing status" forall a b. (a -> b) -> a -> b
$
                                           Cursor
e forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [Text]
elContent Text
"DkimVerificationStatus"
              let idDkimEnabled :: Bool
idDkimEnabled = Text -> Text
T.toCaseFold Text
enabled forall a. Eq a => a -> a -> Bool
== Text -> Text
T.toCaseFold Text
"true"
                  idDkimTokens :: [Text]
idDkimTokens = Cursor
e forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"DkimTokens" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Text -> Cursor -> [Text]
elContent Text
"member"
              forall (m :: * -> *) a. Monad m => a -> m a
return IdentityDkimAttributes{Bool
[Text]
Text
idDkimTokens :: [Text]
idDkimEnabled :: Bool
idDkimVerirficationStatus :: Text
idIdentity :: Text
idDkimVerirficationStatus :: Text
idDkimTokens :: [Text]
idDkimEnabled :: Bool
idIdentity :: Text
..}
        [IdentityDkimAttributes]
attributes <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"entry" forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| forall {m :: * -> *}.
MonadThrow m =>
Cursor -> m IdentityDkimAttributes
buildAttr
        forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [IdentityDkimAttributes] -> GetIdentityDkimAttributesResponse
GetIdentityDkimAttributesResponse [IdentityDkimAttributes]
attributes

instance Transaction GetIdentityDkimAttributes GetIdentityDkimAttributesResponse where

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