{-# 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.PullRequestTarget
-- 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.CodeCommit.Types.PullRequestTarget where

import Amazonka.CodeCommit.Types.MergeMetadata
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about a pull request target.
--
-- /See:/ 'newPullRequestTarget' smart constructor.
data PullRequestTarget = PullRequestTarget'
  { -- | The full commit ID of the tip of the source branch used to create the
    -- pull request. If the pull request branch is updated by a push while the
    -- pull request is open, the commit ID changes to reflect the new tip of
    -- the branch.
    PullRequestTarget -> Maybe Text
sourceCommit :: Prelude.Maybe Prelude.Text,
    -- | The branch of the repository where the pull request changes are merged.
    -- Also known as the destination branch.
    PullRequestTarget -> Maybe Text
destinationReference :: Prelude.Maybe Prelude.Text,
    -- | Returns metadata about the state of the merge, including whether the
    -- merge has been made.
    PullRequestTarget -> Maybe MergeMetadata
mergeMetadata :: Prelude.Maybe MergeMetadata,
    -- | The commit ID of the most recent commit that the source branch and the
    -- destination branch have in common.
    PullRequestTarget -> Maybe Text
mergeBase :: Prelude.Maybe Prelude.Text,
    -- | The full commit ID that is the tip of the destination branch. This is
    -- the commit where the pull request was or will be merged.
    PullRequestTarget -> Maybe Text
destinationCommit :: Prelude.Maybe Prelude.Text,
    -- | The name of the repository that contains the pull request source and
    -- destination branches.
    PullRequestTarget -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text,
    -- | The branch of the repository that contains the changes for the pull
    -- request. Also known as the source branch.
    PullRequestTarget -> Maybe Text
sourceReference :: Prelude.Maybe Prelude.Text
  }
  deriving (PullRequestTarget -> PullRequestTarget -> Bool
(PullRequestTarget -> PullRequestTarget -> Bool)
-> (PullRequestTarget -> PullRequestTarget -> Bool)
-> Eq PullRequestTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PullRequestTarget -> PullRequestTarget -> Bool
$c/= :: PullRequestTarget -> PullRequestTarget -> Bool
== :: PullRequestTarget -> PullRequestTarget -> Bool
$c== :: PullRequestTarget -> PullRequestTarget -> Bool
Prelude.Eq, ReadPrec [PullRequestTarget]
ReadPrec PullRequestTarget
Int -> ReadS PullRequestTarget
ReadS [PullRequestTarget]
(Int -> ReadS PullRequestTarget)
-> ReadS [PullRequestTarget]
-> ReadPrec PullRequestTarget
-> ReadPrec [PullRequestTarget]
-> Read PullRequestTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PullRequestTarget]
$creadListPrec :: ReadPrec [PullRequestTarget]
readPrec :: ReadPrec PullRequestTarget
$creadPrec :: ReadPrec PullRequestTarget
readList :: ReadS [PullRequestTarget]
$creadList :: ReadS [PullRequestTarget]
readsPrec :: Int -> ReadS PullRequestTarget
$creadsPrec :: Int -> ReadS PullRequestTarget
Prelude.Read, Int -> PullRequestTarget -> ShowS
[PullRequestTarget] -> ShowS
PullRequestTarget -> String
(Int -> PullRequestTarget -> ShowS)
-> (PullRequestTarget -> String)
-> ([PullRequestTarget] -> ShowS)
-> Show PullRequestTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PullRequestTarget] -> ShowS
$cshowList :: [PullRequestTarget] -> ShowS
show :: PullRequestTarget -> String
$cshow :: PullRequestTarget -> String
showsPrec :: Int -> PullRequestTarget -> ShowS
$cshowsPrec :: Int -> PullRequestTarget -> ShowS
Prelude.Show, (forall x. PullRequestTarget -> Rep PullRequestTarget x)
-> (forall x. Rep PullRequestTarget x -> PullRequestTarget)
-> Generic PullRequestTarget
forall x. Rep PullRequestTarget x -> PullRequestTarget
forall x. PullRequestTarget -> Rep PullRequestTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PullRequestTarget x -> PullRequestTarget
$cfrom :: forall x. PullRequestTarget -> Rep PullRequestTarget x
Prelude.Generic)

