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

import Amazonka.CodeCommit.Types.MergeMetadata
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 a pull request target.
--
-- /See:/ 'newPullRequestTarget' smart constructor.
data PullRequestTarget = 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 -> Maybe Text
destinationCommit :: 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,
    -- | 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,
    -- | Returns metadata about the state of the merge, including whether the
    -- merge has been made.
    PullRequestTarget -> Maybe MergeMetadata
mergeMetadata :: Prelude.Maybe MergeMetadata,
    -- | The name of the repository that contains the pull request source and
    -- destination branches.
    PullRequestTarget -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text,
    -- | 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 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
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]
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
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. 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:
--
-- '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.
--
-- 'destinationReference', 'pullRequestTarget_destinationReference' - The branch of the repository where the pull request changes are merged.
-- Also known as the destination branch.
--
-- 'mergeBase', 'pullRequestTarget_mergeBase' - The commit ID of the most recent commit that the source branch and the
-- destination branch have in common.
--
-- 'mergeMetadata', 'pullRequestTarget_mergeMetadata' - Returns metadata about the state of the merge, including whether the
-- merge has been made.
--
-- 'repositoryName', 'pullRequestTarget_repositoryName' - The name of the repository that contains the pull request source and
-- destination branches.
--
-- '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.
--
-- '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'
    { $sel:destinationCommit:PullRequestTarget' :: Maybe Text
destinationCommit =
        forall a. Maybe a
Prelude.Nothing,
      $sel:destinationReference:PullRequestTarget' :: Maybe Text
destinationReference = forall a. Maybe a
Prelude.Nothing,
      $sel:mergeBase:PullRequestTarget' :: Maybe Text
mergeBase = forall a. Maybe a
Prelude.Nothing,
      $sel:mergeMetadata:PullRequestTarget' :: Maybe MergeMetadata
mergeMetadata = forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:PullRequestTarget' :: Maybe Text
repositoryName = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceCommit:PullRequestTarget' :: Maybe Text
sourceCommit = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceReference:PullRequestTarget' :: Maybe Text
sourceReference = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' PullRequestTarget (Maybe Text)
pullRequestTarget_destinationCommit = 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 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 :: Lens' PullRequestTarget (Maybe Text)
pullRequestTarget_destinationReference = 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)

-- | 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 :: Lens' PullRequestTarget (Maybe Text)
pullRequestTarget_mergeBase = 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)

-- | 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 :: Lens' PullRequestTarget (Maybe MergeMetadata)
pullRequestTarget_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 name of the repository that contains the pull request source and
-- destination branches.
pullRequestTarget_repositoryName :: Lens.Lens' PullRequestTarget (Prelude.Maybe Prelude.Text)
pullRequestTarget_repositoryName :: Lens' PullRequestTarget (Maybe Text)
pullRequestTarget_repositoryName = 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 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 :: Lens' PullRequestTarget (Maybe Text)
pullRequestTarget_sourceCommit = 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 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 :: Lens' PullRequestTarget (Maybe Text)
pullRequestTarget_sourceReference = 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 Data.FromJSON PullRequestTarget where
  parseJSON :: Value -> Parser PullRequestTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PullRequestTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe MergeMetadata
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PullRequestTarget
PullRequestTarget'
            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
"destinationReference")
            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
"mergeBase")
            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
"mergeMetadata")
            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")
            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")
            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
"sourceReference")
      )

instance Prelude.Hashable PullRequestTarget where
  hashWithSalt :: Int -> PullRequestTarget -> Int
hashWithSalt Int
_salt PullRequestTarget' {Maybe Text
Maybe MergeMetadata
sourceReference :: Maybe Text
sourceCommit :: Maybe Text
repositoryName :: Maybe Text
mergeMetadata :: Maybe MergeMetadata
mergeBase :: Maybe Text
destinationReference :: Maybe Text
destinationCommit :: Maybe Text
$sel:sourceReference:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:sourceCommit:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:repositoryName:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:mergeMetadata:PullRequestTarget' :: PullRequestTarget -> Maybe MergeMetadata
$sel:mergeBase:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:destinationReference:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:destinationCommit:PullRequestTarget' :: PullRequestTarget -> 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
destinationReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mergeBase
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MergeMetadata
mergeMetadata
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
repositoryName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceCommit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceReference

instance Prelude.NFData PullRequestTarget where
  rnf :: PullRequestTarget -> ()
rnf PullRequestTarget' {Maybe Text
Maybe MergeMetadata
sourceReference :: Maybe Text
sourceCommit :: Maybe Text
repositoryName :: Maybe Text
mergeMetadata :: Maybe MergeMetadata
mergeBase :: Maybe Text
destinationReference :: Maybe Text
destinationCommit :: Maybe Text
$sel:sourceReference:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:sourceCommit:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:repositoryName:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:mergeMetadata:PullRequestTarget' :: PullRequestTarget -> Maybe MergeMetadata
$sel:mergeBase:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:destinationReference:PullRequestTarget' :: PullRequestTarget -> Maybe Text
$sel:destinationCommit:PullRequestTarget' :: PullRequestTarget -> 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
destinationReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mergeBase
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe MergeMetadata
mergeMetadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
repositoryName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceCommit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceReference