{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CodeCommit.GetCommentsForPullRequest
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns comments made on a pull request.
--
-- Reaction counts might include numbers from user identities who were
-- deleted after the reaction was made. For a count of reactions from
-- active identities, use GetCommentReactions.
--
-- This operation returns paginated results.
module Amazonka.CodeCommit.GetCommentsForPullRequest
  ( -- * Creating a Request
    GetCommentsForPullRequest (..),
    newGetCommentsForPullRequest,

    -- * Request Lenses
    getCommentsForPullRequest_afterCommitId,
    getCommentsForPullRequest_nextToken,
    getCommentsForPullRequest_beforeCommitId,
    getCommentsForPullRequest_repositoryName,
    getCommentsForPullRequest_maxResults,
    getCommentsForPullRequest_pullRequestId,

    -- * Destructuring the Response
    GetCommentsForPullRequestResponse (..),
    newGetCommentsForPullRequestResponse,

    -- * Response Lenses
    getCommentsForPullRequestResponse_commentsForPullRequestData,
    getCommentsForPullRequestResponse_nextToken,
    getCommentsForPullRequestResponse_httpStatus,
  )
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

-- | /See:/ 'newGetCommentsForPullRequest' smart constructor.
data GetCommentsForPullRequest = GetCommentsForPullRequest'
  { -- | The full commit ID of the commit in the source branch that was the tip
    -- of the branch at the time the comment was made.
    GetCommentsForPullRequest -> Maybe Text
afterCommitId :: Prelude.Maybe Prelude.Text,
    -- | An enumeration token that, when provided in a request, returns the next
    -- batch of the results.
    GetCommentsForPullRequest -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The full commit ID of the commit in the destination branch that was the
    -- tip of the branch at the time the pull request was created.
    GetCommentsForPullRequest -> Maybe Text
beforeCommitId :: Prelude.Maybe Prelude.Text,
    -- | The name of the repository that contains the pull request.
    GetCommentsForPullRequest -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text,
    -- | A non-zero, non-negative integer used to limit the number of returned
    -- results. The default is 100 comments. You can return up to 500 comments
    -- with a single request.
    GetCommentsForPullRequest -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The system-generated ID of the pull request. To get this ID, use
    -- ListPullRequests.
    GetCommentsForPullRequest -> Text
pullRequestId :: Prelude.Text
  }
  deriving (GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool
(GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool)
-> (GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool)
-> Eq GetCommentsForPullRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool
$c/= :: GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool
== :: GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool
$c== :: GetCommentsForPullRequest -> GetCommentsForPullRequest -> Bool
Prelude.Eq, ReadPrec [GetCommentsForPullRequest]
ReadPrec GetCommentsForPullRequest
Int -> ReadS GetCommentsForPullRequest
ReadS [GetCommentsForPullRequest]
(Int -> ReadS GetCommentsForPullRequest)
-> ReadS [GetCommentsForPullRequest]
-> ReadPrec GetCommentsForPullRequest
-> ReadPrec [GetCommentsForPullRequest]
-> Read GetCommentsForPullRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCommentsForPullRequest]
$creadListPrec :: ReadPrec [GetCommentsForPullRequest]
readPrec :: ReadPrec GetCommentsForPullRequest
$creadPrec :: ReadPrec GetCommentsForPullRequest
readList :: ReadS [GetCommentsForPullRequest]
$creadList :: ReadS [GetCommentsForPullRequest]
readsPrec :: Int -> ReadS GetCommentsForPullRequest
$creadsPrec :: Int -> ReadS GetCommentsForPullRequest
Prelude.Read, Int -> GetCommentsForPullRequest -> ShowS
[GetCommentsForPullRequest] -> ShowS
GetCommentsForPullRequest -> String
(Int -> GetCommentsForPullRequest -> ShowS)
-> (GetCommentsForPullRequest -> String)
-> ([GetCommentsForPullRequest] -> ShowS)
-> Show GetCommentsForPullRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCommentsForPullRequest] -> ShowS
$cshowList :: [GetCommentsForPullRequest] -> ShowS
show :: GetCommentsForPullRequest -> String
$cshow :: GetCommentsForPullRequest -> String
showsPrec :: Int -> GetCommentsForPullRequest -> ShowS
$cshowsPrec :: Int -> GetCommentsForPullRequest -> ShowS
Prelude.Show, (forall x.
 GetCommentsForPullRequest -> Rep GetCommentsForPullRequest x)