-- |
-- Create a value of 'PullRequestTarget' 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:
--
-- 'sourceCommit', 'pullRequestTarget_sourceCommit' - The full commit ID of the tip of the source branch used to create the
-- pull request. If the pull request branch is updated by a push while the
-- pull request is open, the commit ID changes to reflect the new tip of
-- the branch.
--
-- 'destinationReference', 'pullRequestTarget_destinationReference' - The branch of the repository where the pull request changes are merged.
-- Also known as the destination branch.
--
-- 'mergeMetadata', 'pullRequestTarget_mergeMetadata' - Returns metadata about the state of the merge, including whether the
-- merge has been made.
--
-- 'mergeBase', 'pullRequestTarget_mergeBase' - The commit ID of the most recent commit that the source branch and the
-- destination branch have in common.
--
-- 'destinationCommit', 'pullRequestTarget_destinationCommit' - The full commit ID that is the tip of the destination branch. This is
-- the commit where the pull request was or will be merged.
--
-- 'repositoryName', 'pullRequestTarget_repositoryName' - The name of the repository that contains the pull request source and
-- destination branches.
--
-- 'sourceReference', 'pullRequestTarget_sourceReference' - The branch of the repository that contains the changes for the pull
-- request. Also known as the source branch.
newPullRequestTarget ::
  PullRequestTarget
newPullRequestTarget :: PullRequestTarget
newPullRequestTarget =
  PullRequestTarget' :: Maybe Text
-> Maybe Text
-> Maybe MergeMetadata
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PullRequestTarget
PullRequestTarget'
    { $sel:sourceCommit:PullRequestTarget' :: Maybe Text
sourceCommit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationReference:PullRequestTarget' :: Maybe Text
destinationReference = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mergeMetadata:PullRequestTarget' :: Maybe MergeMetadata
mergeMetadata = Maybe MergeMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:mergeBase:PullRequestTarget' :: Maybe Text
mergeBase = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationCommit:PullRequestTarget' :: Maybe Text
destinationCommit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:PullRequestTarget' :: Maybe Text
repositoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceReference:PullRequestTarget' :: Maybe Text
sourceReference = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The full commit ID of the tip of the source branch used to create the
-- pull request. If the pull request branch is updated by a push while the
-- pull request is open, the commit ID changes to reflect the new tip of
-- the branch.
pullRequestTarget_sourceCommit :: Lens.Lens' PullRequestTarget (Prelude.Maybe Prelude.Text)
pullRequestTarget_sourceCommit :: (Maybe Text -> f (Maybe Text))
-> PullRequestTarget -> f PullRequestTarget
pullRequestTarget_sourceCommit = (PullRequestTarget -> Maybe Text)
-> (PullRequestTarget -> Maybe Text -> PullRequestTarget)
-> Lens
     PullRequestTarget PullRequestTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestTarget' {Maybe Text
sourceCommit :: Maybe Text
$sel:sourceCommit:PullRequestTarget' :: PullRequestTarget -> Maybe Text
sourceCommit} -> Maybe Text
sourceCommit) (\s :: PullRequestTarget
s@PullRequestTarget' {} Maybe Text
a -> PullRequestTarget
s {$sel:sourceCommit:PullRequestTarget' :: Maybe Text
sourceCommit = Maybe Text
a} :: PullRequestTarget)

-- | The branch of the repository where the pull request changes are merged.
-- Also known as the destination branch.
pullRequestTarget_destinationReference :: Lens.Lens' PullRequestTarget (Prelude.Maybe Prelude.Text)
pullRequestTarget_destinationReference :: (Maybe Text -> f (Maybe Text))
-> PullRequestTarget -> f PullRequestTarget
pullRequestTarget_destinationReference = (PullRequestTarget -> Maybe Text)
-> (PullRequestTarget -> Maybe Text -> PullRequestTarget)
-> Lens
     PullRequestTarget PullRequestTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestTarget' {Maybe Text
destinationReference :: Maybe Text
$sel:destinationReference:PullRequestTarget' :: PullRequestTarget -> Maybe Text
destinationReference} -> Maybe Text
destinationReference) (\s :: PullRequestTarget
s@PullRequestTarget' {} Maybe Text
a -> PullRequestTarget
s {$sel:destinationReference:PullRequestTarget' :: Maybe Text
destinationReference = Maybe Text
a} :: PullRequestTarget)

-- | Returns metadata about the state of the merge, including whether the
-- merge has been made.
pullRequestTarget_mergeMetadata :: Lens.Lens' PullRequestTarget (Prelude.Maybe MergeMetadata)
pullRequestTarget_mergeMetadata :: (Maybe MergeMetadata -> f (Maybe MergeMetadata))
-> PullRequestTarget -> f PullRequestTarget
pullRequestTarget_mergeMetadata = (PullRequestTarget -> Maybe MergeMetadata)
-> (PullRequestTarget -> Maybe MergeMetadata -> PullRequestTarget)
-> Lens
     PullRequestTarget
     PullRequestTarget
     (Maybe MergeMetadata)
     (Maybe MergeMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestTarget' {Maybe MergeMetadata
mergeMetadata :: Maybe MergeMetadata
$sel:mergeMetadata:PullRequestTarget' :: PullRequestTarget -> Maybe MergeMetadata
mergeMetadata} -> Maybe MergeMetadata
mergeMetadata) (\s :: PullRequestTarget
s@PullRequestTarget' {} Maybe MergeMetadata
a -> PullRequestTarget
s {$sel:mergeMetadata:PullRequestTarget' :: Maybe MergeMetadata
mergeMetadata = Maybe MergeMetadata
a} :: PullRequestTarget)

