{-# 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.CodeGuruReviewer.Types.CommitDiffSourceCodeType
-- 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.CodeGuruReviewer.Types.CommitDiffSourceCodeType where

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

-- | A type of
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_SourceCodeType SourceCodeType>
-- that specifies the commit diff for a pull request on an associated
-- repository. The @SourceCommit@ and @DestinationCommit@ fields are
-- required to do a pull request code review.
--
-- /See:/ 'newCommitDiffSourceCodeType' smart constructor.
data CommitDiffSourceCodeType = CommitDiffSourceCodeType'
  { -- | The SHA of the destination commit used to generate a commit diff. This
    -- field is required for a pull request code review.
    CommitDiffSourceCodeType -> Maybe Text
destinationCommit :: Prelude.Maybe Prelude.Text,
    -- | The SHA of the merge base of a commit.
    CommitDiffSourceCodeType -> Maybe Text
mergeBaseCommit :: Prelude.Maybe Prelude.Text,
    -- | The SHA of the source commit used to generate a commit diff. This field
    -- is required for a pull request code review.
    CommitDiffSourceCodeType -> Maybe Text
sourceCommit :: Prelude.Maybe Prelude.Text
  }
  deriving (CommitDiffSourceCodeType -> CommitDiffSourceCodeType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommitDiffSourceCodeType -> CommitDiffSourceCodeType -> Bool
$c/= :: CommitDiffSourceCodeType -> CommitDiffSourceCodeType -> Bool
== :: CommitDiffSourceCodeType -> CommitDiffSourceCodeType -> Bool
$c== :: CommitDiffSourceCodeType -> CommitDiffSourceCodeType -> Bool
Prelude.Eq, ReadPrec [CommitDiffSourceCodeType]
ReadPrec CommitDiffSourceCodeType
Int -> ReadS CommitDiffSourceCodeType
ReadS [CommitDiffSourceCodeType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CommitDiffSourceCodeType]
$creadListPrec :: ReadPrec [CommitDiffSourceCodeType]
readPrec :: ReadPrec CommitDiffSourceCodeType
$creadPrec :: ReadPrec CommitDiffSourceCodeType
readList :: ReadS [CommitDiffSourceCodeType]
$creadList :: ReadS [CommitDiffSourceCodeType]
readsPrec :: Int -> ReadS CommitDiffSourceCodeType
$creadsPrec :: Int -> ReadS CommitDiffSourceCodeType
Prelude.Read, Int -> CommitDiffSourceCodeType -> ShowS
[CommitDiffSourceCodeType] -> ShowS
CommitDiffSourceCodeType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CommitDiffSourceCodeType] -> ShowS
$cshowList :: [CommitDiffSourceCodeType] -> ShowS
show :: CommitDiffSourceCodeType -> String
$cshow :: CommitDiffSourceCodeType -> String
showsPrec :: Int -> CommitDiffSourceCodeType -> ShowS
$cshowsPrec :: Int -> CommitDiffSourceCodeType -> ShowS
Prelude.Show, forall x.
Rep CommitDiffSourceCodeType x -> CommitDiffSourceCodeType
forall x.
CommitDiffSourceCodeType -> Rep CommitDiffSourceCodeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CommitDiffSourceCodeType x -> CommitDiffSourceCodeType
$cfrom :: forall x.
CommitDiffSourceCodeType -> Rep CommitDiffSourceCodeType x
Prelude.Generic)

-- |
-- Create a value of 'CommitDiffSourceCodeType' 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:
--
-- 'destinationCommit', 'commitDiffSourceCodeType_destinationCommit' - The SHA of the destination commit used to generate a commit diff. This
-- field is required for a pull request code review.
--
-- 'mergeBaseCommit', 'commitDiffSourceCodeType_mergeBaseCommit' - The SHA of the merge base of a commit.
--
-- 'sourceCommit', 'commitDiffSourceCodeType_sourceCommit' - The SHA of the source commit used to generate a commit diff. This field
-- is required for a pull request code review.
newCommitDiffSourceCodeType ::
  CommitDiffSourceCodeType
newCommitDiffSourceCodeType :: CommitDiffSourceCodeType
newCommitDiffSourceCodeType =
  CommitDiffSourceCodeType'
    { $sel:destinationCommit:CommitDiffSourceCodeType' :: Maybe Text
destinationCommit =
        forall a. Maybe a
Prelude.Nothing,
      $sel:mergeBaseCommit:CommitDiffSourceCodeType' :: Maybe Text
mergeBaseCommit = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceCommit:CommitDiffSourceCodeType' :: Maybe Text
sourceCommit = forall a. Maybe a
Prelude.Nothing
    }

