{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.CommentsForPullRequest
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeCommit.Types.CommentsForPullRequest where

import Amazonka.CodeCommit.Types.Comment
import Amazonka.CodeCommit.Types.Location
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Returns information about comments on a pull request.
--
-- /See:/ 'newCommentsForPullRequest' smart constructor.
data CommentsForPullRequest = CommentsForPullRequest'
  { -- | The full blob ID of the file on which you want to comment on the source
    -- commit.
    CommentsForPullRequest -> Maybe Text
afterBlobId :: Prelude.Maybe Prelude.Text,
    -- | The full commit ID of the commit that was the tip of the source branch
    -- at the time the comment was made.
    CommentsForPullRequest -> Maybe Text
afterCommitId :: Prelude.Maybe Prelude.Text,
    -- | The full blob ID of the file on which you want to comment on the
    -- destination commit.
    CommentsForPullRequest -> Maybe Text
beforeBlobId :: Prelude.Maybe Prelude.Text,
    -- | The full commit ID of the commit that was the tip of the destination
    -- branch when the pull request was created. This commit is superceded by
    -- the after commit in the source branch when and if you merge the source
    -- branch into the destination branch.
    CommentsForPullRequest -> Maybe Text
beforeCommitId :: Prelude.Maybe Prelude.Text,
    -- | An array of comment objects. Each comment object contains information
    -- about a comment on the pull request.
    CommentsForPullRequest -> Maybe [Comment]
comments :: Prelude.Maybe [Comment],
    -- | Location information about the comment on the pull request, including
    -- the file name, line number, and whether the version of the file where
    -- the comment was made is BEFORE (destination branch) or AFTER (source
    -- branch).
    CommentsForPullRequest -> Maybe Location
location :: Prelude.Maybe Location,
    -- | The system-generated ID of the pull request.
    CommentsForPullRequest -> Maybe Text
pullRequestId :: Prelude.Maybe Prelude.Text,
    -- | The name of the repository that contains the pull request.
    CommentsForPullRequest -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text
  }
  deriving (CommentsForPullRequest -> CommentsForPullRequest -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommentsForPullRequest -> CommentsForPullRequest -> Bool
$c/= :: CommentsForPullRequest -> CommentsForPullRequest -> Bool
== :: CommentsForPullRequest -> CommentsForPullRequest -> Bool
$c== :: CommentsForPullRequest -> CommentsForPullRequest -> Bool
Prelude.Eq, ReadPrec [CommentsForPullRequest]
ReadPrec CommentsForPullRequest
Int -> ReadS CommentsForPullRequest
ReadS [CommentsForPullRequest]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CommentsForPullRequest]
$creadListPrec :: ReadPrec [CommentsForPullRequest]
readPrec :: ReadPrec CommentsForPullRequest
$creadPrec :: ReadPrec CommentsForPullRequest
readList :: ReadS [CommentsForPullRequest]
$creadList :: ReadS [CommentsForPullRequest]
readsPrec :: Int -> ReadS CommentsForPullRequest
$creadsPrec :: Int -> ReadS CommentsForPullRequest
Prelude.Read, Int -> CommentsForPullRequest -> ShowS
[CommentsForPullRequest] -> ShowS
CommentsForPullRequest -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CommentsForPullRequest] -> ShowS
$cshowList :: [CommentsForPullRequest] -> ShowS
show :: CommentsForPullRequest -> String
$cshow :: CommentsForPullRequest -> String
showsPrec :: Int -> CommentsForPullRequest -> ShowS
$cshowsPrec :: Int -> CommentsForPullRequest -> ShowS
Prelude.Show, forall x. Rep CommentsForPullRequest x -> CommentsForPullRequest
forall x. CommentsForPullRequest -> Rep CommentsForPullRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CommentsForPullRequest x -> CommentsForPullRequest
$cfrom :: forall x. CommentsForPullRequest -> Rep CommentsForPullRequest x
Prelude.Generic)