-> (forall x.
    Rep GetCommentsForPullRequest x -> GetCommentsForPullRequest)
-> Generic GetCommentsForPullRequest
forall x.
Rep GetCommentsForPullRequest x -> GetCommentsForPullRequest
forall x.
GetCommentsForPullRequest -> Rep GetCommentsForPullRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCommentsForPullRequest x -> GetCommentsForPullRequest
$cfrom :: forall x.
GetCommentsForPullRequest -> Rep GetCommentsForPullRequest x
Prelude.Generic)

-- |
-- Create a value of 'GetCommentsForPullRequest' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'afterCommitId', 'getCommentsForPullRequest_afterCommitId' - The full commit ID of the commit in the source branch that was the tip
-- of the branch at the time the comment was made.
--
-- 'nextToken', 'getCommentsForPullRequest_nextToken' - An enumeration token that, when provided in a request, returns the next
-- batch of the results.
--
-- 'beforeCommitId', 'getCommentsForPullRequest_beforeCommitId' - The full commit ID of the commit in the destination branch that was the
-- tip of the branch at the time the pull request was created.
--
-- 'repositoryName', 'getCommentsForPullRequest_repositoryName' - The name of the repository that contains the pull request.
--
-- 'maxResults', 'getCommentsForPullRequest_maxResults' - A non-zero, non-negative integer used to limit the number of returned
-- results. The default is 100 comments. You can return up to 500 comments
-- with a single request.
--
-- 'pullRequestId', 'getCommentsForPullRequest_pullRequestId' - The system-generated ID of the pull request. To get this ID, use
-- ListPullRequests.
newGetCommentsForPullRequest ::
  -- | 'pullRequestId'
  Prelude.Text ->
  GetCommentsForPullRequest
newGetCommentsForPullRequest :: Text -> GetCommentsForPullRequest
newGetCommentsForPullRequest Text
pPullRequestId_ =
  GetCommentsForPullRequest' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Text
-> GetCommentsForPullRequest
GetCommentsForPullRequest'
    { $sel:afterCommitId:GetCommentsForPullRequest' :: Maybe Text
afterCommitId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetCommentsForPullRequest' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:beforeCommitId:GetCommentsForPullRequest' :: Maybe Text
beforeCommitId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:GetCommentsForPullRequest' :: Maybe Text
repositoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:GetCommentsForPullRequest' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:pullRequestId:GetCommentsForPullRequest' :: Text
pullRequestId = Text
pPullRequestId_
    }

-- | The full commit ID of the commit in the source branch that was the tip
-- of the branch at the time the comment was made.
getCommentsForPullRequest_afterCommitId :: Lens.Lens' GetCommentsForPullRequest (Prelude.Maybe Prelude.Text)
getCommentsForPullRequest_afterCommitId :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForPullRequest -> f GetCommentsForPullRequest
getCommentsForPullRequest_afterCommitId = (GetCommentsForPullRequest -> Maybe Text)
-> (GetCommentsForPullRequest
    -> Maybe Text -> GetCommentsForPullRequest)
-> Lens
     GetCommentsForPullRequest
     GetCommentsForPullRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequest' {Maybe Text
afterCommitId :: Maybe Text
$sel:afterCommitId:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
afterCommitId} -> Maybe Text
afterCommitId) (\s :: GetCommentsForPullRequest
s@GetCommentsForPullRequest' {} Maybe Text
a -> GetCommentsForPullRequest
s {$sel:afterCommitId:GetCommentsForPullRequest' :: Maybe Text
afterCommitId = Maybe Text
a} :: GetCommentsForPullRequest)

-- | An enumeration token that, when provided in a request, returns the next
-- batch of the results.
getCommentsForPullRequest_nextToken :: Lens.Lens' GetCommentsForPullRequest (Prelude.Maybe Prelude.Text)
getCommentsForPullRequest_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForPullRequest -> f GetCommentsForPullRequest
getCommentsForPullRequest_nextToken = (GetCommentsForPullRequest -> Maybe Text)
-> (GetCommentsForPullRequest
    -> Maybe Text -> GetCommentsForPullRequest)
-> Lens
     GetCommentsForPullRequest
     GetCommentsForPullRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequest' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetCommentsForPullRequest
