{-# 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
(CreateAccessKey -> CreateAccessKey -> Bool)
-> (CreateAccessKey -> CreateAccessKey -> Bool)
-> Eq CreateAccessKey
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
Eq CreateAccessKey
-> (CreateAccessKey -> CreateAccessKey -> Ordering)
-> (CreateAccessKey -> CreateAccessKey -> Bool)
-> (CreateAccessKey -> CreateAccessKey -> Bool)
-> (CreateAccessKey -> CreateAccessKey -> Bool)
-> (CreateAccessKey -> CreateAccessKey -> Bool)
-> (CreateAccessKey -> CreateAccessKey -> CreateAccessKey)
-> (CreateAccessKey -> CreateAccessKey -> CreateAccessKey)
-> Ord 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
$cp1Ord :: Eq CreateAccessKey
Ord, Int -> CreateAccessKey -> ShowS
[CreateAccessKey] -> ShowS
CreateAccessKey -> String
(Int -> CreateAccessKey -> ShowS)
-> (CreateAccessKey -> String)
-> ([CreateAccessKey] -> ShowS)
-> Show CreateAccessKey
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 :: CreateAccessKey
-> ServiceConfiguration CreateAccessKey queryType
-> SignatureData
-> SignedQuery
signQuery (CreateAccessKey Maybe Text
user)
= ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"CreateAccessKey" [(ByteString
"UserName",) (Text -> (ByteString, Text))
-> Maybe Text -> Maybe (ByteString, Text)
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
(AccessKey -> AccessKey -> Bool)
-> (AccessKey -> AccessKey -> Bool) -> Eq AccessKey
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
Eq AccessKey
-> (AccessKey -> AccessKey -> Ordering)
-> (AccessKey -> AccessKey -> Bool)
-> (AccessKey -> AccessKey -> Bool)
-> (AccessKey -> AccessKey -> Bool)
-> (AccessKey -> AccessKey -> Bool)
-> (AccessKey -> AccessKey -> AccessKey)
-> (AccessKey -> AccessKey -> AccessKey)
-> Ord 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
$cp1Ord :: Eq AccessKey
Ord, Int -> AccessKey -> ShowS
[AccessKey] -> ShowS
AccessKey -> String
(Int -> AccessKey -> ShowS)
-> (AccessKey -> String)
-> ([AccessKey] -> ShowS)
-> Show AccessKey
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
(CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool)
-> (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool)
-> Eq CreateAccessKeyResponse
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
Eq CreateAccessKeyResponse
-> (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Ordering)
-> (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool)
-> (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool)
-> (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool)
-> (CreateAccessKeyResponse -> CreateAccessKeyResponse -> Bool)
-> (CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse)
-> (CreateAccessKeyResponse
-> CreateAccessKeyResponse -> CreateAccessKeyResponse)
-> Ord 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
$cp1Ord :: Eq CreateAccessKeyResponse
Ord, Int -> CreateAccessKeyResponse -> ShowS
[CreateAccessKeyResponse] -> ShowS
CreateAccessKeyResponse -> String
(Int -> CreateAccessKeyResponse -> ShowS)
-> (CreateAccessKeyResponse -> String)
-> ([CreateAccessKeyResponse] -> ShowS)
-> Show CreateAccessKeyResponse
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
_
= (Cursor -> Response IamMetadata CreateAccessKeyResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer CreateAccessKeyResponse
forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer ((Cursor -> Response IamMetadata CreateAccessKeyResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer CreateAccessKeyResponse)
-> (Cursor -> Response IamMetadata CreateAccessKeyResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer CreateAccessKeyResponse
forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
let attr :: Text -> Response IamMetadata Text
attr Text
name = String -> [Text] -> Response IamMetadata Text
forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force (String
"Missing " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> String
Text.unpack Text
name) ([Text] -> Response IamMetadata Text)
-> [Text] -> Response IamMetadata 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
name
Text
akAccessKeyId <- Text -> Response IamMetadata Text
attr Text
"AccessKeyId"
Text
akSecretAccessKey <- Text -> Response IamMetadata Text
attr Text
"SecretAccessKey"
AccessKeyStatus
akStatus <- Text -> AccessKeyStatus
readAccessKeyStatus (Text -> AccessKeyStatus)
-> Response IamMetadata Text
-> Response IamMetadata AccessKeyStatus
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 <- Cursor -> Response IamMetadata (Maybe UTCTime)
forall (f :: * -> *). MonadThrow f => Cursor -> f (Maybe UTCTime)
readDate Cursor
cursor
CreateAccessKeyResponse
-> Response IamMetadata CreateAccessKeyResponse
forall (m :: * -> *) a. Monad m => a -> m a
return (CreateAccessKeyResponse
-> Response IamMetadata CreateAccessKeyResponse)
-> CreateAccessKeyResponse
-> Response IamMetadata CreateAccessKeyResponse
forall a b. (a -> b) -> a -> b
$ AccessKey -> CreateAccessKeyResponse
CreateAccessKeyResponse AccessKey :: Text
-> Maybe UTCTime -> Text -> AccessKeyStatus -> Text -> AccessKey
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 Cursor -> (Cursor -> [String]) -> [String]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [String]
elCont Text
"CreateDate" of
(String
x:[String]
_) -> UTCTime -> Maybe UTCTime
forall a. a -> Maybe a
Just (UTCTime -> Maybe UTCTime) -> f UTCTime -> f (Maybe UTCTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> f UTCTime
forall (m :: * -> *). MonadThrow m => String -> m UTCTime
parseDateTime String
x
[String]
_ -> Maybe UTCTime -> f (Maybe UTCTime)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe UTCTime
forall a. Maybe a
Nothing
readAccessKeyStatus :: Text -> AccessKeyStatus
readAccessKeyStatus Text
s
| Text -> Text
Text.toCaseFold Text
s Text -> Text -> Bool
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 = CreateAccessKeyResponse
-> ResourceT IO (MemoryResponse CreateAccessKeyResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return