{-# 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.GetUser
(
GetUser (..),
newGetUser,
getUser_userName,
GetUserResponse (..),
newGetUserResponse,
getUserResponse_httpStatus,
getUserResponse_user,
)
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 GetUser = GetUser'
{
GetUser -> Maybe Text
userName :: Prelude.Maybe Prelude.Text
}
deriving (GetUser -> GetUser -> Bool
(GetUser -> GetUser -> Bool)
-> (GetUser -> GetUser -> Bool) -> Eq GetUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUser -> GetUser -> Bool
$c/= :: GetUser -> GetUser -> Bool
== :: GetUser -> GetUser -> Bool
$c== :: GetUser -> GetUser -> Bool
Prelude.Eq, ReadPrec [GetUser]
ReadPrec GetUser
Int -> ReadS GetUser
ReadS [GetUser]
(Int -> ReadS GetUser)
-> ReadS [GetUser]
-> ReadPrec GetUser
-> ReadPrec [GetUser]
-> Read GetUser
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUser]
$creadListPrec :: ReadPrec [GetUser]
readPrec :: ReadPrec GetUser
$creadPrec :: ReadPrec GetUser
readList :: ReadS [GetUser]
$creadList :: ReadS [GetUser]
readsPrec :: Int -> ReadS GetUser
$creadsPrec :: Int -> ReadS GetUser
Prelude.Read, Int -> GetUser -> ShowS
[GetUser] -> ShowS
GetUser -> String
(Int -> GetUser -> ShowS)
-> (GetUser -> String) -> ([GetUser] -> ShowS) -> Show GetUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUser] -> ShowS
$cshowList :: [GetUser] -> ShowS
show :: GetUser -> String
$cshow :: GetUser -> String
showsPrec :: Int -> GetUser -> ShowS
$cshowsPrec :: Int -> GetUser -> ShowS
Prelude.Show, (forall x. GetUser -> Rep GetUser x)
-> (forall x. Rep GetUser x -> GetUser) -> Generic GetUser
forall x. Rep GetUser x -> GetUser
forall x. GetUser -> Rep GetUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUser x -> GetUser
$cfrom :: forall x. GetUser -> Rep GetUser x
Prelude.Generic)
newGetUser ::
GetUser
newGetUser :: GetUser
newGetUser = GetUser' :: Maybe Text -> GetUser
GetUser' {$sel:userName:GetUser' :: Maybe Text
userName = Maybe Text
forall a. Maybe a
Prelude.Nothing}
getUser_userName :: Lens.Lens' GetUser (Prelude.Maybe Prelude.Text)
getUser_userName :: (Maybe Text -> f (Maybe Text)) -> GetUser -> f GetUser
getUser_userName = (GetUser -> Maybe Text)
-> (GetUser -> Maybe Text -> GetUser)
-> Lens GetUser GetUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUser' {Maybe Text
userName :: Maybe Text
$sel:userName:GetUser' :: GetUser -> Maybe Text
userName} -> Maybe Text
userName) (\s :: GetUser
s@GetUser' {} Maybe Text
a -> GetUser
s {$sel:userName:GetUser' :: Maybe Text
userName = Maybe Text
a} :: GetUser)
instance Core.AWSRequest GetUser where
type AWSResponse GetUser = GetUserResponse
request :: GetUser -> Request GetUser
request = Service -> GetUser -> Request GetUser
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy GetUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUser)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse GetUser))
-> Logger
-> Service
-> Proxy GetUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUser)))
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
"GetUserResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Int -> User -> GetUserResponse
GetUserResponse'
(Int -> User -> GetUserResponse)
-> Either String Int -> Either String (User -> GetUserResponse)
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 (User -> GetUserResponse)
-> Either String User -> Either String GetUserResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String User
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"User")
)
instance Prelude.Hashable GetUser
instance Prelude.NFData GetUser
instance Core.ToHeaders GetUser where
toHeaders :: GetUser -> ResponseHeaders
toHeaders = ResponseHeaders -> GetUser -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath GetUser where
toPath :: GetUser -> ByteString
toPath = ByteString -> GetUser -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetUser where
toQuery :: GetUser -> QueryString
toQuery GetUser' {Maybe Text
userName :: Maybe Text
$sel:userName:GetUser' :: GetUser -> 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
"GetUser" :: 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 GetUserResponse = GetUserResponse'
{
GetUserResponse -> Int
httpStatus :: Prelude.Int,
GetUserResponse -> User
user :: User
}
deriving (GetUserResponse -> GetUserResponse -> Bool
(GetUserResponse -> GetUserResponse -> Bool)
-> (GetUserResponse -> GetUserResponse -> Bool)
-> Eq GetUserResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUserResponse -> GetUserResponse -> Bool
$c/= :: GetUserResponse -> GetUserResponse -> Bool
== :: GetUserResponse -> GetUserResponse -> Bool
$c== :: GetUserResponse -> GetUserResponse -> Bool
Prelude.Eq, ReadPrec [GetUserResponse]
ReadPrec GetUserResponse
Int -> ReadS GetUserResponse
ReadS [GetUserResponse]
(Int -> ReadS GetUserResponse)
-> ReadS [GetUserResponse]
-> ReadPrec GetUserResponse
-> ReadPrec [GetUserResponse]
-> Read GetUserResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUserResponse]
$creadListPrec :: ReadPrec [GetUserResponse]
readPrec :: ReadPrec GetUserResponse
$creadPrec :: ReadPrec GetUserResponse
readList :: ReadS [GetUserResponse]
$creadList :: ReadS [GetUserResponse]
readsPrec :: Int -> ReadS GetUserResponse
$creadsPrec :: Int -> ReadS GetUserResponse
Prelude.Read, Int -> GetUserResponse -> ShowS
[GetUserResponse] -> ShowS
GetUserResponse -> String
(Int -> GetUserResponse -> ShowS)
-> (GetUserResponse -> String)
-> ([GetUserResponse] -> ShowS)
-> Show GetUserResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUserResponse] -> ShowS
$cshowList :: [GetUserResponse] -> ShowS
show :: GetUserResponse -> String
$cshow :: GetUserResponse -> String
showsPrec :: Int -> GetUserResponse -> ShowS
$cshowsPrec :: Int -> GetUserResponse -> ShowS
Prelude.Show, (forall x. GetUserResponse -> Rep GetUserResponse x)
-> (forall x. Rep GetUserResponse x -> GetUserResponse)
-> Generic GetUserResponse
forall x. Rep GetUserResponse x -> GetUserResponse
forall x. GetUserResponse -> Rep GetUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUserResponse x -> GetUserResponse
$cfrom :: forall x. GetUserResponse -> Rep GetUserResponse x
Prelude.Generic)
newGetUserResponse ::
Prelude.Int ->
User ->
GetUserResponse
newGetUserResponse :: Int -> User -> GetUserResponse
newGetUserResponse Int
pHttpStatus_ User
pUser_ =
GetUserResponse' :: Int -> User -> GetUserResponse
GetUserResponse'
{ $sel:httpStatus:GetUserResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:user:GetUserResponse' :: User
user = User
pUser_
}
getUserResponse_httpStatus :: Lens.Lens' GetUserResponse Prelude.Int
getUserResponse_httpStatus :: (Int -> f Int) -> GetUserResponse -> f GetUserResponse
getUserResponse_httpStatus = (GetUserResponse -> Int)
-> (GetUserResponse -> Int -> GetUserResponse)
-> Lens GetUserResponse GetUserResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetUserResponse' :: GetUserResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetUserResponse
s@GetUserResponse' {} Int
a -> GetUserResponse
s {$sel:httpStatus:GetUserResponse' :: Int
httpStatus = Int
a} :: GetUserResponse)
getUserResponse_user :: Lens.Lens' GetUserResponse User
getUserResponse_user :: (User -> f User) -> GetUserResponse -> f GetUserResponse
getUserResponse_user = (GetUserResponse -> User)
-> (GetUserResponse -> User -> GetUserResponse)
-> Lens GetUserResponse GetUserResponse User User
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserResponse' {User
user :: User
$sel:user:GetUserResponse' :: GetUserResponse -> User
user} -> User
user) (\s :: GetUserResponse
s@GetUserResponse' {} User
a -> GetUserResponse
s {$sel:user:GetUserResponse' :: User
user = User
a} :: GetUserResponse)
instance Prelude.NFData GetUserResponse