{-# 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.GetCommentsForComparedCommit
-- 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 information about comments made on the comparison between two
-- commits.
--
-- 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.GetCommentsForComparedCommit
  ( -- * Creating a Request
    GetCommentsForComparedCommit (..),
    newGetCommentsForComparedCommit,

    -- * Request Lenses
    getCommentsForComparedCommit_nextToken,
    getCommentsForComparedCommit_beforeCommitId,
    getCommentsForComparedCommit_maxResults,
    getCommentsForComparedCommit_repositoryName,
    getCommentsForComparedCommit_afterCommitId,

    -- * Destructuring the Response
    GetCommentsForComparedCommitResponse (..),
    newGetCommentsForComparedCommitResponse,

    -- * Response Lenses
    getCommentsForComparedCommitResponse_commentsForComparedCommitData,
    getCommentsForComparedCommitResponse_nextToken,
    getCommentsForComparedCommitResponse_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:/ 'newGetCommentsForComparedCommit' smart constructor.
data GetCommentsForComparedCommit = GetCommentsForComparedCommit'
  { -- | An enumeration token that when provided in a request, returns the next
    -- batch of the results.
    GetCommentsForComparedCommit -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | To establish the directionality of the comparison, the full commit ID of
    -- the before commit.
    GetCommentsForComparedCommit -> Maybe Text
beforeCommitId :: Prelude.Maybe Prelude.Text,
    -- | A non-zero, non-negative integer used to limit the number of returned
    -- results. The default is 100 comments, but you can configure up to 500.
    GetCommentsForComparedCommit -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The name of the repository where you want to compare commits.
    GetCommentsForComparedCommit -> Text
repositoryName :: Prelude.Text,
    -- | To establish the directionality of the comparison, the full commit ID of
    -- the after commit.
    GetCommentsForComparedCommit -> Text
afterCommitId :: Prelude.Text
  }
  deriving (GetCommentsForComparedCommit
-> GetCommentsForComparedCommit -> Bool
(GetCommentsForComparedCommit
 -> GetCommentsForComparedCommit -> Bool)
-> (GetCommentsForComparedCommit
    -> GetCommentsForComparedCommit -> Bool)
-> Eq GetCommentsForComparedCommit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCommentsForComparedCommit
-> GetCommentsForComparedCommit -> Bool
$c/= :: GetCommentsForComparedCommit
-> GetCommentsForComparedCommit -> Bool
== :: GetCommentsForComparedCommit
-> GetCommentsForComparedCommit -> Bool
$c== :: GetCommentsForComparedCommit
-> GetCommentsForComparedCommit -> Bool
Prelude.Eq, ReadPrec [GetCommentsForComparedCommit]
ReadPrec GetCommentsForComparedCommit
Int -> ReadS GetCommentsForComparedCommit
ReadS [GetCommentsForComparedCommit]
(Int -> ReadS GetCommentsForComparedCommit)
-> ReadS [GetCommentsForComparedCommit]
-> ReadPrec GetCommentsForComparedCommit
-> ReadPrec [GetCommentsForComparedCommit]
-> Read GetCommentsForComparedCommit
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCommentsForComparedCommit]
$creadListPrec :: ReadPrec [GetCommentsForComparedCommit]
readPrec :: ReadPrec GetCommentsForComparedCommit
$creadPrec :: ReadPrec GetCommentsForComparedCommit
readList :: ReadS [GetCommentsForComparedCommit]
$creadList :: ReadS [GetCommentsForComparedCommit]
readsPrec :: Int -> ReadS GetCommentsForComparedCommit
$creadsPrec :: Int -> ReadS GetCommentsForComparedCommit
Prelude.Read, Int -> GetCommentsForComparedCommit -> ShowS
[GetCommentsForComparedCommit] -> ShowS
GetCommentsForComparedCommit -> String
(Int -> GetCommentsForComparedCommit -> ShowS)
-> (GetCommentsForComparedCommit -> String)
-> ([GetCommentsForComparedCommit] -> ShowS)
-> Show GetCommentsForComparedCommit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCommentsForComparedCommit] -> ShowS
$cshowList :: [GetCommentsForComparedCommit] -> ShowS
show :: GetCommentsForComparedCommit -> String
$cshow :: GetCommentsForComparedCommit -> String
showsPrec :: Int -> GetCommentsForComparedCommit -> ShowS
$cshowsPrec :: Int -> GetCommentsForComparedCommit -> ShowS
Prelude.Show, (forall x.
 GetCommentsForComparedCommit -> Rep GetCommentsForComparedCommit x)
-> (forall x.
    Rep GetCommentsForComparedCommit x -> GetCommentsForComparedCommit)
-> Generic GetCommentsForComparedCommit
forall x.
Rep GetCommentsForComparedCommit x -> GetCommentsForComparedCommit
forall x.
GetCommentsForComparedCommit -> Rep GetCommentsForComparedCommit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCommentsForComparedCommit x -> GetCommentsForComparedCommit
$cfrom :: forall x.
GetCommentsForComparedCommit -> Rep GetCommentsForComparedCommit x
Prelude.Generic)

-- |
-- Create a value of 'GetCommentsForComparedCommit' 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:
--
-- 'nextToken', 'getCommentsForComparedCommit_nextToken' - An enumeration token that when provided in a request, returns the next
-- batch of the results.
--
-- 'beforeCommitId', 'getCommentsForComparedCommit_beforeCommitId' - To establish the directionality of the comparison, the full commit ID of
-- the before commit.
--
-- 'maxResults', 'getCommentsForComparedCommit_maxResults' - A non-zero, non-negative integer used to limit the number of returned
-- results. The default is 100 comments, but you can configure up to 500.
--
-- 'repositoryName', 'getCommentsForComparedCommit_repositoryName' - The name of the repository where you want to compare commits.
--
-- 'afterCommitId', 'getCommentsForComparedCommit_afterCommitId' - To establish the directionality of the comparison, the full commit ID of
-- the after commit.
newGetCommentsForComparedCommit ::
  -- | 'repositoryName'
  Prelude.Text ->
  -- | 'afterCommitId'
  Prelude.Text ->
  GetCommentsForComparedCommit
newGetCommentsForComparedCommit :: Text -> Text -> GetCommentsForComparedCommit
newGetCommentsForComparedCommit
  Text
pRepositoryName_
  Text
pAfterCommitId_ =
    GetCommentsForComparedCommit' :: Maybe Text
-> Maybe Text
-> Maybe Int
-> Text
-> Text
-> GetCommentsForComparedCommit
GetCommentsForComparedCommit'
      { $sel:nextToken:GetCommentsForComparedCommit' :: Maybe Text
nextToken =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:beforeCommitId:GetCommentsForComparedCommit' :: Maybe Text
beforeCommitId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:maxResults:GetCommentsForComparedCommit' :: Maybe Int
maxResults = Maybe Int
forall a. Maybe a
Prelude.Nothing,
        $sel:repositoryName:GetCommentsForComparedCommit' :: Text
repositoryName = Text
pRepositoryName_,
        $sel:afterCommitId:GetCommentsForComparedCommit' :: Text
afterCommitId = Text
pAfterCommitId_
      }

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

-- | To establish the directionality of the comparison, the full commit ID of
-- the before commit.
getCommentsForComparedCommit_beforeCommitId :: Lens.Lens' GetCommentsForComparedCommit (Prelude.Maybe Prelude.Text)
getCommentsForComparedCommit_beforeCommitId :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForComparedCommit -> f GetCommentsForComparedCommit
getCommentsForComparedCommit_beforeCommitId = (GetCommentsForComparedCommit -> Maybe Text)
-> (GetCommentsForComparedCommit
    -> Maybe Text -> GetCommentsForComparedCommit)
-> Lens
     GetCommentsForComparedCommit
     GetCommentsForComparedCommit
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForComparedCommit' {Maybe Text
beforeCommitId :: Maybe Text
$sel:beforeCommitId:GetCommentsForComparedCommit' :: GetCommentsForComparedCommit -> Maybe Text
beforeCommitId} -> Maybe Text
beforeCommitId) (\s :: GetCommentsForComparedCommit
s@GetCommentsForComparedCommit' {} Maybe Text
a -> GetCommentsForComparedCommit
s {$sel:beforeCommitId:GetCommentsForComparedCommit' :: Maybe Text
beforeCommitId = Maybe Text
a} :: GetCommentsForComparedCommit)

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

-- | The name of the repository where you want to compare commits.
getCommentsForComparedCommit_repositoryName :: Lens.Lens' GetCommentsForComparedCommit Prelude.Text
getCommentsForComparedCommit_repositoryName :: (Text -> f Text)
-> GetCommentsForComparedCommit -> f GetCommentsForComparedCommit
getCommentsForComparedCommit_repositoryName = (GetCommentsForComparedCommit -> Text)
-> (GetCommentsForComparedCommit
    -> Text -> GetCommentsForComparedCommit)
-> Lens
     GetCommentsForComparedCommit GetCommentsForComparedCommit Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForComparedCommit' {Text
repositoryName :: Text
$sel:repositoryName:GetCommentsForComparedCommit' :: GetCommentsForComparedCommit -> Text
repositoryName} -> Text
repositoryName) (\s :: GetCommentsForComparedCommit
s@GetCommentsForComparedCommit' {} Text
a -> GetCommentsForComparedCommit
s {$sel:repositoryName:GetCommentsForComparedCommit' :: Text
repositoryName = Text
a} :: GetCommentsForComparedCommit)

-- | To establish the directionality of the comparison, the full commit ID of
-- the after commit.
getCommentsForComparedCommit_afterCommitId :: Lens.Lens' GetCommentsForComparedCommit Prelude.Text
getCommentsForComparedCommit_afterCommitId :: (Text -> f Text)
-> GetCommentsForComparedCommit -> f GetCommentsForComparedCommit
getCommentsForComparedCommit_afterCommitId = (GetCommentsForComparedCommit -> Text)
-> (GetCommentsForComparedCommit
    -> Text -> GetCommentsForComparedCommit)
-> Lens
     GetCommentsForComparedCommit GetCommentsForComparedCommit Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForComparedCommit' {Text
afterCommitId :: Text
$sel:afterCommitId:GetCommentsForComparedCommit' :: GetCommentsForComparedCommit -> Text
afterCommitId} -> Text
afterCommitId) (\s :: GetCommentsForComparedCommit
s@GetCommentsForComparedCommit' {} Text
a -> GetCommentsForComparedCommit
s {$sel:afterCommitId:GetCommentsForComparedCommit' :: Text
afterCommitId = Text
a} :: GetCommentsForComparedCommit)

instance Core.AWSPager GetCommentsForComparedCommit where
  page :: GetCommentsForComparedCommit
-> AWSResponse GetCommentsForComparedCommit
-> Maybe GetCommentsForComparedCommit
page GetCommentsForComparedCommit
rq AWSResponse GetCommentsForComparedCommit
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetCommentsForComparedCommit
GetCommentsForComparedCommitResponse
rs
            GetCommentsForComparedCommitResponse
-> Getting (First Text) GetCommentsForComparedCommitResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetCommentsForComparedCommitResponse
-> Const (First Text) GetCommentsForComparedCommitResponse
Lens' GetCommentsForComparedCommitResponse (Maybe Text)
getCommentsForComparedCommitResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetCommentsForComparedCommitResponse
 -> Const (First Text) GetCommentsForComparedCommitResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetCommentsForComparedCommitResponse 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 GetCommentsForComparedCommit
forall a. Maybe a
Prelude.Nothing
    | Maybe [CommentsForComparedCommit] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetCommentsForComparedCommit
GetCommentsForComparedCommitResponse
rs
            GetCommentsForComparedCommitResponse
-> Getting
     (First [CommentsForComparedCommit])
     GetCommentsForComparedCommitResponse
     [CommentsForComparedCommit]
-> Maybe [CommentsForComparedCommit]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [CommentsForComparedCommit]
 -> Const
      (First [CommentsForComparedCommit])
      (Maybe [CommentsForComparedCommit]))
-> GetCommentsForComparedCommitResponse
-> Const
     (First [CommentsForComparedCommit])
     GetCommentsForComparedCommitResponse
Lens'
  GetCommentsForComparedCommitResponse
  (Maybe [CommentsForComparedCommit])
getCommentsForComparedCommitResponse_commentsForComparedCommitData
              ((Maybe [CommentsForComparedCommit]
  -> Const
       (First [CommentsForComparedCommit])
       (Maybe [CommentsForComparedCommit]))
 -> GetCommentsForComparedCommitResponse
 -> Const
      (First [CommentsForComparedCommit])
      GetCommentsForComparedCommitResponse)
-> (([CommentsForComparedCommit]
     -> Const
          (First [CommentsForComparedCommit]) [CommentsForComparedCommit])
    -> Maybe [CommentsForComparedCommit]
    -> Const
         (First [CommentsForComparedCommit])
         (Maybe [CommentsForComparedCommit]))
-> Getting
     (First [CommentsForComparedCommit])
     GetCommentsForComparedCommitResponse
     [CommentsForComparedCommit]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CommentsForComparedCommit]
 -> Const
      (First [CommentsForComparedCommit]) [CommentsForComparedCommit])
