{-# 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.CreatePolicy
(
CreatePolicy (..),
newCreatePolicy,
createPolicy_description,
createPolicy_path,
createPolicy_tags,
createPolicy_policyName,
createPolicy_policyDocument,
CreatePolicyResponse (..),
newCreatePolicyResponse,
createPolicyResponse_policy,
createPolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreatePolicy = CreatePolicy'
{
CreatePolicy -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreatePolicy -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
CreatePolicy -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreatePolicy -> Text
policyName :: Prelude.Text,
CreatePolicy -> Text
policyDocument :: Prelude.Text
}
deriving (CreatePolicy -> CreatePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePolicy -> CreatePolicy -> Bool
$c/= :: CreatePolicy -> CreatePolicy -> Bool
== :: CreatePolicy -> CreatePolicy -> Bool
$c== :: CreatePolicy -> CreatePolicy -> Bool
Prelude.Eq, ReadPrec [CreatePolicy]
ReadPrec CreatePolicy
Int -> ReadS CreatePolicy
ReadS [CreatePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePolicy]
$creadListPrec :: ReadPrec [CreatePolicy]
readPrec :: ReadPrec CreatePolicy
$creadPrec :: ReadPrec CreatePolicy
readList :: ReadS [CreatePolicy]
$creadList :: ReadS [CreatePolicy]
readsPrec :: Int -> ReadS CreatePolicy
$creadsPrec :: Int -> ReadS CreatePolicy
Prelude.Read, Int -> CreatePolicy -> ShowS
[CreatePolicy] -> ShowS
CreatePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePolicy] -> ShowS
$cshowList :: [CreatePolicy] -> ShowS
show :: CreatePolicy -> String
$cshow :: CreatePolicy -> String
showsPrec :: Int -> CreatePolicy -> ShowS
$cshowsPrec :: Int -> CreatePolicy -> ShowS
Prelude.Show, forall x. Rep CreatePolicy x -> CreatePolicy
forall x. CreatePolicy -> Rep CreatePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePolicy x -> CreatePolicy
$cfrom :: forall x. CreatePolicy -> Rep CreatePolicy x
Prelude.Generic)
newCreatePolicy ::
Prelude.Text ->
Prelude.Text ->
CreatePolicy
newCreatePolicy :: Text -> Text -> CreatePolicy
newCreatePolicy Text
pPolicyName_ Text
pPolicyDocument_ =
CreatePolicy'
{ $sel:description:CreatePolicy' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
$sel:path:CreatePolicy' :: Maybe Text
path = forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreatePolicy' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
$sel:policyName:CreatePolicy' :: Text
policyName = Text
pPolicyName_,
$sel:policyDocument:CreatePolicy' :: Text
policyDocument = Text
pPolicyDocument_
}
createPolicy_description :: Lens.Lens' CreatePolicy (Prelude.Maybe Prelude.Text)
createPolicy_description :: Lens' CreatePolicy (Maybe Text)
createPolicy_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Maybe Text
description :: Maybe Text
$sel:description:CreatePolicy' :: CreatePolicy -> Maybe Text
description} -> Maybe Text
description) (\s :: CreatePolicy
s@CreatePolicy' {} Maybe Text
a -> CreatePolicy
s {$sel:description:CreatePolicy' :: Maybe Text
description = Maybe Text
a} :: CreatePolicy)
createPolicy_path :: Lens.Lens' CreatePolicy (Prelude.Maybe Prelude.Text)
createPolicy_path :: Lens' CreatePolicy (Maybe Text)
createPolicy_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Maybe Text
path :: Maybe Text
$sel:path:CreatePolicy' :: CreatePolicy -> Maybe Text
path} -> Maybe Text
path) (\s :: CreatePolicy
s@CreatePolicy' {} Maybe Text
a -> CreatePolicy
s {$sel:path:CreatePolicy' :: Maybe Text
path = Maybe Text
a} :: CreatePolicy)
createPolicy_tags :: Lens.Lens' CreatePolicy (Prelude.Maybe [Tag])
createPolicy_tags :: Lens' CreatePolicy (Maybe [Tag])
createPolicy_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreatePolicy
s@CreatePolicy' {} Maybe [Tag]
a -> CreatePolicy
s {$sel:tags:CreatePolicy' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreatePolicy) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createPolicy_policyName :: Lens.Lens' CreatePolicy Prelude.Text
createPolicy_policyName :: Lens' CreatePolicy Text
createPolicy_policyName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Text
policyName :: Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
policyName} -> Text
policyName) (\s :: CreatePolicy
s@CreatePolicy' {} Text
a -> CreatePolicy
s {$sel:policyName:CreatePolicy' :: Text
policyName = Text
a} :: CreatePolicy)
createPolicy_policyDocument :: Lens.Lens' CreatePolicy Prelude.Text
createPolicy_policyDocument :: Lens' CreatePolicy Text
createPolicy_policyDocument = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicy' {Text
policyDocument :: Text
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
policyDocument} -> Text
policyDocument) (\s :: CreatePolicy
s@CreatePolicy' {} Text
a -> CreatePolicy
s {$sel:policyDocument:CreatePolicy' :: Text
policyDocument = Text
a} :: CreatePolicy)
instance Core.AWSRequest CreatePolicy where
type AWSResponse CreatePolicy = CreatePolicyResponse
request :: (Service -> Service) -> CreatePolicy -> Request CreatePolicy
request Service -> Service
overrides =
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreatePolicy)))
response =
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"CreatePolicyResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe Policy -> Int -> CreatePolicyResponse
CreatePolicyResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Policy")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreatePolicy where
hashWithSalt :: Int -> CreatePolicy -> Int
hashWithSalt Int
_salt CreatePolicy' {Maybe [Tag]
Maybe Text
Text
policyDocument :: Text
policyName :: Text
tags :: Maybe [Tag]
path :: Maybe Text
description :: Maybe Text
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
$sel:path:CreatePolicy' :: CreatePolicy -> Maybe Text
$sel:description:CreatePolicy' :: CreatePolicy -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
path
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyDocument
instance Prelude.NFData CreatePolicy where
rnf :: CreatePolicy -> ()
rnf CreatePolicy' {Maybe [Tag]
Maybe Text
Text
policyDocument :: Text
policyName :: Text
tags :: Maybe [Tag]
path :: Maybe Text
description :: Maybe Text
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
$sel:path:CreatePolicy' :: CreatePolicy -> Maybe Text
$sel:description:CreatePolicy' :: CreatePolicy -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
path
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyDocument
instance Data.ToHeaders CreatePolicy where
toHeaders :: CreatePolicy -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
instance Data.ToPath CreatePolicy where
toPath :: CreatePolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery CreatePolicy where
toQuery :: CreatePolicy -> QueryString
toQuery CreatePolicy' {Maybe [Tag]
Maybe Text
Text
policyDocument :: Text
policyName :: Text
tags :: Maybe [Tag]
path :: Maybe Text
description :: Maybe Text
$sel:policyDocument:CreatePolicy' :: CreatePolicy -> Text
$sel:policyName:CreatePolicy' :: CreatePolicy -> Text
$sel:tags:CreatePolicy' :: CreatePolicy -> Maybe [Tag]
$sel:path:CreatePolicy' :: CreatePolicy -> Maybe Text
$sel:description:CreatePolicy' :: CreatePolicy -> Maybe Text
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreatePolicy" :: Prelude.ByteString),
ByteString
"Version"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
ByteString
"Description" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
description,
ByteString
"Path" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
path,
ByteString
"Tags"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
(forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
ByteString
"PolicyName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
policyName,
ByteString
"PolicyDocument" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
policyDocument
]
data CreatePolicyResponse = CreatePolicyResponse'
{
CreatePolicyResponse -> Maybe Policy
policy :: Prelude.Maybe Policy,
CreatePolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreatePolicyResponse -> CreatePolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
$c/= :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
== :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
$c== :: CreatePolicyResponse -> CreatePolicyResponse -> Bool
Prelude.Eq, ReadPrec [CreatePolicyResponse]
ReadPrec CreatePolicyResponse
Int -> ReadS CreatePolicyResponse
ReadS [CreatePolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePolicyResponse]
$creadListPrec :: ReadPrec [CreatePolicyResponse]
readPrec :: ReadPrec CreatePolicyResponse
$creadPrec :: ReadPrec CreatePolicyResponse
readList :: ReadS [CreatePolicyResponse]
$creadList :: ReadS [CreatePolicyResponse]
readsPrec :: Int -> ReadS CreatePolicyResponse
$creadsPrec :: Int -> ReadS CreatePolicyResponse
Prelude.Read, Int -> CreatePolicyResponse -> ShowS
[CreatePolicyResponse] -> ShowS
CreatePolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePolicyResponse] -> ShowS
$cshowList :: [CreatePolicyResponse] -> ShowS
show :: CreatePolicyResponse -> String
$cshow :: CreatePolicyResponse -> String
showsPrec :: Int -> CreatePolicyResponse -> ShowS
$cshowsPrec :: Int -> CreatePolicyResponse -> ShowS
Prelude.Show, forall x. Rep CreatePolicyResponse x -> CreatePolicyResponse
forall x. CreatePolicyResponse -> Rep CreatePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePolicyResponse x -> CreatePolicyResponse
$cfrom :: forall x. CreatePolicyResponse -> Rep CreatePolicyResponse x
Prelude.Generic)
newCreatePolicyResponse ::
Prelude.Int ->
CreatePolicyResponse
newCreatePolicyResponse :: Int -> CreatePolicyResponse
newCreatePolicyResponse Int
pHttpStatus_ =
CreatePolicyResponse'
{ $sel:policy:CreatePolicyResponse' :: Maybe Policy
policy = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreatePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createPolicyResponse_policy :: Lens.Lens' CreatePolicyResponse (Prelude.Maybe Policy)
createPolicyResponse_policy :: Lens' CreatePolicyResponse (Maybe Policy)
createPolicyResponse_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicyResponse' {Maybe Policy
policy :: Maybe Policy
$sel:policy:CreatePolicyResponse' :: CreatePolicyResponse -> Maybe Policy
policy} -> Maybe Policy
policy) (\s :: CreatePolicyResponse
s@CreatePolicyResponse' {} Maybe Policy
a -> CreatePolicyResponse
s {$sel:policy:CreatePolicyResponse' :: Maybe Policy
policy = Maybe Policy
a} :: CreatePolicyResponse)
createPolicyResponse_httpStatus :: Lens.Lens' CreatePolicyResponse Prelude.Int
createPolicyResponse_httpStatus :: Lens' CreatePolicyResponse Int
createPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreatePolicyResponse' :: CreatePolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreatePolicyResponse
s@CreatePolicyResponse' {} Int
a -> CreatePolicyResponse
s {$sel:httpStatus:CreatePolicyResponse' :: Int
httpStatus = Int
a} :: CreatePolicyResponse)
instance Prelude.NFData CreatePolicyResponse where
rnf :: CreatePolicyResponse -> ()
rnf CreatePolicyResponse' {Int
Maybe Policy
httpStatus :: Int
policy :: Maybe Policy
$sel:httpStatus:CreatePolicyResponse' :: CreatePolicyResponse -> Int
$sel:policy:CreatePolicyResponse' :: CreatePolicyResponse -> Maybe Policy
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Policy
policy
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus