{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
module Aws.Iam.Commands.CreateAccessKey
( CreateAccessKey(..)
, CreateAccessKeyResponse(..)
, AccessKey(..)
) where
import Aws.Core
import Aws.Iam.Core
import Aws.Iam.Internal
import Control.Applicative
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Time
import Data.Typeable
import Prelude
import Text.XML.Cursor (($//))
data CreateAccessKey = CreateAccessKey (Maybe Text)
deriving (CreateAccessKey -> CreateAccessKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAccessKey -> CreateAccessKey -> Bool
$c/= :: CreateAccessKey -> CreateAccessKey -> Bool
== :: CreateAccessKey -> CreateAccessKey -> Bool
$c== :: CreateAccessKey -> CreateAccessKey -> Bool
Eq, Eq CreateAccessKey
CreateAccessKey -> CreateAccessKey -> Bool
CreateAccessKey -> CreateAccessKey -> Ordering
CreateAccessKey -> CreateAccessKey -> CreateAccessKey
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 :: CreateAccessKey -> CreateAccessKey -> CreateAccessKey
$cmin :: CreateAccessKey -> CreateAccessKey -> CreateAccessKey
max :: CreateAccessKey -> CreateAccessKey -> CreateAccessKey
$cmax :: CreateAccessKey -> CreateAccessKey -> CreateAccessKey
>= :: CreateAccessKey -> CreateAccessKey -> Bool
$c>= :: CreateAccessKey -> CreateAccessKey -> Bool
> :: CreateAccessKey -> CreateAccessKey -> Bool
$c> :: CreateAccessKey -> CreateAccessKey -> Bool
<= :: CreateAccessKey -> CreateAccessKey -> Bool
$c<= :: CreateAccessKey -> CreateAccessKey -> Bool
< :: CreateAccessKey -> CreateAccessKey -> Bool
$c< :: CreateAccessKey -> CreateAccessKey -> Bool
compare :: CreateAccessKey -> CreateAccessKey -> Ordering
$ccompare :: CreateAccessKey -> CreateAccessKey -> Ordering
Ord, Int -> CreateAccessKey -> ShowS
[CreateAccessKey] -> ShowS
CreateAccessKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAccessKey] -> ShowS
$cshowList :: [CreateAccessKey] -> ShowS
show :: CreateAccessKey -> String
$cshow :: CreateAccessKey -> String
showsPrec :: Int -> CreateAccessKey -> ShowS
$cshowsPrec :: Int -> CreateAccessKey -> ShowS
Show, Typeable)
instance SignQuery CreateAccessKey where
type ServiceConfiguration CreateAccessKey = IamConfiguration
signQuery :: forall queryType.
CreateAccessKey
-> ServiceConfiguration CreateAccessKey queryType
-> SignatureData
-> SignedQuery
signQuery (CreateAccessKey Maybe Text
user)
= forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"CreateAccessKey" [(ByteString
"UserName",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
user]
data AccessKey
= AccessKey {
AccessKey -> Text
akAccessKeyId :: Text
, AccessKey -> Maybe UTCTime
akCreateDate :: Maybe UTCTime
, AccessKey -> Text
akSecretAccessKey :: Text
, AccessKey -> AccessKeyStatus
akStatus :: AccessKeyStatus
, AccessKey -> Text
akUserName :: Text
}
deriving (AccessKey -> AccessKey -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessKey -> AccessKey -> Bool
$c/= :: AccessKey -> AccessKey -> Bool
== :: AccessKey -> AccessKey -> Bool
$c== :: AccessKey -> AccessKey -> Bool
Eq, Eq AccessKey
AccessKey -> AccessKey -> Bool
AccessKey -> AccessKey -> Ordering
AccessKey -> AccessKey -> AccessKey
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 :: AccessKey -> AccessKey -> AccessKey
$cmin :: AccessKey -> AccessKey -> AccessKey
max :: AccessKey -> AccessKey -> AccessKey
$cmax :: AccessKey -> AccessKey -> AccessKey
>= :: AccessKey -> AccessKey -> Bool
$c>= :: AccessKey -> AccessKey -> Bool
> :: AccessKey -> AccessKey -> Bool
$c> :: AccessKey -> AccessKey -> Bool
<= :: AccessKey -> AccessKey -> Bool
$c<= :: AccessKey -> AccessKey -> Bool
< :: AccessKey -> AccessKey -> Bool
$c< :: AccessKey -> AccessKey -> Bool
compare :: AccessKey -> AccessKey -> Ordering
$ccompare :: AccessKey -> AccessKey -> Ordering
Ord, Int -> AccessKey -> ShowS
[AccessKey] -> ShowS
AccessKey -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessKey] -> ShowS
$cshowList :: [AccessKey] -> ShowS
show :: AccessKey -> String
$cshow :: AccessKey -> String
showsPrec :: Int -> AccessKey -> ShowS
$cshowsPrec :: Int -> AccessKey -> ShowS
Show, Typeable)
data CreateAccessKeyResponse
= CreateAccessKeyResponse AccessKey
deriving (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
$c/= :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
== :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
$c== :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
Eq, Eq CreateAccessKeyResponse
CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
CreateAccessKeyResponse -> CreateAccessKeyResponse -> Ordering
CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse
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 :: CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse
$cmin :: CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse
max :: CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse
$cmax :: CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse
>= :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
$c>= :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
> :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
$c> :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
<= :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
$c<= :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
< :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
$c< :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool
compare :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Ordering
$ccompare :: CreateAccessKeyResponse -> CreateAccessKeyResponse -> Ordering
Ord, Int -> CreateAccessKeyResponse -> ShowS
[CreateAccessKeyResponse] -> ShowS
CreateAccessKeyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAccessKeyResponse] -> ShowS
$cshowList :: [CreateAccessKeyResponse] -> ShowS
show :: CreateAccessKeyResponse -> String
$cshow :: CreateAccessKeyResponse -> String
showsPrec :: Int -> CreateAccessKeyResponse -> ShowS
$cshowsPrec :: Int -> CreateAccessKeyResponse -> ShowS
Show, Typeable)
instance ResponseConsumer CreateAccessKey CreateAccessKeyResponse where
type ResponseMetadata CreateAccessKeyResponse = IamMetadata
responseConsumer :: Request
-> CreateAccessKey
-> IORef (ResponseMetadata CreateAccessKeyResponse)
-> HTTPResponseConsumer CreateAccessKeyResponse
responseConsumer Request
_ CreateAccessKey
_
= forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
let attr :: Text -> Response IamMetadata Text
attr Text
name = forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force (String
"Missing " forall a. [a] -> [a] -> [a]
++ Text -> String
Text.unpack Text
name) forall a b. (a -> b) -> a -> b
$
Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [Text]
elContent Text
name
Text
akAccessKeyId <- Text -> Response IamMetadata Text
attr Text
"AccessKeyId"
Text
akSecretAccessKey <- Text -> Response IamMetadata Text
attr Text
"SecretAccessKey"
AccessKeyStatus
akStatus <- Text -> AccessKeyStatus
readAccessKeyStatus forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Response IamMetadata Text
attr Text
"Status"
Text
akUserName <- Text -> Response IamMetadata Text
attr Text
"UserName"
Maybe UTCTime
akCreateDate <- forall {f :: * -> *}. MonadThrow f => Cursor -> f (Maybe UTCTime)
readDate Cursor
cursor
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ AccessKey -> CreateAccessKeyResponse
CreateAccessKeyResponse AccessKey{Maybe UTCTime
Text
AccessKeyStatus
akCreateDate :: Maybe UTCTime
akUserName :: Text
akStatus :: AccessKeyStatus
akSecretAccessKey :: Text
akAccessKeyId :: Text
akUserName :: Text
akStatus :: AccessKeyStatus
akSecretAccessKey :: Text
akCreateDate :: Maybe UTCTime
akAccessKeyId :: Text
..}
where
readDate :: Cursor -> f (Maybe UTCTime)
readDate Cursor
c = case Cursor
c forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [String]
elCont Text
"CreateDate" of
(String
x:[String]
_) -> forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). MonadThrow m => String -> m UTCTime
parseDateTime String
x
[String]
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
readAccessKeyStatus :: Text -> AccessKeyStatus
readAccessKeyStatus Text
s
| Text -> Text
Text.toCaseFold Text
s forall a. Eq a => a -> a -> Bool
== Text
"Active" = AccessKeyStatus
AccessKeyActive
| Bool
otherwise = AccessKeyStatus
AccessKeyInactive
instance Transaction CreateAccessKey CreateAccessKeyResponse
instance AsMemoryResponse CreateAccessKeyResponse where
type MemoryResponse CreateAccessKeyResponse = CreateAccessKeyResponse
loadToMemory :: CreateAccessKeyResponse
-> ResourceT IO (MemoryResponse CreateAccessKeyResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return