-> Maybe [CommentsForComparedCommit]
-> Const
     (First [CommentsForComparedCommit])
     (Maybe [CommentsForComparedCommit])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe GetCommentsForComparedCommit
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      GetCommentsForComparedCommit -> Maybe GetCommentsForComparedCommit
forall a. a -> Maybe a
Prelude.Just (GetCommentsForComparedCommit
 -> Maybe GetCommentsForComparedCommit)
-> GetCommentsForComparedCommit
-> Maybe GetCommentsForComparedCommit
forall a b. (a -> b) -> a -> b
Prelude.$
        GetCommentsForComparedCommit
rq
          GetCommentsForComparedCommit
-> (GetCommentsForComparedCommit -> GetCommentsForComparedCommit)
-> GetCommentsForComparedCommit
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetCommentsForComparedCommit
-> Identity GetCommentsForComparedCommit
Lens
  GetCommentsForComparedCommit
  GetCommentsForComparedCommit
  (Maybe Text)
  (Maybe Text)
getCommentsForComparedCommit_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> GetCommentsForComparedCommit
 -> Identity GetCommentsForComparedCommit)
-> Maybe Text
-> GetCommentsForComparedCommit
-> GetCommentsForComparedCommit
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetCommentsForComparedCommit
GetCommentsForComparedCommitResponse
rs
          GetCommentsForComparedCommitResponse
-> Getting (First Text) GetCommentsForComparedCommitResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetCommentsForComparedCommitResponse
-> Const (First Text) GetCommentsForComparedCommitResponse
Lens' GetCommentsForComparedCommitResponse (Maybe Text)
getCommentsForComparedCommitResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> GetCommentsForComparedCommitResponse
 -> Const (First Text) GetCommentsForComparedCommitResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetCommentsForComparedCommitResponse 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 GetCommentsForComparedCommit where
  type
    AWSResponse GetCommentsForComparedCommit =
      GetCommentsForComparedCommitResponse
  request :: GetCommentsForComparedCommit
-> Request GetCommentsForComparedCommit
request = Service
-> GetCommentsForComparedCommit
-> Request GetCommentsForComparedCommit
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetCommentsForComparedCommit
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCommentsForComparedCommit)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetCommentsForComparedCommit))
-> Logger
-> Service
-> Proxy GetCommentsForComparedCommit
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCommentsForComparedCommit)))
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 [CommentsForComparedCommit]
-> Maybe Text -> Int -> GetCommentsForComparedCommitResponse
GetCommentsForComparedCommitResponse'
            (Maybe [CommentsForComparedCommit]
 -> Maybe Text -> Int -> GetCommentsForComparedCommitResponse)
