{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.CodeCommit.CreatePullRequest
(
createPullRequest
, CreatePullRequest
, cprClientRequestToken
, cprDescription
, cprTitle
, cprTargets
, createPullRequestResponse
, CreatePullRequestResponse
, cprrsResponseStatus
, cprrsPullRequest
) where
import Network.AWS.CodeCommit.Types
import Network.AWS.CodeCommit.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreatePullRequest = CreatePullRequest'
{ _cprClientRequestToken :: !(Maybe Text)
, _cprDescription :: !(Maybe Text)
, _cprTitle :: !Text
, _cprTargets :: ![Target]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createPullRequest
:: Text
-> CreatePullRequest
createPullRequest pTitle_ =
CreatePullRequest'
{ _cprClientRequestToken = Nothing
, _cprDescription = Nothing
, _cprTitle = pTitle_
, _cprTargets = mempty
}
cprClientRequestToken :: Lens' CreatePullRequest (Maybe Text)
cprClientRequestToken = lens _cprClientRequestToken (\ s a -> s{_cprClientRequestToken = a})
cprDescription :: Lens' CreatePullRequest (Maybe Text)
cprDescription = lens _cprDescription (\ s a -> s{_cprDescription = a})
cprTitle :: Lens' CreatePullRequest Text
cprTitle = lens _cprTitle (\ s a -> s{_cprTitle = a})
cprTargets :: Lens' CreatePullRequest [Target]
cprTargets = lens _cprTargets (\ s a -> s{_cprTargets = a}) . _Coerce
instance AWSRequest CreatePullRequest where
type Rs CreatePullRequest = CreatePullRequestResponse
request = postJSON codeCommit
response
= receiveJSON
(\ s h x ->
CreatePullRequestResponse' <$>
(pure (fromEnum s)) <*> (x .:> "pullRequest"))
instance Hashable CreatePullRequest where
instance NFData CreatePullRequest where
instance ToHeaders CreatePullRequest where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("CodeCommit_20150413.CreatePullRequest" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreatePullRequest where
toJSON CreatePullRequest'{..}
= object
(catMaybes
[("clientRequestToken" .=) <$>
_cprClientRequestToken,
("description" .=) <$> _cprDescription,
Just ("title" .= _cprTitle),
Just ("targets" .= _cprTargets)])
instance ToPath CreatePullRequest where
toPath = const "/"
instance ToQuery CreatePullRequest where
toQuery = const mempty
data CreatePullRequestResponse = CreatePullRequestResponse'
{ _cprrsResponseStatus :: !Int
, _cprrsPullRequest :: !PullRequest
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createPullRequestResponse
:: Int
-> PullRequest
-> CreatePullRequestResponse
createPullRequestResponse pResponseStatus_ pPullRequest_ =
CreatePullRequestResponse'
{_cprrsResponseStatus = pResponseStatus_, _cprrsPullRequest = pPullRequest_}
cprrsResponseStatus :: Lens' CreatePullRequestResponse Int
cprrsResponseStatus = lens _cprrsResponseStatus (\ s a -> s{_cprrsResponseStatus = a})
cprrsPullRequest :: Lens' CreatePullRequestResponse PullRequest
cprrsPullRequest = lens _cprrsPullRequest (\ s a -> s{_cprrsPullRequest = a})
instance NFData CreatePullRequestResponse where