-- |
-- Create a value of 'CommentsForPullRequest' 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:
--
-- 'afterBlobId', 'commentsForPullRequest_afterBlobId' - The full blob ID of the file on which you want to comment on the source
-- commit.
--
-- 'afterCommitId', 'commentsForPullRequest_afterCommitId' - The full commit ID of the commit that was the tip of the source branch
-- at the time the comment was made.
--
-- 'beforeBlobId', 'commentsForPullRequest_beforeBlobId' - The full blob ID of the file on which you want to comment on the
-- destination commit.
--
-- 'beforeCommitId', 'commentsForPullRequest_beforeCommitId' - The full commit ID of the commit that was the tip of the destination
-- branch when the pull request was created. This commit is superceded by
-- the after commit in the source branch when and if you merge the source
-- branch into the destination branch.
--
-- 'comments', 'commentsForPullRequest_comments' - An array of comment objects. Each comment object contains information
-- about a comment on the pull request.
--
-- 'location', 'commentsForPullRequest_location' - Location information about the comment on the pull request, including
-- the file name, line number, and whether the version of the file where
-- the comment was made is BEFORE (destination branch) or AFTER (source
-- branch).
--
-- 'pullRequestId', 'commentsForPullRequest_pullRequestId' - The system-generated ID of the pull request.
--
-- 'repositoryName', 'commentsForPullRequest_repositoryName' - The name of the repository that contains the pull request.
newCommentsForPullRequest ::
  CommentsForPullRequest
newCommentsForPullRequest :: CommentsForPullRequest
newCommentsForPullRequest =
  CommentsForPullRequest'
    { $sel:afterBlobId:CommentsForPullRequest' :: Maybe Text
afterBlobId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:afterCommitId:CommentsForPullRequest' :: Maybe Text
afterCommitId = forall a. Maybe a
Prelude.Nothing,
      $sel:beforeBlobId:CommentsForPullRequest' :: Maybe Text
beforeBlobId = forall a. Maybe a
Prelude.Nothing,
      $sel:beforeCommitId:CommentsForPullRequest' :: Maybe Text
beforeCommitId = forall a. Maybe a
Prelude.Nothing,
      $sel:comments:CommentsForPullRequest' :: Maybe [Comment]
comments = forall a. Maybe a
Prelude.Nothing,
      $sel:location:CommentsForPullRequest' :: Maybe Location
location = forall a. Maybe a
Prelude.Nothing,
      $sel:pullRequestId:CommentsForPullRequest' :: Maybe Text
pullRequestId = forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:CommentsForPullRequest' :: Maybe Text
repositoryName = forall a. Maybe a
Prelude.Nothing
    }

-- | The full blob ID of the file on which you want to comment on the source
-- commit.
commentsForPullRequest_afterBlobId :: Lens.Lens' CommentsForPullRequest (Prelude.Maybe Prelude.Text)
commentsForPullRequest_afterBlobId :: Lens' CommentsForPullRequest (Maybe Text)
commentsForPullRequest_afterBlobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentsForPullRequest' {Maybe Text
afterBlobId :: Maybe Text
$sel:afterBlobId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
afterBlobId} -> Maybe Text
afterBlobId) (\s :: CommentsForPullRequest
s@CommentsForPullRequest' {} Maybe Text
a -> CommentsForPullRequest
s {$sel:afterBlobId:CommentsForPullRequest' :: Maybe Text
afterBlobId = Maybe Text
a} :: CommentsForPullRequest)

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

-- | The full blob ID of the file on which you want to comment on the
-- destination commit.
commentsForPullRequest_beforeBlobId :: Lens.Lens' CommentsForPullRequest (Prelude.Maybe Prelude.Text)
commentsForPullRequest_beforeBlobId :: Lens' CommentsForPullRequest (Maybe Text)
commentsForPullRequest_beforeBlobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentsForPullRequest' {Maybe Text
beforeBlobId :: Maybe Text
$sel:beforeBlobId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
beforeBlobId} -> Maybe Text
beforeBlobId) (\s :: CommentsForPullRequest
s@CommentsForPullRequest' {} Maybe Text
a -> CommentsForPullRequest
s {$sel:beforeBlobId:CommentsForPullRequest' :: Maybe Text
beforeBlobId = Maybe Text
a} :: CommentsForPullRequest)

-- | The full commit ID of the commit that was the tip of the destination
-- branch when the pull request was created. This commit is superceded by
-- the after commit in the source branch when and if you merge the source
-- branch into the destination branch.
commentsForPullRequest_beforeCommitId :: Lens.Lens' CommentsForPullRequest (Prelude.Maybe Prelude.Text)
commentsForPullRequest_beforeCommitId :: Lens' CommentsForPullRequest (Maybe Text)
commentsForPullRequest_beforeCommitId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentsForPullRequest' {Maybe Text
beforeCommitId :: Maybe Text
$sel:beforeCommitId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
beforeCommitId} -> Maybe Text
beforeCommitId) (\s :: CommentsForPullRequest
s@CommentsForPullRequest' {} Maybe Text
a -> CommentsForPullRequest
s {$sel:beforeCommitId:CommentsForPullRequest' :: Maybe Text
beforeCommitId = Maybe Text
a} :: CommentsForPullRequest)