-> Either String (Maybe [CommentsForComparedCommit])
-> Either
     String (Maybe Text -> Int -> GetCommentsForComparedCommitResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object
-> Text
-> Either String (Maybe (Maybe [CommentsForComparedCommit]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"commentsForComparedCommitData"
                            Either String (Maybe (Maybe [CommentsForComparedCommit]))
-> Maybe [CommentsForComparedCommit]
-> Either String (Maybe [CommentsForComparedCommit])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [CommentsForComparedCommit]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String (Maybe Text -> Int -> GetCommentsForComparedCommitResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetCommentsForComparedCommitResponse)
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 -> GetCommentsForComparedCommitResponse)
-> Either String Int
-> Either String GetCommentsForComparedCommitResponse
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
    GetCommentsForComparedCommit

instance Prelude.NFData GetCommentsForComparedCommit

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

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

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

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

-- |
-- Create a value of 'GetCommentsForComparedCommitResponse' 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:
--
-- 'commentsForComparedCommitData', 'getCommentsForComparedCommitResponse_commentsForComparedCommitData' - A list of comment objects on the compared commit.
--
-- 'nextToken', 'getCommentsForComparedCommitResponse_nextToken' - An enumeration token that can be used in a request to return the next
-- batch of the results.
--
-- 'httpStatus', 'getCommentsForComparedCommitResponse_httpStatus' - The response's http status code.
newGetCommentsForComparedCommitResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCommentsForComparedCommitResponse
newGetCommentsForComparedCommitResponse :: Int -> GetCommentsForComparedCommitResponse
newGetCommentsForComparedCommitResponse Int
pHttpStatus_ =
  GetCommentsForComparedCommitResponse' :: Maybe [CommentsForComparedCommit]
-> Maybe Text -> Int -> GetCommentsForComparedCommitResponse
GetCommentsForComparedCommitResponse'
    { $sel:commentsForComparedCommitData:GetCommentsForComparedCommitResponse' :: Maybe [CommentsForComparedCommit]
commentsForComparedCommitData =
        Maybe [CommentsForComparedCommit]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetCommentsForComparedCommitResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCommentsForComparedCommitResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of comment objects on the compared commit.
getCommentsForComparedCommitResponse_commentsForComparedCommitData :: Lens.Lens' GetCommentsForComparedCommitResponse (Prelude.Maybe [CommentsForComparedCommit])
getCommentsForComparedCommitResponse_commentsForComparedCommitData :: (Maybe [CommentsForComparedCommit]
 -> f (Maybe [CommentsForComparedCommit]))
-> GetCommentsForComparedCommitResponse
-> f GetCommentsForComparedCommitResponse
getCommentsForComparedCommitResponse_commentsForComparedCommitData = (GetCommentsForComparedCommitResponse
 -> Maybe [CommentsForComparedCommit])
-> (GetCommentsForComparedCommitResponse
    -> Maybe [CommentsForComparedCommit]
    -> GetCommentsForComparedCommitResponse)
-> Lens'
     GetCommentsForComparedCommitResponse
     (Maybe [CommentsForComparedCommit])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForComparedCommitResponse' {Maybe [CommentsForComparedCommit]
commentsForComparedCommitData :: Maybe [CommentsForComparedCommit]
$sel:commentsForComparedCommitData:GetCommentsForComparedCommitResponse' :: GetCommentsForComparedCommitResponse
-> Maybe [CommentsForComparedCommit]
commentsForComparedCommitData} -> Maybe [CommentsForComparedCommit]
commentsForComparedCommitData) (\s :: GetCommentsForComparedCommitResponse
s@GetCommentsForComparedCommitResponse' {} Maybe [CommentsForComparedCommit]
a -> GetCommentsForComparedCommitResponse
s {$sel:commentsForComparedCommitData:GetCommentsForComparedCommitResponse' :: Maybe [CommentsForComparedCommit]
commentsForComparedCommitData = Maybe [CommentsForComparedCommit]
a} :: GetCommentsForComparedCommitResponse) ((Maybe [CommentsForComparedCommit]
  -> f (Maybe [CommentsForComparedCommit]))
 -> GetCommentsForComparedCommitResponse
 -> f GetCommentsForComparedCommitResponse)
-> ((Maybe [CommentsForComparedCommit]
     -> f (Maybe [CommentsForComparedCommit]))
    -> Maybe [CommentsForComparedCommit]
    -> f (Maybe [CommentsForComparedCommit]))
-> (Maybe [CommentsForComparedCommit]
    -> f (Maybe [CommentsForComparedCommit]))
-> GetCommentsForComparedCommitResponse
-> f GetCommentsForComparedCommitResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CommentsForComparedCommit]
  [CommentsForComparedCommit]
  [CommentsForComparedCommit]
  [CommentsForComparedCommit]
-> Iso
     (Maybe [CommentsForComparedCommit])
     (Maybe [CommentsForComparedCommit])
     (Maybe [CommentsForComparedCommit])
     (Maybe [CommentsForComparedCommit])
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
  [CommentsForComparedCommit]
  [CommentsForComparedCommit]
  [CommentsForComparedCommit]
  [CommentsForComparedCommit]
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.
getCommentsForComparedCommitResponse_nextToken :: Lens.Lens' GetCommentsForComparedCommitResponse (Prelude.Maybe Prelude.Text)
getCommentsForComparedCommitResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetCommentsForComparedCommitResponse
-> f GetCommentsForComparedCommitResponse
getCommentsForComparedCommitResponse_nextToken = (GetCommentsForComparedCommitResponse -> Maybe Text)
-> (GetCommentsForComparedCommitResponse
    -> Maybe Text -> GetCommentsForComparedCommitResponse)
-> Lens' GetCommentsForComparedCommitResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCommentsForComparedCommitResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetCommentsForComparedCommitResponse' :: GetCommentsForComparedCommitResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetCommentsForComparedCommitResponse
s@GetCommentsForComparedCommitResponse' {} Maybe Text
a -> GetCommentsForComparedCommitResponse
s {$sel:nextToken:GetCommentsForComparedCommitResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetCommentsForComparedCommitResponse)

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

instance
  Prelude.NFData
    GetCommentsForComparedCommitResponse