{-# 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.GetCommentsForPullRequest
(
getCommentsForPullRequest
, GetCommentsForPullRequest
, gcfprAfterCommitId
, gcfprNextToken
, gcfprBeforeCommitId
, gcfprRepositoryName
, gcfprMaxResults
, gcfprPullRequestId
, getCommentsForPullRequestResponse
, GetCommentsForPullRequestResponse
, gcfprrsCommentsForPullRequestData
, gcfprrsNextToken
, gcfprrsResponseStatus
) where
import Network.AWS.CodeCommit.Types
import Network.AWS.CodeCommit.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetCommentsForPullRequest = GetCommentsForPullRequest'
{ _gcfprAfterCommitId :: !(Maybe Text)
, _gcfprNextToken :: !(Maybe Text)
, _gcfprBeforeCommitId :: !(Maybe Text)
, _gcfprRepositoryName :: !(Maybe Text)
, _gcfprMaxResults :: !(Maybe Int)
, _gcfprPullRequestId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getCommentsForPullRequest
:: Text
-> GetCommentsForPullRequest
getCommentsForPullRequest pPullRequestId_ =
GetCommentsForPullRequest'
{ _gcfprAfterCommitId = Nothing
, _gcfprNextToken = Nothing
, _gcfprBeforeCommitId = Nothing
, _gcfprRepositoryName = Nothing
, _gcfprMaxResults = Nothing
, _gcfprPullRequestId = pPullRequestId_
}
gcfprAfterCommitId :: Lens' GetCommentsForPullRequest (Maybe Text)
gcfprAfterCommitId = lens _gcfprAfterCommitId (\ s a -> s{_gcfprAfterCommitId = a})
gcfprNextToken :: Lens' GetCommentsForPullRequest (Maybe Text)
gcfprNextToken = lens _gcfprNextToken (\ s a -> s{_gcfprNextToken = a})
gcfprBeforeCommitId :: Lens' GetCommentsForPullRequest (Maybe Text)
gcfprBeforeCommitId = lens _gcfprBeforeCommitId (\ s a -> s{_gcfprBeforeCommitId = a})
gcfprRepositoryName :: Lens' GetCommentsForPullRequest (Maybe Text)
gcfprRepositoryName = lens _gcfprRepositoryName (\ s a -> s{_gcfprRepositoryName = a})
gcfprMaxResults :: Lens' GetCommentsForPullRequest (Maybe Int)
gcfprMaxResults = lens _gcfprMaxResults (\ s a -> s{_gcfprMaxResults = a})
gcfprPullRequestId :: Lens' GetCommentsForPullRequest Text
gcfprPullRequestId = lens _gcfprPullRequestId (\ s a -> s{_gcfprPullRequestId = a})
instance AWSPager GetCommentsForPullRequest where
page rq rs
| stop (rs ^. gcfprrsNextToken) = Nothing
| stop (rs ^. gcfprrsCommentsForPullRequestData) =
Nothing
| otherwise =
Just $ rq & gcfprNextToken .~ rs ^. gcfprrsNextToken
instance AWSRequest GetCommentsForPullRequest where
type Rs GetCommentsForPullRequest =
GetCommentsForPullRequestResponse
request = postJSON codeCommit
response
= receiveJSON
(\ s h x ->
GetCommentsForPullRequestResponse' <$>
(x .?> "commentsForPullRequestData" .!@ mempty) <*>
(x .?> "nextToken")
<*> (pure (fromEnum s)))
instance Hashable GetCommentsForPullRequest where
instance NFData GetCommentsForPullRequest where
instance ToHeaders GetCommentsForPullRequest where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("CodeCommit_20150413.GetCommentsForPullRequest" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetCommentsForPullRequest where
toJSON GetCommentsForPullRequest'{..}
= object
(catMaybes
[("afterCommitId" .=) <$> _gcfprAfterCommitId,
("nextToken" .=) <$> _gcfprNextToken,
("beforeCommitId" .=) <$> _gcfprBeforeCommitId,
("repositoryName" .=) <$> _gcfprRepositoryName,
("maxResults" .=) <$> _gcfprMaxResults,
Just ("pullRequestId" .= _gcfprPullRequestId)])
instance ToPath GetCommentsForPullRequest where
toPath = const "/"
instance ToQuery GetCommentsForPullRequest where
toQuery = const mempty
data GetCommentsForPullRequestResponse = GetCommentsForPullRequestResponse'
{ _gcfprrsCommentsForPullRequestData :: !(Maybe [CommentsForPullRequest])
, _gcfprrsNextToken :: !(Maybe Text)
, _gcfprrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getCommentsForPullRequestResponse
:: Int
-> GetCommentsForPullRequestResponse
getCommentsForPullRequestResponse pResponseStatus_ =
GetCommentsForPullRequestResponse'
{ _gcfprrsCommentsForPullRequestData = Nothing
, _gcfprrsNextToken = Nothing
, _gcfprrsResponseStatus = pResponseStatus_
}
gcfprrsCommentsForPullRequestData :: Lens' GetCommentsForPullRequestResponse [CommentsForPullRequest]
gcfprrsCommentsForPullRequestData = lens _gcfprrsCommentsForPullRequestData (\ s a -> s{_gcfprrsCommentsForPullRequestData = a}) . _Default . _Coerce
gcfprrsNextToken :: Lens' GetCommentsForPullRequestResponse (Maybe Text)
gcfprrsNextToken = lens _gcfprrsNextToken (\ s a -> s{_gcfprrsNextToken = a})
gcfprrsResponseStatus :: Lens' GetCommentsForPullRequestResponse Int
gcfprrsResponseStatus = lens _gcfprrsResponseStatus (\ s a -> s{_gcfprrsResponseStatus = a})
instance NFData GetCommentsForPullRequestResponse
where