{-# 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.CreatePullRequest
(
CreatePullRequest (..),
newCreatePullRequest,
createPullRequest_clientRequestToken,
createPullRequest_description,
createPullRequest_title,
createPullRequest_targets,
CreatePullRequestResponse (..),
newCreatePullRequestResponse,
createPullRequestResponse_httpStatus,
createPullRequestResponse_pullRequest,
)
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 CreatePullRequest = CreatePullRequest'
{
CreatePullRequest -> Maybe Text
clientRequestToken :: Prelude.Maybe Prelude.Text,
CreatePullRequest -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreatePullRequest -> Text
title :: Prelude.Text,
CreatePullRequest -> [Target]
targets :: [Target]
}
deriving (CreatePullRequest -> CreatePullRequest -> Bool
(CreatePullRequest -> CreatePullRequest -> Bool)
-> (CreatePullRequest -> CreatePullRequest -> Bool)
-> Eq CreatePullRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePullRequest -> CreatePullRequest -> Bool
$c/= :: CreatePullRequest -> CreatePullRequest -> Bool
== :: CreatePullRequest -> CreatePullRequest -> Bool
$c== :: CreatePullRequest -> CreatePullRequest -> Bool
Prelude.Eq, ReadPrec [CreatePullRequest]
ReadPrec CreatePullRequest
Int -> ReadS CreatePullRequest
ReadS [CreatePullRequest]
(Int -> ReadS CreatePullRequest)
-> ReadS [CreatePullRequest]
-> ReadPrec CreatePullRequest
-> ReadPrec [CreatePullRequest]
-> Read CreatePullRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePullRequest]
$creadListPrec :: ReadPrec [CreatePullRequest]
readPrec :: ReadPrec CreatePullRequest
$creadPrec :: ReadPrec CreatePullRequest
readList :: ReadS [CreatePullRequest]
$creadList :: ReadS [CreatePullRequest]
readsPrec :: Int -> ReadS CreatePullRequest
$creadsPrec :: Int -> ReadS CreatePullRequest
Prelude.Read, Int -> CreatePullRequest -> ShowS
[CreatePullRequest] -> ShowS
CreatePullRequest -> String
(Int -> CreatePullRequest -> ShowS)
-> (CreatePullRequest -> String)
-> ([CreatePullRequest] -> ShowS)
-> Show CreatePullRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePullRequest] -> ShowS
$cshowList :: [CreatePullRequest] -> ShowS
show :: CreatePullRequest -> String
$cshow :: CreatePullRequest -> String
showsPrec :: Int -> CreatePullRequest -> ShowS
$cshowsPrec :: Int -> CreatePullRequest -> ShowS
Prelude.Show, (forall x. CreatePullRequest -> Rep CreatePullRequest x)
-> (forall x. Rep CreatePullRequest x -> CreatePullRequest)
-> Generic CreatePullRequest
forall x. Rep CreatePullRequest x -> CreatePullRequest
forall x. CreatePullRequest -> Rep CreatePullRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreatePullRequest x -> CreatePullRequest
$cfrom :: forall x. CreatePullRequest -> Rep CreatePullRequest x
Prelude.Generic)
newCreatePullRequest ::
Prelude.Text ->
CreatePullRequest
newCreatePullRequest :: Text -> CreatePullRequest
newCreatePullRequest Text
pTitle_ =
CreatePullRequest' :: Maybe Text -> Maybe Text -> Text -> [Target] -> CreatePullRequest
CreatePullRequest'
{ $sel:clientRequestToken:CreatePullRequest' :: Maybe Text
clientRequestToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreatePullRequest' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:title:CreatePullRequest' :: Text
title = Text
pTitle_,
$sel:targets:CreatePullRequest' :: [Target]
targets = [Target]
forall a. Monoid a => a
Prelude.mempty
}
createPullRequest_clientRequestToken :: Lens.Lens' CreatePullRequest (Prelude.Maybe Prelude.Text)
createPullRequest_clientRequestToken :: (Maybe Text -> f (Maybe Text))
-> CreatePullRequest -> f CreatePullRequest
createPullRequest_clientRequestToken = (CreatePullRequest -> Maybe Text)
-> (CreatePullRequest -> Maybe Text -> CreatePullRequest)
-> Lens
CreatePullRequest CreatePullRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequest' {Maybe Text
clientRequestToken :: Maybe Text
$sel:clientRequestToken:CreatePullRequest' :: CreatePullRequest -> Maybe Text
clientRequestToken} -> Maybe Text
clientRequestToken) (\s :: CreatePullRequest
s@CreatePullRequest' {} Maybe Text
a -> CreatePullRequest
s {$sel:clientRequestToken:CreatePullRequest' :: Maybe Text
clientRequestToken = Maybe Text
a} :: CreatePullRequest)
createPullRequest_description :: Lens.Lens' CreatePullRequest (Prelude.Maybe Prelude.Text)
createPullRequest_description :: (Maybe Text -> f (Maybe Text))
-> CreatePullRequest -> f CreatePullRequest
createPullRequest_description = (CreatePullRequest -> Maybe Text)
-> (CreatePullRequest -> Maybe Text -> CreatePullRequest)
-> Lens
CreatePullRequest CreatePullRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequest' {Maybe Text
description :: Maybe Text
$sel:description:CreatePullRequest' :: CreatePullRequest -> Maybe Text
description} -> Maybe Text
description) (\s :: CreatePullRequest
s@CreatePullRequest' {} Maybe Text
a -> CreatePullRequest
s {$sel:description:CreatePullRequest' :: Maybe Text
description = Maybe Text
a} :: CreatePullRequest)
createPullRequest_title :: Lens.Lens' CreatePullRequest Prelude.Text
createPullRequest_title :: (Text -> f Text) -> CreatePullRequest -> f CreatePullRequest
createPullRequest_title = (CreatePullRequest -> Text)
-> (CreatePullRequest -> Text -> CreatePullRequest)
-> Lens CreatePullRequest CreatePullRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequest' {Text
title :: Text
$sel:title:CreatePullRequest' :: CreatePullRequest -> Text
title} -> Text
title) (\s :: CreatePullRequest
s@CreatePullRequest' {} Text
a -> CreatePullRequest
s {$sel:title:CreatePullRequest' :: Text
title = Text
a} :: CreatePullRequest)
createPullRequest_targets :: Lens.Lens' CreatePullRequest [Target]
createPullRequest_targets :: ([Target] -> f [Target])
-> CreatePullRequest -> f CreatePullRequest
createPullRequest_targets = (CreatePullRequest -> [Target])
-> (CreatePullRequest -> [Target] -> CreatePullRequest)
-> Lens CreatePullRequest CreatePullRequest [Target] [Target]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequest' {[Target]
targets :: [Target]
$sel:targets:CreatePullRequest' :: CreatePullRequest -> [Target]
targets} -> [Target]
targets) (\s :: CreatePullRequest
s@CreatePullRequest' {} [Target]
a -> CreatePullRequest
s {$sel:targets:CreatePullRequest' :: [Target]
targets = [Target]
a} :: CreatePullRequest) (([Target] -> f [Target])
-> CreatePullRequest -> f CreatePullRequest)
-> (([Target] -> f [Target]) -> [Target] -> f [Target])
-> ([Target] -> f [Target])
-> CreatePullRequest
-> f CreatePullRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Target] -> f [Target]) -> [Target] -> f [Target]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreatePullRequest where
type
AWSResponse CreatePullRequest =
CreatePullRequestResponse
request :: CreatePullRequest -> Request CreatePullRequest
request = Service -> CreatePullRequest -> Request CreatePullRequest
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreatePullRequest
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePullRequest)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreatePullRequest))
-> Logger
-> Service
-> Proxy CreatePullRequest
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreatePullRequest)))
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 -> PullRequest -> CreatePullRequestResponse
CreatePullRequestResponse'
(Int -> PullRequest -> CreatePullRequestResponse)
-> Either String Int
-> Either String (PullRequest -> CreatePullRequestResponse)
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 (PullRequest -> CreatePullRequestResponse)
-> Either String PullRequest
-> Either String CreatePullRequestResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String PullRequest
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"pullRequest")
)
instance Prelude.Hashable CreatePullRequest
instance Prelude.NFData CreatePullRequest
instance Core.ToHeaders CreatePullRequest where
toHeaders :: CreatePullRequest -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreatePullRequest -> 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.CreatePullRequest" ::
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 CreatePullRequest where
toJSON :: CreatePullRequest -> Value
toJSON CreatePullRequest' {[Target]
Maybe Text
Text
targets :: [Target]
title :: Text
description :: Maybe Text
clientRequestToken :: Maybe Text
$sel:targets:CreatePullRequest' :: CreatePullRequest -> [Target]
$sel:title:CreatePullRequest' :: CreatePullRequest -> Text
$sel:description:CreatePullRequest' :: CreatePullRequest -> Maybe Text
$sel:clientRequestToken:CreatePullRequest' :: CreatePullRequest -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"clientRequestToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientRequestToken,
(Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"title" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
title),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"targets" Text -> [Target] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Target]
targets)
]
)
instance Core.ToPath CreatePullRequest where
toPath :: CreatePullRequest -> ByteString
toPath = ByteString -> CreatePullRequest -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreatePullRequest where
toQuery :: CreatePullRequest -> QueryString
toQuery = QueryString -> CreatePullRequest -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreatePullRequestResponse = CreatePullRequestResponse'
{
CreatePullRequestResponse -> Int
httpStatus :: Prelude.Int,
CreatePullRequestResponse -> PullRequest
pullRequest :: PullRequest
}
deriving (CreatePullRequestResponse -> CreatePullRequestResponse -> Bool
(CreatePullRequestResponse -> CreatePullRequestResponse -> Bool)
-> (CreatePullRequestResponse -> CreatePullRequestResponse -> Bool)
-> Eq CreatePullRequestResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreatePullRequestResponse -> CreatePullRequestResponse -> Bool
$c/= :: CreatePullRequestResponse -> CreatePullRequestResponse -> Bool
== :: CreatePullRequestResponse -> CreatePullRequestResponse -> Bool
$c== :: CreatePullRequestResponse -> CreatePullRequestResponse -> Bool
Prelude.Eq, ReadPrec [CreatePullRequestResponse]
ReadPrec CreatePullRequestResponse
Int -> ReadS CreatePullRequestResponse
ReadS [CreatePullRequestResponse]
(Int -> ReadS CreatePullRequestResponse)
-> ReadS [CreatePullRequestResponse]
-> ReadPrec CreatePullRequestResponse
-> ReadPrec [CreatePullRequestResponse]
-> Read CreatePullRequestResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreatePullRequestResponse]
$creadListPrec :: ReadPrec [CreatePullRequestResponse]
readPrec :: ReadPrec CreatePullRequestResponse
$creadPrec :: ReadPrec CreatePullRequestResponse
readList :: ReadS [CreatePullRequestResponse]
$creadList :: ReadS [CreatePullRequestResponse]
readsPrec :: Int -> ReadS CreatePullRequestResponse
$creadsPrec :: Int -> ReadS CreatePullRequestResponse
Prelude.Read, Int -> CreatePullRequestResponse -> ShowS
[CreatePullRequestResponse] -> ShowS
CreatePullRequestResponse -> String
(Int -> CreatePullRequestResponse -> ShowS)
-> (CreatePullRequestResponse -> String)
-> ([CreatePullRequestResponse] -> ShowS)
-> Show CreatePullRequestResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreatePullRequestResponse] -> ShowS
$cshowList :: [CreatePullRequestResponse] -> ShowS
show :: CreatePullRequestResponse -> String
$cshow :: CreatePullRequestResponse -> String
showsPrec :: Int -> CreatePullRequestResponse -> ShowS
$cshowsPrec :: Int -> CreatePullRequestResponse -> ShowS
Prelude.Show, (forall x.
CreatePullRequestResponse -> Rep CreatePullRequestResponse x)
-> (forall x.
Rep CreatePullRequestResponse x -> CreatePullRequestResponse)
-> Generic CreatePullRequestResponse
forall x.
Rep CreatePullRequestResponse x -> CreatePullRequestResponse
forall x.
CreatePullRequestResponse -> Rep CreatePullRequestResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreatePullRequestResponse x -> CreatePullRequestResponse
$cfrom :: forall x.
CreatePullRequestResponse -> Rep CreatePullRequestResponse x
Prelude.Generic)
newCreatePullRequestResponse ::
Prelude.Int ->
PullRequest ->
CreatePullRequestResponse
newCreatePullRequestResponse :: Int -> PullRequest -> CreatePullRequestResponse
newCreatePullRequestResponse
Int
pHttpStatus_
PullRequest
pPullRequest_ =
CreatePullRequestResponse' :: Int -> PullRequest -> CreatePullRequestResponse
CreatePullRequestResponse'
{ $sel:httpStatus:CreatePullRequestResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:pullRequest:CreatePullRequestResponse' :: PullRequest
pullRequest = PullRequest
pPullRequest_
}
createPullRequestResponse_httpStatus :: Lens.Lens' CreatePullRequestResponse Prelude.Int
createPullRequestResponse_httpStatus :: (Int -> f Int)
-> CreatePullRequestResponse -> f CreatePullRequestResponse
createPullRequestResponse_httpStatus = (CreatePullRequestResponse -> Int)
-> (CreatePullRequestResponse -> Int -> CreatePullRequestResponse)
-> Lens CreatePullRequestResponse CreatePullRequestResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreatePullRequestResponse' :: CreatePullRequestResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreatePullRequestResponse
s@CreatePullRequestResponse' {} Int
a -> CreatePullRequestResponse
s {$sel:httpStatus:CreatePullRequestResponse' :: Int
httpStatus = Int
a} :: CreatePullRequestResponse)
createPullRequestResponse_pullRequest :: Lens.Lens' CreatePullRequestResponse PullRequest
createPullRequestResponse_pullRequest :: (PullRequest -> f PullRequest)
-> CreatePullRequestResponse -> f CreatePullRequestResponse
createPullRequestResponse_pullRequest = (CreatePullRequestResponse -> PullRequest)
-> (CreatePullRequestResponse
-> PullRequest -> CreatePullRequestResponse)
-> Lens
CreatePullRequestResponse
CreatePullRequestResponse
PullRequest
PullRequest
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreatePullRequestResponse' {PullRequest
pullRequest :: PullRequest
$sel:pullRequest:CreatePullRequestResponse' :: CreatePullRequestResponse -> PullRequest
pullRequest} -> PullRequest
pullRequest) (\s :: CreatePullRequestResponse
s@CreatePullRequestResponse' {} PullRequest
a -> CreatePullRequestResponse
s {$sel:pullRequest:CreatePullRequestResponse' :: PullRequest
pullRequest = PullRequest
a} :: CreatePullRequestResponse)
instance Prelude.NFData CreatePullRequestResponse