{-# 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.BranchDiffSourceCodeType
-- 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)
module Amazonka.CodeGuruReviewer.Types.BranchDiffSourceCodeType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A type of
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_SourceCodeType SourceCodeType>
-- that specifies a code diff between a source and destination branch in an
-- associated repository.
--
-- /See:/ 'newBranchDiffSourceCodeType' smart constructor.
data BranchDiffSourceCodeType = BranchDiffSourceCodeType'
  { -- | The source branch for a diff in an associated repository.
    BranchDiffSourceCodeType -> Text
sourceBranchName :: Prelude.Text,
    -- | The destination branch for a diff in an associated repository.
    BranchDiffSourceCodeType -> Text
destinationBranchName :: Prelude.Text
  }
  deriving (BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool
(BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool)
-> (BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool)
-> Eq BranchDiffSourceCodeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool
$c/= :: BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool
== :: BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool
$c== :: BranchDiffSourceCodeType -> BranchDiffSourceCodeType -> Bool
Prelude.Eq, ReadPrec [BranchDiffSourceCodeType]
ReadPrec BranchDiffSourceCodeType
Int -> ReadS BranchDiffSourceCodeType
ReadS [BranchDiffSourceCodeType]
(Int -> ReadS BranchDiffSourceCodeType)
-> ReadS [BranchDiffSourceCodeType]
-> ReadPrec BranchDiffSourceCodeType
-> ReadPrec [BranchDiffSourceCodeType]
-> Read BranchDiffSourceCodeType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BranchDiffSourceCodeType]
$creadListPrec :: ReadPrec [BranchDiffSourceCodeType]
readPrec :: ReadPrec BranchDiffSourceCodeType
$creadPrec :: ReadPrec BranchDiffSourceCodeType
readList :: ReadS [BranchDiffSourceCodeType]
$creadList :: ReadS [BranchDiffSourceCodeType]
readsPrec :: Int -> ReadS BranchDiffSourceCodeType
$creadsPrec :: Int -> ReadS BranchDiffSourceCodeType
Prelude.Read, Int -> BranchDiffSourceCodeType -> ShowS
[BranchDiffSourceCodeType] -> ShowS
BranchDiffSourceCodeType -> String
(Int -> BranchDiffSourceCodeType -> ShowS)
-> (BranchDiffSourceCodeType -> String)
-> ([BranchDiffSourceCodeType] -> ShowS)
-> Show BranchDiffSourceCodeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BranchDiffSourceCodeType] -> ShowS
$cshowList :: [BranchDiffSourceCodeType] -> ShowS
show :: BranchDiffSourceCodeType -> String
$cshow :: BranchDiffSourceCodeType -> String
showsPrec :: Int -> BranchDiffSourceCodeType -> ShowS
$cshowsPrec :: Int -> BranchDiffSourceCodeType -> ShowS
Prelude.Show, (forall x.
 BranchDiffSourceCodeType -> Rep BranchDiffSourceCodeType x)
-> (forall x.
    Rep BranchDiffSourceCodeType x -> BranchDiffSourceCodeType)
-> Generic BranchDiffSourceCodeType
forall x.
Rep BranchDiffSourceCodeType x -> BranchDiffSourceCodeType
forall x.
BranchDiffSourceCodeType -> Rep BranchDiffSourceCodeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BranchDiffSourceCodeType x -> BranchDiffSourceCodeType
$cfrom :: forall x.
BranchDiffSourceCodeType -> Rep BranchDiffSourceCodeType x
Prelude.Generic)

-- |
-- Create a value of 'BranchDiffSourceCodeType' 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:
--
-- 'sourceBranchName', 'branchDiffSourceCodeType_sourceBranchName' - The source branch for a diff in an associated repository.
--
-- 'destinationBranchName', 'branchDiffSourceCodeType_destinationBranchName' - The destination branch for a diff in an associated repository.
newBranchDiffSourceCodeType ::
  -- | 'sourceBranchName'
  Prelude.Text ->
  -- | 'destinationBranchName'
  Prelude.Text ->
  BranchDiffSourceCodeType
newBranchDiffSourceCodeType :: Text -> Text -> BranchDiffSourceCodeType
newBranchDiffSourceCodeType
  Text
pSourceBranchName_
  Text
