{-# 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.GetUserPolicy
(
GetUserPolicy (..),
newGetUserPolicy,
getUserPolicy_userName,
getUserPolicy_policyName,
GetUserPolicyResponse (..),
newGetUserPolicyResponse,
getUserPolicyResponse_httpStatus,
getUserPolicyResponse_userName,
getUserPolicyResponse_policyName,
getUserPolicyResponse_policyDocument,
)
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 GetUserPolicy = GetUserPolicy'
{
GetUserPolicy -> Text
userName :: Prelude.Text,
GetUserPolicy -> Text
policyName :: Prelude.Text
}
deriving (GetUserPolicy -> GetUserPolicy -> Bool
(GetUserPolicy -> GetUserPolicy -> Bool)
-> (GetUserPolicy -> GetUserPolicy -> Bool) -> Eq GetUserPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUserPolicy -> GetUserPolicy -> Bool
$c/= :: GetUserPolicy -> GetUserPolicy -> Bool
== :: GetUserPolicy -> GetUserPolicy -> Bool
$c== :: GetUserPolicy -> GetUserPolicy -> Bool
Prelude.Eq, ReadPrec [GetUserPolicy]
ReadPrec GetUserPolicy
Int -> ReadS GetUserPolicy
ReadS [GetUserPolicy]
(Int -> ReadS GetUserPolicy)
-> ReadS [GetUserPolicy]
-> ReadPrec GetUserPolicy
-> ReadPrec [GetUserPolicy]
-> Read GetUserPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUserPolicy]
$creadListPrec :: ReadPrec [GetUserPolicy]
readPrec :: ReadPrec GetUserPolicy
$creadPrec :: ReadPrec GetUserPolicy
readList :: ReadS [GetUserPolicy]
$creadList :: ReadS [GetUserPolicy]
readsPrec :: Int -> ReadS GetUserPolicy
$creadsPrec :: Int -> ReadS GetUserPolicy
Prelude.Read, Int -> GetUserPolicy -> ShowS
[GetUserPolicy] -> ShowS
GetUserPolicy -> String
(Int -> GetUserPolicy -> ShowS)
-> (GetUserPolicy -> String)
-> ([GetUserPolicy] -> ShowS)
-> Show GetUserPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUserPolicy] -> ShowS
$cshowList :: [GetUserPolicy] -> ShowS
show :: GetUserPolicy -> String
$cshow :: GetUserPolicy -> String
showsPrec :: Int -> GetUserPolicy -> ShowS
$cshowsPrec :: Int -> GetUserPolicy -> ShowS
Prelude.Show, (forall x. GetUserPolicy -> Rep GetUserPolicy x)
-> (forall x. Rep GetUserPolicy x -> GetUserPolicy)
-> Generic GetUserPolicy
forall x. Rep GetUserPolicy x -> GetUserPolicy
forall x. GetUserPolicy -> Rep GetUserPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUserPolicy x -> GetUserPolicy
$cfrom :: forall x. GetUserPolicy -> Rep GetUserPolicy x
Prelude.Generic)
newGetUserPolicy ::
Prelude.Text ->
Prelude.Text ->
GetUserPolicy
newGetUserPolicy :: Text -> Text -> GetUserPolicy
newGetUserPolicy Text
pUserName_ Text
pPolicyName_ =
GetUserPolicy' :: Text -> Text -> GetUserPolicy
GetUserPolicy'
{ $sel:userName:GetUserPolicy' :: Text
userName = Text
pUserName_,
$sel:policyName:GetUserPolicy' :: Text
policyName = Text
pPolicyName_
}
getUserPolicy_userName :: Lens.Lens' GetUserPolicy Prelude.Text
getUserPolicy_userName :: (Text -> f Text) -> GetUserPolicy -> f GetUserPolicy
getUserPolicy_userName = (GetUserPolicy -> Text)
-> (GetUserPolicy -> Text -> GetUserPolicy)
-> Lens GetUserPolicy GetUserPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserPolicy' {Text
userName :: Text
$sel:userName:GetUserPolicy' :: GetUserPolicy -> Text
userName} -> Text
userName) (\s :: GetUserPolicy
s@GetUserPolicy' {} Text
a -> GetUserPolicy
s {$sel:userName:GetUserPolicy' :: Text
userName = Text
a} :: GetUserPolicy)
getUserPolicy_policyName :: Lens.Lens' GetUserPolicy Prelude.Text
getUserPolicy_policyName :: (Text -> f Text) -> GetUserPolicy -> f GetUserPolicy
getUserPolicy_policyName = (GetUserPolicy -> Text)
-> (GetUserPolicy -> Text -> GetUserPolicy)
-> Lens GetUserPolicy GetUserPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserPolicy' {Text
policyName :: Text
$sel:policyName:GetUserPolicy' :: GetUserPolicy -> Text
policyName} -> Text
policyName) (\s :: GetUserPolicy
s@GetUserPolicy' {} Text
a -> GetUserPolicy
s {$sel:policyName:GetUserPolicy' :: Text
policyName = Text
a} :: GetUserPolicy)
instance Core.AWSRequest GetUserPolicy where
type
AWSResponse GetUserPolicy =
GetUserPolicyResponse
request :: GetUserPolicy -> Request GetUserPolicy
request = Service -> GetUserPolicy -> Request GetUserPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
response :: Logger
-> Service
-> Proxy GetUserPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUserPolicy)))
response =
Text
-> (Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse GetUserPolicy))
-> Logger
-> Service
-> Proxy GetUserPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetUserPolicy)))
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
"GetUserPolicyResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Int -> Text -> Text -> Text -> GetUserPolicyResponse
GetUserPolicyResponse'
(Int -> Text -> Text -> Text -> GetUserPolicyResponse)
-> Either String Int
-> Either String (Text -> Text -> Text -> GetUserPolicyResponse)
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 (Text -> Text -> Text -> GetUserPolicyResponse)
-> Either String Text
-> Either String (Text -> Text -> GetUserPolicyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"UserName")
Either String (Text -> Text -> GetUserPolicyResponse)
-> Either String Text
-> Either String (Text -> GetUserPolicyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"PolicyName")
Either String (Text -> GetUserPolicyResponse)
-> Either String Text -> Either String GetUserPolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"PolicyDocument")
)
instance Prelude.Hashable GetUserPolicy
instance Prelude.NFData GetUserPolicy
instance Core.ToHeaders GetUserPolicy where
toHeaders :: GetUserPolicy -> ResponseHeaders
toHeaders = ResponseHeaders -> GetUserPolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath GetUserPolicy where
toPath :: GetUserPolicy -> ByteString
toPath = ByteString -> GetUserPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetUserPolicy where
toQuery :: GetUserPolicy -> QueryString
toQuery GetUserPolicy' {Text
policyName :: Text
userName :: Text
$sel:policyName:GetUserPolicy' :: GetUserPolicy -> Text
$sel:userName:GetUserPolicy' :: GetUserPolicy -> 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
"GetUserPolicy" :: Prelude.ByteString),
ByteString
"Version"
ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
ByteString
"UserName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
userName,
ByteString
"PolicyName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
policyName
]
data GetUserPolicyResponse = GetUserPolicyResponse'
{
GetUserPolicyResponse -> Int
httpStatus :: Prelude.Int,
GetUserPolicyResponse -> Text
userName :: Prelude.Text,
GetUserPolicyResponse -> Text
policyName :: Prelude.Text,
GetUserPolicyResponse -> Text
policyDocument :: Prelude.Text
}
deriving (GetUserPolicyResponse -> GetUserPolicyResponse -> Bool
(GetUserPolicyResponse -> GetUserPolicyResponse -> Bool)
-> (GetUserPolicyResponse -> GetUserPolicyResponse -> Bool)
-> Eq GetUserPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUserPolicyResponse -> GetUserPolicyResponse -> Bool
$c/= :: GetUserPolicyResponse -> GetUserPolicyResponse -> Bool
== :: GetUserPolicyResponse -> GetUserPolicyResponse -> Bool
$c== :: GetUserPolicyResponse -> GetUserPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetUserPolicyResponse]
ReadPrec GetUserPolicyResponse
Int -> ReadS GetUserPolicyResponse
ReadS [GetUserPolicyResponse]
(Int -> ReadS GetUserPolicyResponse)
-> ReadS [GetUserPolicyResponse]
-> ReadPrec GetUserPolicyResponse
-> ReadPrec [GetUserPolicyResponse]
-> Read GetUserPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetUserPolicyResponse]
$creadListPrec :: ReadPrec [GetUserPolicyResponse]
readPrec :: ReadPrec GetUserPolicyResponse
$creadPrec :: ReadPrec GetUserPolicyResponse
readList :: ReadS [GetUserPolicyResponse]
$creadList :: ReadS [GetUserPolicyResponse]
readsPrec :: Int -> ReadS GetUserPolicyResponse
$creadsPrec :: Int -> ReadS GetUserPolicyResponse
Prelude.Read, Int -> GetUserPolicyResponse -> ShowS
[GetUserPolicyResponse] -> ShowS
GetUserPolicyResponse -> String
(Int -> GetUserPolicyResponse -> ShowS)
-> (GetUserPolicyResponse -> String)
-> ([GetUserPolicyResponse] -> ShowS)
-> Show GetUserPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUserPolicyResponse] -> ShowS
$cshowList :: [GetUserPolicyResponse] -> ShowS
show :: GetUserPolicyResponse -> String
$cshow :: GetUserPolicyResponse -> String
showsPrec :: Int -> GetUserPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetUserPolicyResponse -> ShowS
Prelude.Show, (forall x. GetUserPolicyResponse -> Rep GetUserPolicyResponse x)
-> (forall x. Rep GetUserPolicyResponse x -> GetUserPolicyResponse)
-> Generic GetUserPolicyResponse
forall x. Rep GetUserPolicyResponse x -> GetUserPolicyResponse
forall x. GetUserPolicyResponse -> Rep GetUserPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetUserPolicyResponse x -> GetUserPolicyResponse
$cfrom :: forall x. GetUserPolicyResponse -> Rep GetUserPolicyResponse x
Prelude.Generic)
newGetUserPolicyResponse ::
Prelude.Int ->
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
GetUserPolicyResponse
newGetUserPolicyResponse :: Int -> Text -> Text -> Text -> GetUserPolicyResponse
newGetUserPolicyResponse
Int
pHttpStatus_
Text
pUserName_
Text
pPolicyName_
Text
pPolicyDocument_ =
GetUserPolicyResponse' :: Int -> Text -> Text -> Text -> GetUserPolicyResponse
GetUserPolicyResponse'
{ $sel:httpStatus:GetUserPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:userName:GetUserPolicyResponse' :: Text
userName = Text
pUserName_,
$sel:policyName:GetUserPolicyResponse' :: Text
policyName = Text
pPolicyName_,
$sel:policyDocument:GetUserPolicyResponse' :: Text
policyDocument = Text
pPolicyDocument_
}
getUserPolicyResponse_httpStatus :: Lens.Lens' GetUserPolicyResponse Prelude.Int
getUserPolicyResponse_httpStatus :: (Int -> f Int) -> GetUserPolicyResponse -> f GetUserPolicyResponse
getUserPolicyResponse_httpStatus = (GetUserPolicyResponse -> Int)
-> (GetUserPolicyResponse -> Int -> GetUserPolicyResponse)
-> Lens GetUserPolicyResponse GetUserPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetUserPolicyResponse' :: GetUserPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetUserPolicyResponse
s@GetUserPolicyResponse' {} Int
a -> GetUserPolicyResponse
s {$sel:httpStatus:GetUserPolicyResponse' :: Int
httpStatus = Int
a} :: GetUserPolicyResponse)
getUserPolicyResponse_userName :: Lens.Lens' GetUserPolicyResponse Prelude.Text
getUserPolicyResponse_userName :: (Text -> f Text)
-> GetUserPolicyResponse -> f GetUserPolicyResponse
getUserPolicyResponse_userName = (GetUserPolicyResponse -> Text)
-> (GetUserPolicyResponse -> Text -> GetUserPolicyResponse)
-> Lens GetUserPolicyResponse GetUserPolicyResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserPolicyResponse' {Text
userName :: Text
$sel:userName:GetUserPolicyResponse' :: GetUserPolicyResponse -> Text
userName} -> Text
userName) (\s :: GetUserPolicyResponse
s@GetUserPolicyResponse' {} Text
a -> GetUserPolicyResponse
s {$sel:userName:GetUserPolicyResponse' :: Text
userName = Text
a} :: GetUserPolicyResponse)
getUserPolicyResponse_policyName :: Lens.Lens' GetUserPolicyResponse Prelude.Text
getUserPolicyResponse_policyName :: (Text -> f Text)
-> GetUserPolicyResponse -> f GetUserPolicyResponse
getUserPolicyResponse_policyName = (GetUserPolicyResponse -> Text)
-> (GetUserPolicyResponse -> Text -> GetUserPolicyResponse)
-> Lens GetUserPolicyResponse GetUserPolicyResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserPolicyResponse' {Text
policyName :: Text
$sel:policyName:GetUserPolicyResponse' :: GetUserPolicyResponse -> Text
policyName} -> Text
policyName) (\s :: GetUserPolicyResponse
s@GetUserPolicyResponse' {} Text
a -> GetUserPolicyResponse
s {$sel:policyName:GetUserPolicyResponse' :: Text
policyName = Text
a} :: GetUserPolicyResponse)
getUserPolicyResponse_policyDocument :: Lens.Lens' GetUserPolicyResponse Prelude.Text
getUserPolicyResponse_policyDocument :: (Text -> f Text)
-> GetUserPolicyResponse -> f GetUserPolicyResponse
getUserPolicyResponse_policyDocument = (GetUserPolicyResponse -> Text)
-> (GetUserPolicyResponse -> Text -> GetUserPolicyResponse)
-> Lens GetUserPolicyResponse GetUserPolicyResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetUserPolicyResponse' {Text
policyDocument :: Text
$sel:policyDocument:GetUserPolicyResponse' :: GetUserPolicyResponse -> Text
policyDocument} -> Text
policyDocument) (\s :: GetUserPolicyResponse
s@GetUserPolicyResponse' {} Text
a -> GetUserPolicyResponse
s {$sel:policyDocument:GetUserPolicyResponse' :: Text
policyDocument = Text
a} :: GetUserPolicyResponse)
instance Prelude.NFData GetUserPolicyResponse