s@GetCommentsForPullRequest' {} Maybe Text
a -> GetCommentsForPullRequest
s {$sel:nextToken:GetCommentsForPullRequest' :: Maybe Text
nextToken = Maybe Text
a} :: GetCommentsForPullRequest)

-- | The full commit ID of the commit in the destination branch that was the
-- tip of the branch at the time the pull request was created.
getCommentsForPullRequest_beforeCommitId :: Lens.Lens' GetCommentsForPullRequest (Prelude.Maybe Prelude.Text)
getCommentsForPullRequest_beforeCommitId :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForPullRequest -> f GetCommentsForPullRequest
getCommentsForPullRequest_beforeCommitId = (GetCommentsForPullRequest -> Maybe Text)
-> (GetCommentsForPullRequest
    -> Maybe Text -> GetCommentsForPullRequest)
-> Lens
     GetCommentsForPullRequest
     GetCommentsForPullRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequest' {Maybe Text
beforeCommitId :: Maybe Text
$sel:beforeCommitId:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
beforeCommitId} -> Maybe Text
beforeCommitId) (\s :: GetCommentsForPullRequest
s@GetCommentsForPullRequest' {} Maybe Text
a -> GetCommentsForPullRequest
s {$sel:beforeCommitId:GetCommentsForPullRequest' :: Maybe Text
beforeCommitId = Maybe Text
a} :: GetCommentsForPullRequest)

-- | The name of the repository that contains the pull request.
getCommentsForPullRequest_repositoryName :: Lens.Lens' GetCommentsForPullRequest (Prelude.Maybe Prelude.Text)
getCommentsForPullRequest_repositoryName :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForPullRequest -> f GetCommentsForPullRequest
getCommentsForPullRequest_repositoryName = (GetCommentsForPullRequest -> Maybe Text)
-> (GetCommentsForPullRequest
    -> Maybe Text -> GetCommentsForPullRequest)
-> Lens
     GetCommentsForPullRequest
     GetCommentsForPullRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequest' {Maybe Text
repositoryName :: Maybe Text
$sel:repositoryName:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
repositoryName} -> Maybe Text
repositoryName) (\s :: GetCommentsForPullRequest
s@GetCommentsForPullRequest' {} Maybe Text
a -> GetCommentsForPullRequest
s {$sel:repositoryName:GetCommentsForPullRequest' :: Maybe Text
repositoryName = Maybe Text
a} :: GetCommentsForPullRequest)

-- | A non-zero, non-negative integer used to limit the number of returned
-- results. The default is 100 comments. You can return up to 500 comments
-- with a single request.
getCommentsForPullRequest_maxResults :: Lens.Lens' GetCommentsForPullRequest (Prelude.Maybe Prelude.Int)
getCommentsForPullRequest_maxResults :: (Maybe Int -> f (Maybe Int))
-> GetCommentsForPullRequest -> f GetCommentsForPullRequest
getCommentsForPullRequest_maxResults = (GetCommentsForPullRequest -> Maybe Int)
-> (GetCommentsForPullRequest
    -> Maybe Int -> GetCommentsForPullRequest)
-> Lens
     GetCommentsForPullRequest
     GetCommentsForPullRequest
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequest' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: GetCommentsForPullRequest
s@GetCommentsForPullRequest' {} Maybe Int
a -> GetCommentsForPullRequest
s {$sel:maxResults:GetCommentsForPullRequest' :: Maybe Int
maxResults = Maybe Int
a} :: GetCommentsForPullRequest)

-- | The system-generated ID of the pull request. To get this ID, use
-- ListPullRequests.
getCommentsForPullRequest_pullRequestId :: Lens.Lens' GetCommentsForPullRequest Prelude.Text
getCommentsForPullRequest_pullRequestId :: (Text -> f Text)
-> GetCommentsForPullRequest -> f GetCommentsForPullRequest
getCommentsForPullRequest_pullRequestId = (GetCommentsForPullRequest -> Text)
-> (GetCommentsForPullRequest -> Text -> GetCommentsForPullRequest)
-> Lens
     GetCommentsForPullRequest GetCommentsForPullRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequest' {Text
pullRequestId :: Text
$sel:pullRequestId:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Text
pullRequestId} -> Text
pullRequestId) (\s :: GetCommentsForPullRequest
s@GetCommentsForPullRequest' {} Text
a -> GetCommentsForPullRequest
s {$sel:pullRequestId:GetCommentsForPullRequest' :: Text
pullRequestId = Text
a} :: GetCommentsForPullRequest)