pDestinationBranchName_ =
    BranchDiffSourceCodeType' :: Text -> Text -> BranchDiffSourceCodeType
BranchDiffSourceCodeType'
      { $sel:sourceBranchName:BranchDiffSourceCodeType' :: Text
sourceBranchName =
          Text
pSourceBranchName_,
        $sel:destinationBranchName:BranchDiffSourceCodeType' :: Text
destinationBranchName = Text
pDestinationBranchName_
      }

-- | The source branch for a diff in an associated repository.
branchDiffSourceCodeType_sourceBranchName :: Lens.Lens' BranchDiffSourceCodeType Prelude.Text
branchDiffSourceCodeType_sourceBranchName :: (Text -> f Text)
-> BranchDiffSourceCodeType -> f BranchDiffSourceCodeType
branchDiffSourceCodeType_sourceBranchName = (BranchDiffSourceCodeType -> Text)
-> (BranchDiffSourceCodeType -> Text -> BranchDiffSourceCodeType)
-> Lens BranchDiffSourceCodeType BranchDiffSourceCodeType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BranchDiffSourceCodeType' {Text
sourceBranchName :: Text
$sel:sourceBranchName:BranchDiffSourceCodeType' :: BranchDiffSourceCodeType -> Text
sourceBranchName} -> Text
sourceBranchName) (\s :: BranchDiffSourceCodeType
s@BranchDiffSourceCodeType' {} Text
a -> BranchDiffSourceCodeType
s {$sel:sourceBranchName:BranchDiffSourceCodeType' :: Text
sourceBranchName = Text
a} :: BranchDiffSourceCodeType)

-- | The destination branch for a diff in an associated repository.
branchDiffSourceCodeType_destinationBranchName :: Lens.Lens' BranchDiffSourceCodeType Prelude.Text
branchDiffSourceCodeType_destinationBranchName :: (Text -> f Text)
-> BranchDiffSourceCodeType -> f BranchDiffSourceCodeType
branchDiffSourceCodeType_destinationBranchName = (BranchDiffSourceCodeType -> Text)
-> (BranchDiffSourceCodeType -> Text -> BranchDiffSourceCodeType)
-> Lens BranchDiffSourceCodeType BranchDiffSourceCodeType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BranchDiffSourceCodeType' {Text
destinationBranchName :: Text
$sel:destinationBranchName:BranchDiffSourceCodeType' :: BranchDiffSourceCodeType -> Text
destinationBranchName} -> Text
destinationBranchName) (\s :: BranchDiffSourceCodeType
s@BranchDiffSourceCodeType' {} Text
a -> BranchDiffSourceCodeType
s {$sel:destinationBranchName:BranchDiffSourceCodeType' :: Text
destinationBranchName = Text
a} :: BranchDiffSourceCodeType)

instance Core.FromJSON BranchDiffSourceCodeType where
  parseJSON :: Value -> Parser BranchDiffSourceCodeType
parseJSON =
    String
-> (Object -> Parser BranchDiffSourceCodeType)
-> Value
-> Parser BranchDiffSourceCodeType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BranchDiffSourceCodeType"
      ( \Object
x ->
          Text -> Text -> BranchDiffSourceCodeType
BranchDiffSourceCodeType'
            (Text -> Text -> BranchDiffSourceCodeType)
-> Parser Text -> Parser (Text -> BranchDiffSourceCodeType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourceBranchName")
            Parser (Text -> BranchDiffSourceCodeType)
-> Parser Text -> Parser BranchDiffSourceCodeType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DestinationBranchName")
      )

instance Prelude.Hashable BranchDiffSourceCodeType

instance Prelude.NFData BranchDiffSourceCodeType

instance Core.ToJSON BranchDiffSourceCodeType where
  toJSON :: BranchDiffSourceCodeType -> Value
toJSON BranchDiffSourceCodeType' {Text
destinationBranchName :: Text
sourceBranchName :: Text
$sel:destinationBranchName:BranchDiffSourceCodeType' :: BranchDiffSourceCodeType -> Text
$sel:sourceBranchName:BranchDiffSourceCodeType' :: BranchDiffSourceCodeType -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SourceBranchName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceBranchName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"DestinationBranchName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationBranchName
              )
          ]
      )