-- | An array of comment objects. Each comment object contains information
-- about a comment on the pull request.
commentsForPullRequest_comments :: Lens.Lens' CommentsForPullRequest (Prelude.Maybe [Comment])
commentsForPullRequest_comments :: Lens' CommentsForPullRequest (Maybe [Comment])
commentsForPullRequest_comments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentsForPullRequest' {Maybe [Comment]
comments :: Maybe [Comment]
$sel:comments:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe [Comment]
comments} -> Maybe [Comment]
comments) (\s :: CommentsForPullRequest
s@CommentsForPullRequest' {} Maybe [Comment]
a -> CommentsForPullRequest
s {$sel:comments:CommentsForPullRequest' :: Maybe [Comment]
comments = Maybe [Comment]
a} :: CommentsForPullRequest) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Location information about the comment on the pull request, including
-- the file name, line number, and whether the version of the file where
-- the comment was made is BEFORE (destination branch) or AFTER (source
-- branch).
commentsForPullRequest_location :: Lens.Lens' CommentsForPullRequest (Prelude.Maybe Location)
commentsForPullRequest_location :: Lens' CommentsForPullRequest (Maybe Location)
commentsForPullRequest_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentsForPullRequest' {Maybe Location
location :: Maybe Location
$sel:location:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Location
location} -> Maybe Location
location) (\s :: CommentsForPullRequest
s@CommentsForPullRequest' {} Maybe Location
a -> CommentsForPullRequest
s {$sel:location:CommentsForPullRequest' :: Maybe Location
location = Maybe Location
a} :: CommentsForPullRequest)

-- | The system-generated ID of the pull request.
commentsForPullRequest_pullRequestId :: Lens.Lens' CommentsForPullRequest (Prelude.Maybe Prelude.Text)
commentsForPullRequest_pullRequestId :: Lens' CommentsForPullRequest (Maybe Text)
commentsForPullRequest_pullRequestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommentsForPullRequest' {Maybe Text
pullRequestId :: Maybe Text
$sel:pullRequestId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
pullRequestId} -> Maybe Text
pullRequestId) (\s :: CommentsForPullRequest
s@CommentsForPullRequest' {} Maybe Text
a -> CommentsForPullRequest
s {$sel:pullRequestId:CommentsForPullRequest' :: Maybe Text
pullRequestId = Maybe Text
a} :: CommentsForPullRequest)

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

instance Data.FromJSON CommentsForPullRequest where
  parseJSON :: Value -> Parser CommentsForPullRequest
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CommentsForPullRequest"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Comment]
-> Maybe Location
-> Maybe Text
-> Maybe Text
-> CommentsForPullRequest
CommentsForPullRequest'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"afterBlobId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"afterCommitId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"beforeBlobId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"beforeCommitId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"comments" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"location")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"pullRequestId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"repositoryName")
      )

instance Prelude.Hashable CommentsForPullRequest where
  hashWithSalt :: Int -> CommentsForPullRequest -> Int
hashWithSalt Int
_salt CommentsForPullRequest' {Maybe [Comment]
Maybe Text
Maybe Location
repositoryName :: Maybe Text
pullRequestId :: Maybe Text
location :: Maybe Location
comments :: Maybe [Comment]
beforeCommitId :: Maybe Text
beforeBlobId :: Maybe Text
afterCommitId :: Maybe Text
afterBlobId :: Maybe Text
$sel:repositoryName:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:pullRequestId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:location:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Location
$sel:comments:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe [Comment]
$sel:beforeCommitId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:beforeBlobId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:afterCommitId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:afterBlobId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
afterBlobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
afterCommitId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
beforeBlobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
beforeCommitId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Comment]
comments
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Location
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pullRequestId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
repositoryName

instance Prelude.NFData CommentsForPullRequest where
  rnf :: CommentsForPullRequest -> ()
rnf CommentsForPullRequest' {Maybe [Comment]
Maybe Text
Maybe Location
repositoryName :: Maybe Text
pullRequestId :: Maybe Text
location :: Maybe Location
comments :: Maybe [Comment]
beforeCommitId :: Maybe Text
beforeBlobId :: Maybe Text
afterCommitId :: Maybe Text
afterBlobId :: Maybe Text
$sel:repositoryName:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:pullRequestId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:location:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Location
$sel:comments:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe [Comment]
$sel:beforeCommitId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:beforeBlobId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:afterCommitId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
$sel:afterBlobId:CommentsForPullRequest' :: CommentsForPullRequest -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
afterBlobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
afterCommitId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
beforeBlobId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
beforeCommitId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Comment]
comments
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Location
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pullRequestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
repositoryName