instance Core.AWSPager GetCommentsForPullRequest where
  page :: GetCommentsForPullRequest
-> AWSResponse GetCommentsForPullRequest
-> Maybe GetCommentsForPullRequest
page GetCommentsForPullRequest
rq AWSResponse GetCommentsForPullRequest
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetCommentsForPullRequest
GetCommentsForPullRequestResponse
rs
            GetCommentsForPullRequestResponse
-> Getting (First Text) GetCommentsForPullRequestResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetCommentsForPullRequestResponse
-> Const (First Text) GetCommentsForPullRequestResponse
Lens' GetCommentsForPullRequestResponse (Maybe Text)
getCommentsForPullRequestResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetCommentsForPullRequestResponse
 -> Const (First Text) GetCommentsForPullRequestResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetCommentsForPullRequestResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetCommentsForPullRequest
forall a. Maybe a
Prelude.Nothing
    | Maybe [CommentsForPullRequest] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetCommentsForPullRequest
GetCommentsForPullRequestResponse
rs
            GetCommentsForPullRequestResponse
-> Getting
     (First [CommentsForPullRequest])
     GetCommentsForPullRequestResponse
     [CommentsForPullRequest]
-> Maybe [CommentsForPullRequest]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [CommentsForPullRequest]
 -> Const
      (First [CommentsForPullRequest]) (Maybe [CommentsForPullRequest]))
-> GetCommentsForPullRequestResponse
-> Const
     (First [CommentsForPullRequest]) GetCommentsForPullRequestResponse
Lens'
  GetCommentsForPullRequestResponse (Maybe [CommentsForPullRequest])
getCommentsForPullRequestResponse_commentsForPullRequestData
              ((Maybe [CommentsForPullRequest]
  -> Const
       (First [CommentsForPullRequest]) (Maybe [CommentsForPullRequest]))
 -> GetCommentsForPullRequestResponse
 -> Const
      (First [CommentsForPullRequest]) GetCommentsForPullRequestResponse)
-> (([CommentsForPullRequest]
     -> Const (First [CommentsForPullRequest]) [CommentsForPullRequest])
    -> Maybe [CommentsForPullRequest]
    -> Const
         (First [CommentsForPullRequest]) (Maybe [CommentsForPullRequest]))
-> Getting
     (First [CommentsForPullRequest])
     GetCommentsForPullRequestResponse
     [CommentsForPullRequest]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CommentsForPullRequest]
 -> Const (First [CommentsForPullRequest]) [CommentsForPullRequest])
-> Maybe [CommentsForPullRequest]
-> Const
     (First [CommentsForPullRequest]) (Maybe [CommentsForPullRequest])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetCommentsForPullRequest
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetCommentsForPullRequest -> Maybe GetCommentsForPullRequest
forall a. a -> Maybe a
Prelude.Just (GetCommentsForPullRequest -> Maybe GetCommentsForPullRequest)
-> GetCommentsForPullRequest -> Maybe GetCommentsForPullRequest
forall a b. (a -> b) -> a -> b
Prelude.$
        GetCommentsForPullRequest
rq
          GetCommentsForPullRequest
-> (GetCommentsForPullRequest -> GetCommentsForPullRequest)
-> GetCommentsForPullRequest
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetCommentsForPullRequest -> Identity GetCommentsForPullRequest
Lens
  GetCommentsForPullRequest
  GetCommentsForPullRequest
  (Maybe Text)
  (Maybe Text)
getCommentsForPullRequest_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetCommentsForPullRequest -> Identity GetCommentsForPullRequest)
-> Maybe Text
-> GetCommentsForPullRequest
-> GetCommentsForPullRequest
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetCommentsForPullRequest
GetCommentsForPullRequestResponse
rs
          GetCommentsForPullRequestResponse
-> Getting (First Text) GetCommentsForPullRequestResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetCommentsForPullRequestResponse
-> Const (First Text) GetCommentsForPullRequestResponse
Lens' GetCommentsForPullRequestResponse (Maybe Text)
getCommentsForPullRequestResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetCommentsForPullRequestResponse
 -> Const (First Text) GetCommentsForPullRequestResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetCommentsForPullRequestResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetCommentsForPullRequest where
  type
    AWSResponse GetCommentsForPullRequest =
      GetCommentsForPullRequestResponse
  request :: GetCommentsForPullRequest -> Request GetCommentsForPullRequest