-- | The SHA of the destination commit used to generate a commit diff. This
-- field is required for a pull request code review.
commitDiffSourceCodeType_destinationCommit :: Lens.Lens' CommitDiffSourceCodeType (Prelude.Maybe Prelude.Text)
commitDiffSourceCodeType_destinationCommit :: Lens' CommitDiffSourceCodeType (Maybe Text)
commitDiffSourceCodeType_destinationCommit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitDiffSourceCodeType' {Maybe Text
destinationCommit :: Maybe Text
$sel:destinationCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
destinationCommit} -> Maybe Text
destinationCommit) (\s :: CommitDiffSourceCodeType
s@CommitDiffSourceCodeType' {} Maybe Text
a -> CommitDiffSourceCodeType
s {$sel:destinationCommit:CommitDiffSourceCodeType' :: Maybe Text
destinationCommit = Maybe Text
a} :: CommitDiffSourceCodeType)

-- | The SHA of the merge base of a commit.
commitDiffSourceCodeType_mergeBaseCommit :: Lens.Lens' CommitDiffSourceCodeType (Prelude.Maybe Prelude.Text)
commitDiffSourceCodeType_mergeBaseCommit :: Lens' CommitDiffSourceCodeType (Maybe Text)
commitDiffSourceCodeType_mergeBaseCommit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitDiffSourceCodeType' {Maybe Text
mergeBaseCommit :: Maybe Text
$sel:mergeBaseCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
mergeBaseCommit} -> Maybe Text
mergeBaseCommit) (\s :: CommitDiffSourceCodeType
s@CommitDiffSourceCodeType' {} Maybe Text
a -> CommitDiffSourceCodeType
s {$sel:mergeBaseCommit:CommitDiffSourceCodeType' :: Maybe Text
mergeBaseCommit = Maybe Text
a} :: CommitDiffSourceCodeType)

-- | The SHA of the source commit used to generate a commit diff. This field
-- is required for a pull request code review.
commitDiffSourceCodeType_sourceCommit :: Lens.Lens' CommitDiffSourceCodeType (Prelude.Maybe Prelude.Text)
commitDiffSourceCodeType_sourceCommit :: Lens' CommitDiffSourceCodeType (Maybe Text)
commitDiffSourceCodeType_sourceCommit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CommitDiffSourceCodeType' {Maybe Text
sourceCommit :: Maybe Text
$sel:sourceCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
sourceCommit} -> Maybe Text
sourceCommit) (\s :: CommitDiffSourceCodeType
s@CommitDiffSourceCodeType' {} Maybe Text
a -> CommitDiffSourceCodeType
s {$sel:sourceCommit:CommitDiffSourceCodeType' :: Maybe Text
sourceCommit = Maybe Text
a} :: CommitDiffSourceCodeType)

instance Data.FromJSON CommitDiffSourceCodeType where
  parseJSON :: Value -> Parser CommitDiffSourceCodeType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CommitDiffSourceCodeType"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> CommitDiffSourceCodeType
CommitDiffSourceCodeType'
            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
"DestinationCommit")
            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
"MergeBaseCommit")
            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
"SourceCommit")
      )

instance Prelude.Hashable CommitDiffSourceCodeType where
  hashWithSalt :: Int -> CommitDiffSourceCodeType -> Int
hashWithSalt Int
_salt CommitDiffSourceCodeType' {Maybe Text
sourceCommit :: Maybe Text
mergeBaseCommit :: Maybe Text
destinationCommit :: Maybe Text
$sel:sourceCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
$sel:mergeBaseCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
$sel:destinationCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationCommit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mergeBaseCommit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceCommit

instance Prelude.NFData CommitDiffSourceCodeType where
  rnf :: CommitDiffSourceCodeType -> ()
rnf CommitDiffSourceCodeType' {Maybe Text
sourceCommit :: Maybe Text
mergeBaseCommit :: Maybe Text
destinationCommit :: Maybe Text
$sel:sourceCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
$sel:mergeBaseCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
$sel:destinationCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationCommit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mergeBaseCommit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceCommit

instance Data.ToJSON CommitDiffSourceCodeType where
  toJSON :: CommitDiffSourceCodeType -> Value
toJSON CommitDiffSourceCodeType' {Maybe Text
sourceCommit :: Maybe Text
mergeBaseCommit :: Maybe Text
destinationCommit :: Maybe Text
$sel:sourceCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
$sel:mergeBaseCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
$sel:destinationCommit:CommitDiffSourceCodeType' :: CommitDiffSourceCodeType -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DestinationCommit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
destinationCommit,
            (Key
"MergeBaseCommit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
mergeBaseCommit,
            (Key
"SourceCommit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sourceCommit
          ]
      )