-- | The commit ID of the most recent commit that the source branch and the
-- destination branch have in common.
pullRequestTarget_mergeBase :: Lens.Lens' PullRequestTarget (Prelude.Maybe Prelude.Text)
pullRequestTarget_mergeBase :: (Maybe Text -> f (Maybe Text))
-> PullRequestTarget -> f PullRequestTarget
pullRequestTarget_mergeBase = (PullRequestTarget -> Maybe Text)
-> (PullRequestTarget -> Maybe Text -> PullRequestTarget)
-> Lens
     PullRequestTarget PullRequestTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestTarget' {Maybe Text
mergeBase :: Maybe Text
$sel:mergeBase:PullRequestTarget' :: PullRequestTarget -> Maybe Text
mergeBase} -> Maybe Text
mergeBase) (\s :: PullRequestTarget
s@PullRequestTarget' {} Maybe Text
a -> PullRequestTarget
s {$sel:mergeBase:PullRequestTarget' :: Maybe Text
mergeBase = Maybe Text
a} :: PullRequestTarget)

-- | The full commit ID that is the tip of the destination branch. This is
-- the commit where the pull request was or will be merged.
pullRequestTarget_destinationCommit :: Lens.Lens' PullRequestTarget (Prelude.Maybe Prelude.Text)
pullRequestTarget_destinationCommit :: (Maybe Text -> f (Maybe Text))
-> PullRequestTarget -> f PullRequestTarget
pullRequestTarget_destinationCommit = (PullRequestTarget -> Maybe Text)
-> (PullRequestTarget -> Maybe Text -> PullRequestTarget)
-> Lens
     PullRequestTarget PullRequestTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestTarget' {Maybe Text
destinationCommit :: Maybe Text
$sel:destinationCommit:PullRequestTarget' :: PullRequestTarget -> Maybe Text
destinationCommit} -> Maybe Text
destinationCommit) (\s :: PullRequestTarget
s@PullRequestTarget' {} Maybe Text
a -> PullRequestTarget
s {$sel:destinationCommit:PullRequestTarget' :: Maybe Text
destinationCommit = Maybe Text
a} :: PullRequestTarget)

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

-- | The branch of the repository that contains the changes for the pull
-- request. Also known as the source branch.
pullRequestTarget_sourceReference :: Lens.Lens' PullRequestTarget (Prelude.Maybe Prelude.Text)
pullRequestTarget_sourceReference :: (Maybe Text -> f (Maybe Text))
-> PullRequestTarget -> f PullRequestTarget
pullRequestTarget_sourceReference = (PullRequestTarget -> Maybe Text)
-> (PullRequestTarget -> Maybe Text -> PullRequestTarget)
-> Lens
     PullRequestTarget PullRequestTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestTarget' {Maybe Text
sourceReference :: Maybe Text
$sel:sourceReference:PullRequestTarget' :: PullRequestTarget -> Maybe Text
sourceReference} -> Maybe Text
sourceReference) (\s :: PullRequestTarget
s@PullRequestTarget' {} Maybe Text
a -> PullRequestTarget
s {$sel:sourceReference:PullRequestTarget' :: Maybe Text
sourceReference = Maybe Text
a} :: PullRequestTarget)

instance Core.FromJSON PullRequestTarget where
  parseJSON :: Value -> Parser PullRequestTarget
parseJSON =
    String
-> (Object -> Parser PullRequestTarget)
-> Value
-> Parser PullRequestTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PullRequestTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe MergeMetadata
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PullRequestTarget
PullRequestTarget'
            (Maybe Text
 -> Maybe Text
 -> Maybe MergeMetadata
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> PullRequestTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe MergeMetadata
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PullRequestTarget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sourceCommit")
            Parser
  (Maybe Text
   -> Maybe MergeMetadata
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PullRequestTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe MergeMetadata
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PullRequestTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"destinationReference")
            Parser
  (Maybe MergeMetadata
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PullRequestTarget)
-> Parser (Maybe MergeMetadata)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> PullRequestTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MergeMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mergeMetadata")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> PullRequestTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> PullRequestTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mergeBase")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> PullRequestTarget)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PullRequestTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"destinationCommit")
            Parser (Maybe Text -> Maybe Text -> PullRequestTarget)
-> Parser (Maybe Text) -> Parser (Maybe Text -> PullRequestTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"repositoryName")
            Parser (Maybe Text -> PullRequestTarget)
-> Parser (Maybe Text) -> Parser PullRequestTarget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sourceReference")
      )

instance Prelude.Hashable PullRequestTarget

instance Prelude.NFData PullRequestTarget