request = Service
-> GetCommentsForPullRequest -> Request GetCommentsForPullRequest
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetCommentsForPullRequest
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCommentsForPullRequest)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetCommentsForPullRequest))
-> Logger
-> Service
-> Proxy GetCommentsForPullRequest
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCommentsForPullRequest)))
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 ->
          Maybe [CommentsForPullRequest]
-> Maybe Text -> Int -> GetCommentsForPullRequestResponse
GetCommentsForPullRequestResponse'
            (Maybe [CommentsForPullRequest]
 -> Maybe Text -> Int -> GetCommentsForPullRequestResponse)
-> Either String (Maybe [CommentsForPullRequest])
-> Either
     String (Maybe Text -> Int -> GetCommentsForPullRequestResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text -> Either String (Maybe (Maybe [CommentsForPullRequest]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"commentsForPullRequestData"
                            Either String (Maybe (Maybe [CommentsForPullRequest]))
-> Maybe [CommentsForPullRequest]
-> Either String (Maybe [CommentsForPullRequest])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [CommentsForPullRequest]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String (Maybe Text -> Int -> GetCommentsForPullRequestResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetCommentsForPullRequestResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> GetCommentsForPullRequestResponse)
-> Either String Int
-> Either String GetCommentsForPullRequestResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable GetCommentsForPullRequest

instance Prelude.NFData GetCommentsForPullRequest

instance Core.ToHeaders GetCommentsForPullRequest where
  toHeaders :: GetCommentsForPullRequest -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetCommentsForPullRequest -> 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.GetCommentsForPullRequest" ::
                          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 GetCommentsForPullRequest where
  toJSON :: GetCommentsForPullRequest -> Value
toJSON GetCommentsForPullRequest' {Maybe Int
Maybe Text
Text
pullRequestId :: Text
maxResults :: Maybe Int
repositoryName :: Maybe Text
beforeCommitId :: Maybe Text
nextToken :: Maybe Text
afterCommitId :: Maybe Text
$sel:pullRequestId:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Text
$sel:maxResults:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Int
$sel:repositoryName:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
$sel:beforeCommitId:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
$sel:nextToken:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
$sel:afterCommitId:GetCommentsForPullRequest' :: GetCommentsForPullRequest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"afterCommitId" 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
afterCommitId,
            (Text
"nextToken" 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
nextToken,
            (Text
"beforeCommitId" 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
beforeCommitId,
            (Text
"repositoryName" 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
repositoryName,
            (Text
"maxResults" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults,
            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)
          ]
      )

instance Core.ToPath GetCommentsForPullRequest where
  toPath :: GetCommentsForPullRequest -> ByteString
toPath = ByteString -> GetCommentsForPullRequest -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GetCommentsForPullRequest where
  toQuery :: GetCommentsForPullRequest -> QueryString
toQuery = QueryString -> GetCommentsForPullRequest -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetCommentsForPullRequestResponse' smart constructor.
data GetCommentsForPullRequestResponse = GetCommentsForPullRequestResponse'
  { -- | An array of comment objects on the pull request.
    GetCommentsForPullRequestResponse -> Maybe [CommentsForPullRequest]
commentsForPullRequestData :: Prelude.Maybe [CommentsForPullRequest],
    -- | An enumeration token that can be used in a request to return the next
    -- batch of the results.
    GetCommentsForPullRequestResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetCommentsForPullRequestResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetCommentsForPullRequestResponse
-> GetCommentsForPullRequestResponse -> Bool
(GetCommentsForPullRequestResponse
 -> GetCommentsForPullRequestResponse -> Bool)
-> (GetCommentsForPullRequestResponse
    -> GetCommentsForPullRequestResponse -> Bool)
-> Eq GetCommentsForPullRequestResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCommentsForPullRequestResponse
-> GetCommentsForPullRequestResponse -> Bool
$c/= :: GetCommentsForPullRequestResponse
-> GetCommentsForPullRequestResponse -> Bool
== :: GetCommentsForPullRequestResponse
-> GetCommentsForPullRequestResponse -> Bool
$c== :: GetCommentsForPullRequestResponse
-> GetCommentsForPullRequestResponse -> Bool
Prelude.Eq, ReadPrec [GetCommentsForPullRequestResponse]
ReadPrec GetCommentsForPullRequestResponse
Int -> ReadS GetCommentsForPullRequestResponse
ReadS [GetCommentsForPullRequestResponse]
(Int -> ReadS GetCommentsForPullRequestResponse)
-> ReadS [GetCommentsForPullRequestResponse]
-> ReadPrec GetCommentsForPullRequestResponse
-> ReadPrec [GetCommentsForPullRequestResponse]
-> Read GetCommentsForPullRequestResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCommentsForPullRequestResponse]
$creadListPrec :: ReadPrec [GetCommentsForPullRequestResponse]
readPrec :: ReadPrec GetCommentsForPullRequestResponse
$creadPrec :: ReadPrec GetCommentsForPullRequestResponse
readList :: ReadS [GetCommentsForPullRequestResponse]
$creadList :: ReadS [GetCommentsForPullRequestResponse]
readsPrec :: Int -> ReadS GetCommentsForPullRequestResponse
$creadsPrec :: Int -> ReadS GetCommentsForPullRequestResponse
Prelude.Read, Int -> GetCommentsForPullRequestResponse -> ShowS
[GetCommentsForPullRequestResponse] -> ShowS
GetCommentsForPullRequestResponse -> String
(Int -> GetCommentsForPullRequestResponse -> ShowS)
-> (GetCommentsForPullRequestResponse -> String)
-> ([GetCommentsForPullRequestResponse] -> ShowS)
-> Show GetCommentsForPullRequestResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCommentsForPullRequestResponse] -> ShowS
$cshowList :: [GetCommentsForPullRequestResponse] -> ShowS
show :: GetCommentsForPullRequestResponse -> String
$cshow :: GetCommentsForPullRequestResponse -> String
showsPrec :: Int -> GetCommentsForPullRequestResponse -> ShowS
$cshowsPrec :: Int -> GetCommentsForPullRequestResponse -> ShowS
Prelude.Show, (forall x.
 GetCommentsForPullRequestResponse
 -> Rep GetCommentsForPullRequestResponse x)
-> (forall x.
    Rep GetCommentsForPullRequestResponse x
    -> GetCommentsForPullRequestResponse)
-> Generic GetCommentsForPullRequestResponse
forall x.
Rep GetCommentsForPullRequestResponse x
-> GetCommentsForPullRequestResponse
forall x.
GetCommentsForPullRequestResponse
-> Rep GetCommentsForPullRequestResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCommentsForPullRequestResponse x
-> GetCommentsForPullRequestResponse
$cfrom :: forall x.
GetCommentsForPullRequestResponse
-> Rep GetCommentsForPullRequestResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCommentsForPullRequestResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'commentsForPullRequestData', 'getCommentsForPullRequestResponse_commentsForPullRequestData' - An array of comment objects on the pull request.
--
-- 'nextToken', 'getCommentsForPullRequestResponse_nextToken' - An enumeration token that can be used in a request to return the next
-- batch of the results.
--
-- 'httpStatus', 'getCommentsForPullRequestResponse_httpStatus' - The response's http status code.
newGetCommentsForPullRequestResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCommentsForPullRequestResponse
newGetCommentsForPullRequestResponse :: Int -> GetCommentsForPullRequestResponse
newGetCommentsForPullRequestResponse Int
pHttpStatus_ =
  GetCommentsForPullRequestResponse' :: Maybe [CommentsForPullRequest]
-> Maybe Text -> Int -> GetCommentsForPullRequestResponse
GetCommentsForPullRequestResponse'
    { $sel:commentsForPullRequestData:GetCommentsForPullRequestResponse' :: Maybe [CommentsForPullRequest]
commentsForPullRequestData =
        Maybe [CommentsForPullRequest]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetCommentsForPullRequestResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCommentsForPullRequestResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of comment objects on the pull request.
getCommentsForPullRequestResponse_commentsForPullRequestData :: Lens.Lens' GetCommentsForPullRequestResponse (Prelude.Maybe [CommentsForPullRequest])
getCommentsForPullRequestResponse_commentsForPullRequestData :: (Maybe [CommentsForPullRequest]
 -> f (Maybe [CommentsForPullRequest]))
-> GetCommentsForPullRequestResponse
-> f GetCommentsForPullRequestResponse
getCommentsForPullRequestResponse_commentsForPullRequestData = (GetCommentsForPullRequestResponse
 -> Maybe [CommentsForPullRequest])
-> (GetCommentsForPullRequestResponse
    -> Maybe [CommentsForPullRequest]
    -> GetCommentsForPullRequestResponse)
-> Lens'
     GetCommentsForPullRequestResponse (Maybe [CommentsForPullRequest])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequestResponse' {Maybe [CommentsForPullRequest]
commentsForPullRequestData :: Maybe [CommentsForPullRequest]
$sel:commentsForPullRequestData:GetCommentsForPullRequestResponse' :: GetCommentsForPullRequestResponse -> Maybe [CommentsForPullRequest]
commentsForPullRequestData} -> Maybe [CommentsForPullRequest]
commentsForPullRequestData) (\s :: GetCommentsForPullRequestResponse
s@GetCommentsForPullRequestResponse' {} Maybe [CommentsForPullRequest]
a -> GetCommentsForPullRequestResponse
s {$sel:commentsForPullRequestData:GetCommentsForPullRequestResponse' :: Maybe [CommentsForPullRequest]
commentsForPullRequestData = Maybe [CommentsForPullRequest]
a} :: GetCommentsForPullRequestResponse) ((Maybe [CommentsForPullRequest]
  -> f (Maybe [CommentsForPullRequest]))
 -> GetCommentsForPullRequestResponse
 -> f GetCommentsForPullRequestResponse)
-> ((Maybe [CommentsForPullRequest]
     -> f (Maybe [CommentsForPullRequest]))
    -> Maybe [CommentsForPullRequest]
    -> f (Maybe [CommentsForPullRequest]))
-> (Maybe [CommentsForPullRequest]
    -> f (Maybe [CommentsForPullRequest]))
-> GetCommentsForPullRequestResponse
-> f GetCommentsForPullRequestResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CommentsForPullRequest]
  [CommentsForPullRequest]
  [CommentsForPullRequest]
  [CommentsForPullRequest]
-> Iso
     (Maybe [CommentsForPullRequest])
     (Maybe [CommentsForPullRequest])
     (Maybe [CommentsForPullRequest])
     (Maybe [CommentsForPullRequest])
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 AnIso
  [CommentsForPullRequest]
  [CommentsForPullRequest]
  [CommentsForPullRequest]
  [CommentsForPullRequest]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An enumeration token that can be used in a request to return the next
-- batch of the results.
getCommentsForPullRequestResponse_nextToken :: Lens.Lens' GetCommentsForPullRequestResponse (Prelude.Maybe Prelude.Text)
getCommentsForPullRequestResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForPullRequestResponse
-> f GetCommentsForPullRequestResponse
getCommentsForPullRequestResponse_nextToken = (GetCommentsForPullRequestResponse -> Maybe Text)
-> (GetCommentsForPullRequestResponse
    -> Maybe Text -> GetCommentsForPullRequestResponse)
-> Lens' GetCommentsForPullRequestResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequestResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetCommentsForPullRequestResponse' :: GetCommentsForPullRequestResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetCommentsForPullRequestResponse
s@GetCommentsForPullRequestResponse' {} Maybe Text
a -> GetCommentsForPullRequestResponse
s {$sel:nextToken:GetCommentsForPullRequestResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetCommentsForPullRequestResponse)

-- | The response's http status code.
getCommentsForPullRequestResponse_httpStatus :: Lens.Lens' GetCommentsForPullRequestResponse Prelude.Int
getCommentsForPullRequestResponse_httpStatus :: (Int -> f Int)
-> GetCommentsForPullRequestResponse
-> f GetCommentsForPullRequestResponse
getCommentsForPullRequestResponse_httpStatus = (GetCommentsForPullRequestResponse -> Int)
-> (GetCommentsForPullRequestResponse
    -> Int -> GetCommentsForPullRequestResponse)
-> Lens
     GetCommentsForPullRequestResponse
     GetCommentsForPullRequestResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForPullRequestResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCommentsForPullRequestResponse' :: GetCommentsForPullRequestResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCommentsForPullRequestResponse
s@GetCommentsForPullRequestResponse' {} Int
a -> GetCommentsForPullRequestResponse
s {$sel:httpStatus:GetCommentsForPullRequestResponse' :: Int
httpStatus = Int
a} :: GetCommentsForPullRequestResponse)

instance
  Prelude.NFData
    GetCommentsForPullRequestResponse