{-# 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.CodeCommit.CreatePullRequestApprovalRule
(
CreatePullRequestApprovalRule (..),
newCreatePullRequestApprovalRule,
createPullRequestApprovalRule_pullRequestId,
createPullRequestApprovalRule_approvalRuleName,
createPullRequestApprovalRule_approvalRuleContent,
CreatePullRequestApprovalRuleResponse (..),
newCreatePullRequestApprovalRuleResponse,
createPullRequestApprovalRuleResponse_httpStatus,
createPullRequestApprovalRuleResponse_approvalRule,
)
where
import Amazonka.CodeCommit.Types
import qualified Amazonka.Core as Core
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 CreatePullRequestApprovalRule = CreatePullRequestApprovalRule'
{
CreatePullRequestApprovalRule -> Text
pullRequestId :: Prelude.Text,
CreatePullRequestApprovalRule -> Text
approvalRuleName :: Prelude.Text,
CreatePullRequestApprovalRule -> Text
approvalRuleContent :: Prelude.Text
}
deriving (CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool
(CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool)
-> (CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool)
-> Eq CreatePullRequestApprovalRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool
$c/= :: CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool
== :: CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool
$c== :: CreatePullRequestApprovalRule
-> CreatePullRequestApprovalRule -> Bool
Prelude.Eq, ReadPrec [CreatePullRequestApprovalRule]
ReadPrec CreatePullRequestApprovalRule
Int -> ReadS CreatePullRequestApprovalRule
ReadS [CreatePullRequestApprovalRule]
(Int -> ReadS CreatePullRequestApprovalRule)
-> ReadS [CreatePullRequestApprovalRule]
-> ReadPrec CreatePullRequestApprovalRule
-> ReadPrec [CreatePullRequestApprovalRule]
-> Read CreatePullRequestApprovalRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePullRequestApprovalRule]
$creadListPrec :: ReadPrec [CreatePullRequestApprovalRule]
readPrec :: ReadPrec CreatePullRequestApprovalRule
$creadPrec :: ReadPrec CreatePullRequestApprovalRule
readList :: ReadS [CreatePullRequestApprovalRule]
$creadList :: ReadS [CreatePullRequestApprovalRule]
readsPrec :: Int -> ReadS CreatePullRequestApprovalRule
$creadsPrec :: Int -> ReadS CreatePullRequestApprovalRule
Prelude.Read, Int -> CreatePullRequestApprovalRule -> ShowS
[CreatePullRequestApprovalRule] -> ShowS
CreatePullRequestApprovalRule -> String
(Int -> CreatePullRequestApprovalRule -> ShowS)
-> (CreatePullRequestApprovalRule -> String)
-> ([CreatePullRequestApprovalRule] -> ShowS)
-> Show CreatePullRequestApprovalRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePullRequestApprovalRule] -> ShowS
$cshowList :: [CreatePullRequestApprovalRule] -> ShowS
show :: CreatePullRequestApprovalRule -> String
$cshow :: CreatePullRequestApprovalRule -> String
showsPrec :: Int -> CreatePullRequestApprovalRule -> ShowS
$cshowsPrec :: Int -> CreatePullRequestApprovalRule -> ShowS
Prelude.Show, (forall x.
CreatePullRequestApprovalRule
-> Rep CreatePullRequestApprovalRule x)
-> (forall x.
Rep CreatePullRequestApprovalRule x
-> CreatePullRequestApprovalRule)
-> Generic CreatePullRequestApprovalRule
forall x.
Rep CreatePullRequestApprovalRule x
-> CreatePullRequestApprovalRule
forall x.
CreatePullRequestApprovalRule
-> Rep CreatePullRequestApprovalRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePullRequestApprovalRule x
-> CreatePullRequestApprovalRule
$cfrom :: forall x.
CreatePullRequestApprovalRule
-> Rep CreatePullRequestApprovalRule x
Prelude.Generic)
newCreatePullRequestApprovalRule ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
CreatePullRequestApprovalRule
newCreatePullRequestApprovalRule :: Text -> Text -> Text -> CreatePullRequestApprovalRule
newCreatePullRequestApprovalRule
Text
pPullRequestId_
Text
pApprovalRuleName_
Text
pApprovalRuleContent_ =
CreatePullRequestApprovalRule' :: Text -> Text -> Text -> CreatePullRequestApprovalRule
CreatePullRequestApprovalRule'
{ $sel:pullRequestId:CreatePullRequestApprovalRule' :: Text
pullRequestId =
Text
pPullRequestId_,
$sel:approvalRuleName:CreatePullRequestApprovalRule' :: Text
approvalRuleName = Text
pApprovalRuleName_,
$sel:approvalRuleContent:CreatePullRequestApprovalRule' :: Text
approvalRuleContent = Text
pApprovalRuleContent_
}
createPullRequestApprovalRule_pullRequestId :: Lens.Lens' CreatePullRequestApprovalRule Prelude.Text
createPullRequestApprovalRule_pullRequestId :: (Text -> f Text)
-> CreatePullRequestApprovalRule -> f CreatePullRequestApprovalRule
createPullRequestApprovalRule_pullRequestId = (CreatePullRequestApprovalRule -> Text)
-> (CreatePullRequestApprovalRule
-> Text -> CreatePullRequestApprovalRule)
-> Lens
CreatePullRequestApprovalRule
CreatePullRequestApprovalRule
Text
Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestApprovalRule' {Text
pullRequestId :: Text
$sel:pullRequestId:CreatePullRequestApprovalRule' :: CreatePullRequestApprovalRule -> Text
pullRequestId} -> Text
pullRequestId) (\s :: CreatePullRequestApprovalRule
s@CreatePullRequestApprovalRule' {} Text
a -> CreatePullRequestApprovalRule
s {$sel:pullRequestId:CreatePullRequestApprovalRule' :: Text
pullRequestId = Text
a} :: CreatePullRequestApprovalRule)
createPullRequestApprovalRule_approvalRuleName :: Lens.Lens' CreatePullRequestApprovalRule Prelude.Text
createPullRequestApprovalRule_approvalRuleName :: (Text -> f Text)
-> CreatePullRequestApprovalRule -> f CreatePullRequestApprovalRule
createPullRequestApprovalRule_approvalRuleName = (CreatePullRequestApprovalRule -> Text)
-> (CreatePullRequestApprovalRule
-> Text -> CreatePullRequestApprovalRule)
-> Lens
CreatePullRequestApprovalRule
CreatePullRequestApprovalRule
Text
Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestApprovalRule' {Text
approvalRuleName :: Text
$sel:approvalRuleName:CreatePullRequestApprovalRule' :: CreatePullRequestApprovalRule -> Text
approvalRuleName} -> Text
approvalRuleName) (\s :: CreatePullRequestApprovalRule
s@CreatePullRequestApprovalRule' {} Text
a -> CreatePullRequestApprovalRule
s {$sel:approvalRuleName:CreatePullRequestApprovalRule' :: Text
approvalRuleName = Text
a} :: CreatePullRequestApprovalRule)
createPullRequestApprovalRule_approvalRuleContent :: Lens.Lens' CreatePullRequestApprovalRule Prelude.Text
createPullRequestApprovalRule_approvalRuleContent :: (Text -> f Text)
-> CreatePullRequestApprovalRule -> f CreatePullRequestApprovalRule
createPullRequestApprovalRule_approvalRuleContent = (CreatePullRequestApprovalRule -> Text)
-> (CreatePullRequestApprovalRule
-> Text -> CreatePullRequestApprovalRule)
-> Lens
CreatePullRequestApprovalRule
CreatePullRequestApprovalRule
Text
Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestApprovalRule' {Text
approvalRuleContent :: Text
$sel:approvalRuleContent:CreatePullRequestApprovalRule' :: CreatePullRequestApprovalRule -> Text
approvalRuleContent} -> Text
approvalRuleContent) (\s :: CreatePullRequestApprovalRule
s@CreatePullRequestApprovalRule' {} Text
a -> CreatePullRequestApprovalRule
s {$sel:approvalRuleContent:CreatePullRequestApprovalRule' :: Text
approvalRuleContent = Text
a} :: CreatePullRequestApprovalRule)
instance
Core.AWSRequest
CreatePullRequestApprovalRule
where
type
AWSResponse CreatePullRequestApprovalRule =
CreatePullRequestApprovalRuleResponse
request :: CreatePullRequestApprovalRule
-> Request CreatePullRequestApprovalRule
request = Service
-> CreatePullRequestApprovalRule
-> Request CreatePullRequestApprovalRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreatePullRequestApprovalRule
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePullRequestApprovalRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreatePullRequestApprovalRule))
-> Logger
-> Service
-> Proxy CreatePullRequestApprovalRule
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePullRequestApprovalRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Int -> ApprovalRule -> CreatePullRequestApprovalRuleResponse
CreatePullRequestApprovalRuleResponse'
(Int -> ApprovalRule -> CreatePullRequestApprovalRuleResponse)
-> Either String Int
-> Either
String (ApprovalRule -> CreatePullRequestApprovalRuleResponse)
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 (ApprovalRule -> CreatePullRequestApprovalRuleResponse)
-> Either String ApprovalRule
-> Either String CreatePullRequestApprovalRuleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String ApprovalRule
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"approvalRule")
)
instance
Prelude.Hashable
CreatePullRequestApprovalRule
instance Prelude.NFData CreatePullRequestApprovalRule
instance Core.ToHeaders CreatePullRequestApprovalRule where
toHeaders :: CreatePullRequestApprovalRule -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreatePullRequestApprovalRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeCommit_20150413.CreatePullRequestApprovalRule" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreatePullRequestApprovalRule where
toJSON :: CreatePullRequestApprovalRule -> Value
toJSON CreatePullRequestApprovalRule' {Text
approvalRuleContent :: Text
approvalRuleName :: Text
pullRequestId :: Text
$sel:approvalRuleContent:CreatePullRequestApprovalRule' :: CreatePullRequestApprovalRule -> Text
$sel:approvalRuleName:CreatePullRequestApprovalRule' :: CreatePullRequestApprovalRule -> Text
$sel:pullRequestId:CreatePullRequestApprovalRule' :: CreatePullRequestApprovalRule -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"pullRequestId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
pullRequestId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"approvalRuleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
approvalRuleName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"approvalRuleContent" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
approvalRuleContent)
]
)
instance Core.ToPath CreatePullRequestApprovalRule where
toPath :: CreatePullRequestApprovalRule -> ByteString
toPath = ByteString -> CreatePullRequestApprovalRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreatePullRequestApprovalRule where
toQuery :: CreatePullRequestApprovalRule -> QueryString
toQuery = QueryString -> CreatePullRequestApprovalRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreatePullRequestApprovalRuleResponse = CreatePullRequestApprovalRuleResponse'
{
CreatePullRequestApprovalRuleResponse -> Int
httpStatus :: Prelude.Int,
CreatePullRequestApprovalRuleResponse -> ApprovalRule
approvalRule :: ApprovalRule
}
deriving (CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool
(CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool)
-> (CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool)
-> Eq CreatePullRequestApprovalRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool
$c/= :: CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool
== :: CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool
$c== :: CreatePullRequestApprovalRuleResponse
-> CreatePullRequestApprovalRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreatePullRequestApprovalRuleResponse]
ReadPrec CreatePullRequestApprovalRuleResponse
Int -> ReadS CreatePullRequestApprovalRuleResponse
ReadS [CreatePullRequestApprovalRuleResponse]
(Int -> ReadS CreatePullRequestApprovalRuleResponse)
-> ReadS [CreatePullRequestApprovalRuleResponse]
-> ReadPrec CreatePullRequestApprovalRuleResponse
-> ReadPrec [CreatePullRequestApprovalRuleResponse]
-> Read CreatePullRequestApprovalRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePullRequestApprovalRuleResponse]
$creadListPrec :: ReadPrec [CreatePullRequestApprovalRuleResponse]
readPrec :: ReadPrec CreatePullRequestApprovalRuleResponse
$creadPrec :: ReadPrec CreatePullRequestApprovalRuleResponse
readList :: ReadS [CreatePullRequestApprovalRuleResponse]
$creadList :: ReadS [CreatePullRequestApprovalRuleResponse]
readsPrec :: Int -> ReadS CreatePullRequestApprovalRuleResponse
$creadsPrec :: Int -> ReadS CreatePullRequestApprovalRuleResponse
Prelude.Read, Int -> CreatePullRequestApprovalRuleResponse -> ShowS
[CreatePullRequestApprovalRuleResponse] -> ShowS
CreatePullRequestApprovalRuleResponse -> String
(Int -> CreatePullRequestApprovalRuleResponse -> ShowS)
-> (CreatePullRequestApprovalRuleResponse -> String)
-> ([CreatePullRequestApprovalRuleResponse] -> ShowS)
-> Show CreatePullRequestApprovalRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePullRequestApprovalRuleResponse] -> ShowS
$cshowList :: [CreatePullRequestApprovalRuleResponse] -> ShowS
show :: CreatePullRequestApprovalRuleResponse -> String
$cshow :: CreatePullRequestApprovalRuleResponse -> String
showsPrec :: Int -> CreatePullRequestApprovalRuleResponse -> ShowS
$cshowsPrec :: Int -> CreatePullRequestApprovalRuleResponse -> ShowS
Prelude.Show, (forall x.
CreatePullRequestApprovalRuleResponse
-> Rep CreatePullRequestApprovalRuleResponse x)
-> (forall x.
Rep CreatePullRequestApprovalRuleResponse x
-> CreatePullRequestApprovalRuleResponse)
-> Generic CreatePullRequestApprovalRuleResponse
forall x.
Rep CreatePullRequestApprovalRuleResponse x
-> CreatePullRequestApprovalRuleResponse
forall x.
CreatePullRequestApprovalRuleResponse
-> Rep CreatePullRequestApprovalRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePullRequestApprovalRuleResponse x
-> CreatePullRequestApprovalRuleResponse
$cfrom :: forall x.
CreatePullRequestApprovalRuleResponse
-> Rep CreatePullRequestApprovalRuleResponse x
Prelude.Generic)
newCreatePullRequestApprovalRuleResponse ::
Prelude.Int ->
ApprovalRule ->
CreatePullRequestApprovalRuleResponse
newCreatePullRequestApprovalRuleResponse :: Int -> ApprovalRule -> CreatePullRequestApprovalRuleResponse
newCreatePullRequestApprovalRuleResponse
Int
pHttpStatus_
ApprovalRule
pApprovalRule_ =
CreatePullRequestApprovalRuleResponse' :: Int -> ApprovalRule -> CreatePullRequestApprovalRuleResponse
CreatePullRequestApprovalRuleResponse'
{ $sel:httpStatus:CreatePullRequestApprovalRuleResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:approvalRule:CreatePullRequestApprovalRuleResponse' :: ApprovalRule
approvalRule = ApprovalRule
pApprovalRule_
}
createPullRequestApprovalRuleResponse_httpStatus :: Lens.Lens' CreatePullRequestApprovalRuleResponse Prelude.Int
createPullRequestApprovalRuleResponse_httpStatus :: (Int -> f Int)
-> CreatePullRequestApprovalRuleResponse
-> f CreatePullRequestApprovalRuleResponse
createPullRequestApprovalRuleResponse_httpStatus = (CreatePullRequestApprovalRuleResponse -> Int)
-> (CreatePullRequestApprovalRuleResponse
-> Int -> CreatePullRequestApprovalRuleResponse)
-> Lens
CreatePullRequestApprovalRuleResponse
CreatePullRequestApprovalRuleResponse
Int
Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestApprovalRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreatePullRequestApprovalRuleResponse' :: CreatePullRequestApprovalRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreatePullRequestApprovalRuleResponse
s@CreatePullRequestApprovalRuleResponse' {} Int
a -> CreatePullRequestApprovalRuleResponse
s {$sel:httpStatus:CreatePullRequestApprovalRuleResponse' :: Int
httpStatus = Int
a} :: CreatePullRequestApprovalRuleResponse)
createPullRequestApprovalRuleResponse_approvalRule :: Lens.Lens' CreatePullRequestApprovalRuleResponse ApprovalRule
createPullRequestApprovalRuleResponse_approvalRule :: (ApprovalRule -> f ApprovalRule)
-> CreatePullRequestApprovalRuleResponse
-> f CreatePullRequestApprovalRuleResponse
createPullRequestApprovalRuleResponse_approvalRule = (CreatePullRequestApprovalRuleResponse -> ApprovalRule)
-> (CreatePullRequestApprovalRuleResponse
-> ApprovalRule -> CreatePullRequestApprovalRuleResponse)
-> Lens
CreatePullRequestApprovalRuleResponse
CreatePullRequestApprovalRuleResponse
ApprovalRule
ApprovalRule
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestApprovalRuleResponse' {ApprovalRule
approvalRule :: ApprovalRule
$sel:approvalRule:CreatePullRequestApprovalRuleResponse' :: CreatePullRequestApprovalRuleResponse -> ApprovalRule
approvalRule} -> ApprovalRule
approvalRule) (\s :: CreatePullRequestApprovalRuleResponse
s@CreatePullRequestApprovalRuleResponse' {} ApprovalRule
a -> CreatePullRequestApprovalRuleResponse
s {$sel:approvalRule:CreatePullRequestApprovalRuleResponse' :: ApprovalRule
approvalRule = ApprovalRule
a} :: CreatePullRequestApprovalRuleResponse)
instance
Prelude.NFData
CreatePullRequestApprovalRuleResponse