{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.IAM.CreateAccessKey
(
CreateAccessKey (..),
newCreateAccessKey,
createAccessKey_userName,
CreateAccessKeyResponse (..),
newCreateAccessKeyResponse,
createAccessKeyResponse_httpStatus,
createAccessKeyResponse_accessKey,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateAccessKey = CreateAccessKey'
{
CreateAccessKey -> Maybe Text
userName :: Prelude.Maybe Prelude.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
Prelude.Eq, ReadPrec [CreateAccessKey]
ReadPrec CreateAccessKey
Int -> ReadS CreateAccessKey
ReadS [CreateAccessKey]
(Int -> ReadS CreateAccessKey)
-> ReadS [CreateAccessKey]
-> ReadPrec CreateAccessKey
-> ReadPrec [CreateAccessKey]
-> Read CreateAccessKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAccessKey]
$creadListPrec :: ReadPrec [CreateAccessKey]
readPrec :: ReadPrec CreateAccessKey
$creadPrec :: ReadPrec CreateAccessKey
readList :: ReadS [CreateAccessKey]
$creadList :: ReadS [CreateAccessKey]
readsPrec :: Int -> ReadS CreateAccessKey
$creadsPrec :: Int -> ReadS CreateAccessKey
Prelude.Read, 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
Prelude.Show, (forall x. CreateAccessKey -> Rep CreateAccessKey x)
-> (forall x. Rep CreateAccessKey x -> CreateAccessKey)
-> Generic CreateAccessKey
forall x. Rep CreateAccessKey x -> CreateAccessKey
forall x. CreateAccessKey -> Rep CreateAccessKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAccessKey x -> CreateAccessKey
$cfrom :: forall x. CreateAccessKey -> Rep CreateAccessKey x
Prelude.Generic)
newCreateAccessKey ::
CreateAccessKey
newCreateAccessKey :: CreateAccessKey
newCreateAccessKey =
CreateAccessKey' :: Maybe Text -> CreateAccessKey
CreateAccessKey' {$sel:userName:CreateAccessKey' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing}
createAccessKey_userName :: Lens.Lens' CreateAccessKey (Prelude.Maybe Prelude.Text)
createAccessKey_userName :: (Maybe Text -> f (Maybe Text))
-> CreateAccessKey -> f CreateAccessKey
createAccessKey_userName = (CreateAccessKey -> Maybe Text)
-> (CreateAccessKey -> Maybe Text -> CreateAccessKey)
-> Lens CreateAccessKey CreateAccessKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccessKey' {Maybe Text
userName :: Maybe Text
$sel:userName:CreateAccessKey' :: CreateAccessKey -> Maybe Text
userName} -> Maybe Text
userName) (\s :: CreateAccessKey
s@CreateAccessKey' {} Maybe Text
a -> CreateAccessKey
s {$sel:userName:CreateAccessKey' :: Maybe Text
userName = Maybe Text
a} :: CreateAccessKey)
instance Core.AWSRequest CreateAccessKey where
type
AWSResponse CreateAccessKey =
CreateAccessKeyResponse
request :: CreateAccessKey -> Request CreateAccessKey
request = Service -> CreateAccessKey -> Request CreateAccessKey
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy CreateAccessKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAccessKey)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse CreateAccessKey))
-> Logger
-> Service
-> Proxy CreateAccessKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAccessKey)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"CreateAccessKeyResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Int -> AccessKeyInfo -> CreateAccessKeyResponse
CreateAccessKeyResponse'
(Int -> AccessKeyInfo -> CreateAccessKeyResponse)
-> Either String Int
-> Either String (AccessKeyInfo -> CreateAccessKeyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
Either String (AccessKeyInfo -> CreateAccessKeyResponse)
-> Either String AccessKeyInfo
-> Either String CreateAccessKeyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String AccessKeyInfo
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"AccessKey")
)
instance Prelude.Hashable CreateAccessKey
instance Prelude.NFData CreateAccessKey
instance Core.ToHeaders CreateAccessKey where
toHeaders :: CreateAccessKey -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateAccessKey -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath CreateAccessKey where
toPath :: CreateAccessKey -> ByteString
toPath = ByteString -> CreateAccessKey -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateAccessKey where
toQuery :: CreateAccessKey -> QueryString
toQuery CreateAccessKey' {Maybe Text
userName :: Maybe Text
$sel:userName:CreateAccessKey' :: CreateAccessKey -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"CreateAccessKey" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
ByteString
"UserName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
userName
]
data CreateAccessKeyResponse = CreateAccessKeyResponse'
{
CreateAccessKeyResponse -> Int
httpStatus :: Prelude.Int,
CreateAccessKeyResponse -> AccessKeyInfo
accessKey :: AccessKeyInfo
}
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
Prelude.Eq, 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
Prelude.Show, (forall x.
CreateAccessKeyResponse -> Rep CreateAccessKeyResponse x)
-> (forall x.
Rep CreateAccessKeyResponse x -> CreateAccessKeyResponse)
-> Generic CreateAccessKeyResponse
forall x. Rep CreateAccessKeyResponse x -> CreateAccessKeyResponse
forall x. CreateAccessKeyResponse -> Rep CreateAccessKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAccessKeyResponse x -> CreateAccessKeyResponse
$cfrom :: forall x. CreateAccessKeyResponse -> Rep CreateAccessKeyResponse x
Prelude.Generic)
newCreateAccessKeyResponse ::
Prelude.Int ->
AccessKeyInfo ->
CreateAccessKeyResponse
newCreateAccessKeyResponse :: Int -> AccessKeyInfo -> CreateAccessKeyResponse
newCreateAccessKeyResponse Int
pHttpStatus_ AccessKeyInfo
pAccessKey_ =
CreateAccessKeyResponse' :: Int -> AccessKeyInfo -> CreateAccessKeyResponse
CreateAccessKeyResponse'
{ $sel:httpStatus:CreateAccessKeyResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:accessKey:CreateAccessKeyResponse' :: AccessKeyInfo
accessKey = AccessKeyInfo
pAccessKey_
}
createAccessKeyResponse_httpStatus :: Lens.Lens' CreateAccessKeyResponse Prelude.Int
createAccessKeyResponse_httpStatus :: (Int -> f Int)
-> CreateAccessKeyResponse -> f CreateAccessKeyResponse
createAccessKeyResponse_httpStatus = (CreateAccessKeyResponse -> Int)
-> (CreateAccessKeyResponse -> Int -> CreateAccessKeyResponse)
-> Lens CreateAccessKeyResponse CreateAccessKeyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccessKeyResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateAccessKeyResponse' :: CreateAccessKeyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateAccessKeyResponse
s@CreateAccessKeyResponse' {} Int
a -> CreateAccessKeyResponse
s {$sel:httpStatus:CreateAccessKeyResponse' :: Int
httpStatus = Int
a} :: CreateAccessKeyResponse)
createAccessKeyResponse_accessKey :: Lens.Lens' CreateAccessKeyResponse AccessKeyInfo
createAccessKeyResponse_accessKey :: (AccessKeyInfo -> f AccessKeyInfo)
-> CreateAccessKeyResponse -> f CreateAccessKeyResponse
createAccessKeyResponse_accessKey = (CreateAccessKeyResponse -> AccessKeyInfo)
-> (CreateAccessKeyResponse
-> AccessKeyInfo -> CreateAccessKeyResponse)
-> Lens
CreateAccessKeyResponse
CreateAccessKeyResponse
AccessKeyInfo
AccessKeyInfo
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAccessKeyResponse' {AccessKeyInfo
accessKey :: AccessKeyInfo
$sel:accessKey:CreateAccessKeyResponse' :: CreateAccessKeyResponse -> AccessKeyInfo
accessKey} -> AccessKeyInfo
accessKey) (\s :: CreateAccessKeyResponse
s@CreateAccessKeyResponse' {} AccessKeyInfo
a -> CreateAccessKeyResponse
s {$sel:accessKey:CreateAccessKeyResponse' :: AccessKeyInfo
accessKey = AccessKeyInfo
a} :: CreateAccessKeyResponse)
instance Prelude.NFData CreateAccessKeyResponse