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

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

-- | Metadata about the pull request that is used when comparing the pull
-- request source with its destination.
--
-- /See:/ 'newPullRequestCreatedEventMetadata' smart constructor.
data PullRequestCreatedEventMetadata = PullRequestCreatedEventMetadata'
  { -- | The commit ID of the tip of the branch specified as the destination
    -- branch when the pull request was created.
    PullRequestCreatedEventMetadata -> Maybe Text
destinationCommitId :: Prelude.Maybe Prelude.Text,
    -- | The commit ID of the most recent commit that the source branch and the
    -- destination branch have in common.
    PullRequestCreatedEventMetadata -> Maybe Text
mergeBase :: Prelude.Maybe Prelude.Text,
    -- | The name of the repository where the pull request was created.
    PullRequestCreatedEventMetadata -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text,
    -- | The commit ID on the source branch used when the pull request was
    -- created.
    PullRequestCreatedEventMetadata -> Maybe Text
sourceCommitId :: Prelude.Maybe Prelude.Text
  }
  deriving (PullRequestCreatedEventMetadata
-> PullRequestCreatedEventMetadata -> Bool
(PullRequestCreatedEventMetadata
 -> PullRequestCreatedEventMetadata -> Bool)
-> (PullRequestCreatedEventMetadata
    -> PullRequestCreatedEventMetadata -> Bool)
-> Eq PullRequestCreatedEventMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PullRequestCreatedEventMetadata
-> PullRequestCreatedEventMetadata -> Bool
$c/= :: PullRequestCreatedEventMetadata
-> PullRequestCreatedEventMetadata -> Bool
== :: PullRequestCreatedEventMetadata
-> PullRequestCreatedEventMetadata -> Bool
$c== :: PullRequestCreatedEventMetadata
-> PullRequestCreatedEventMetadata -> Bool
Prelude.Eq, ReadPrec [PullRequestCreatedEventMetadata]
ReadPrec PullRequestCreatedEventMetadata
Int -> ReadS PullRequestCreatedEventMetadata
ReadS [PullRequestCreatedEventMetadata]
(Int -> ReadS PullRequestCreatedEventMetadata)
-> ReadS [PullRequestCreatedEventMetadata]
-> ReadPrec PullRequestCreatedEventMetadata
-> ReadPrec [PullRequestCreatedEventMetadata]
-> Read PullRequestCreatedEventMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PullRequestCreatedEventMetadata]
$creadListPrec :: ReadPrec [PullRequestCreatedEventMetadata]
readPrec :: ReadPrec PullRequestCreatedEventMetadata
$creadPrec :: ReadPrec PullRequestCreatedEventMetadata
readList :: ReadS [PullRequestCreatedEventMetadata]
$creadList :: ReadS [PullRequestCreatedEventMetadata]
readsPrec :: Int -> ReadS PullRequestCreatedEventMetadata
$creadsPrec :: Int -> ReadS PullRequestCreatedEventMetadata
Prelude.Read, Int -> PullRequestCreatedEventMetadata -> ShowS
[PullRequestCreatedEventMetadata] -> ShowS
PullRequestCreatedEventMetadata -> String
(Int -> PullRequestCreatedEventMetadata -> ShowS)
-> (PullRequestCreatedEventMetadata -> String)
-> ([PullRequestCreatedEventMetadata] -> ShowS)
-> Show PullRequestCreatedEventMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PullRequestCreatedEventMetadata] -> ShowS
$cshowList :: [PullRequestCreatedEventMetadata] -> ShowS
show :: PullRequestCreatedEventMetadata -> String
$cshow :: PullRequestCreatedEventMetadata -> String
showsPrec :: Int -> PullRequestCreatedEventMetadata -> ShowS
$cshowsPrec :: Int -> PullRequestCreatedEventMetadata -> ShowS
Prelude.Show, (forall x.
 PullRequestCreatedEventMetadata
 -> Rep PullRequestCreatedEventMetadata x)
-> (forall x.
    Rep PullRequestCreatedEventMetadata x
    -> PullRequestCreatedEventMetadata)
-> Generic PullRequestCreatedEventMetadata
forall x.
Rep PullRequestCreatedEventMetadata x
-> PullRequestCreatedEventMetadata
forall x.
PullRequestCreatedEventMetadata
-> Rep PullRequestCreatedEventMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PullRequestCreatedEventMetadata x
-> PullRequestCreatedEventMetadata
$cfrom :: forall x.
PullRequestCreatedEventMetadata
-> Rep PullRequestCreatedEventMetadata x
Prelude.Generic)

-- |
-- Create a value of 'PullRequestCreatedEventMetadata' 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:
--
-- 'destinationCommitId', 'pullRequestCreatedEventMetadata_destinationCommitId' - The commit ID of the tip of the branch specified as the destination
-- branch when the pull request was created.
--
-- 'mergeBase', 'pullRequestCreatedEventMetadata_mergeBase' - The commit ID of the most recent commit that the source branch and the
-- destination branch have in common.
--
-- 'repositoryName', 'pullRequestCreatedEventMetadata_repositoryName' - The name of the repository where the pull request was created.
--
-- 'sourceCommitId', 'pullRequestCreatedEventMetadata_sourceCommitId' - The commit ID on the source branch used when the pull request was
-- created.
newPullRequestCreatedEventMetadata ::
  PullRequestCreatedEventMetadata
newPullRequestCreatedEventMetadata :: PullRequestCreatedEventMetadata
newPullRequestCreatedEventMetadata =
  PullRequestCreatedEventMetadata' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PullRequestCreatedEventMetadata
PullRequestCreatedEventMetadata'
    { $sel:destinationCommitId:PullRequestCreatedEventMetadata' :: Maybe Text
destinationCommitId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mergeBase:PullRequestCreatedEventMetadata' :: Maybe Text
mergeBase = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:PullRequestCreatedEventMetadata' :: Maybe Text
repositoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceCommitId:PullRequestCreatedEventMetadata' :: Maybe Text
sourceCommitId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The commit ID of the tip of the branch specified as the destination
-- branch when the pull request was created.
pullRequestCreatedEventMetadata_destinationCommitId :: Lens.Lens' PullRequestCreatedEventMetadata (Prelude.Maybe Prelude.Text)
pullRequestCreatedEventMetadata_destinationCommitId :: (Maybe Text -> f (Maybe Text))
-> PullRequestCreatedEventMetadata
-> f PullRequestCreatedEventMetadata
pullRequestCreatedEventMetadata_destinationCommitId = (PullRequestCreatedEventMetadata -> Maybe Text)
-> (PullRequestCreatedEventMetadata
    -> Maybe Text -> PullRequestCreatedEventMetadata)
-> Lens
     PullRequestCreatedEventMetadata
     PullRequestCreatedEventMetadata
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestCreatedEventMetadata' {Maybe Text
destinationCommitId :: Maybe Text
$sel:destinationCommitId:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
destinationCommitId} -> Maybe Text
destinationCommitId) (\s :: PullRequestCreatedEventMetadata
s@PullRequestCreatedEventMetadata' {} Maybe Text
a -> PullRequestCreatedEventMetadata
s {$sel:destinationCommitId:PullRequestCreatedEventMetadata' :: Maybe Text
destinationCommitId = Maybe Text
a} :: PullRequestCreatedEventMetadata)

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

-- | The name of the repository where the pull request was created.
pullRequestCreatedEventMetadata_repositoryName :: Lens.Lens' PullRequestCreatedEventMetadata (Prelude.Maybe Prelude.Text)
pullRequestCreatedEventMetadata_repositoryName :: (Maybe Text -> f (Maybe Text))
-> PullRequestCreatedEventMetadata
-> f PullRequestCreatedEventMetadata
pullRequestCreatedEventMetadata_repositoryName = (PullRequestCreatedEventMetadata -> Maybe Text)
-> (PullRequestCreatedEventMetadata
    -> Maybe Text -> PullRequestCreatedEventMetadata)
-> Lens
     PullRequestCreatedEventMetadata
     PullRequestCreatedEventMetadata
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestCreatedEventMetadata' {Maybe Text
repositoryName :: Maybe Text
$sel:repositoryName:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
repositoryName} -> Maybe Text
repositoryName) (\s :: PullRequestCreatedEventMetadata
s@PullRequestCreatedEventMetadata' {} Maybe Text
a -> PullRequestCreatedEventMetadata
s {$sel:repositoryName:PullRequestCreatedEventMetadata' :: Maybe Text
repositoryName = Maybe Text
a} :: PullRequestCreatedEventMetadata)

-- | The commit ID on the source branch used when the pull request was
-- created.
pullRequestCreatedEventMetadata_sourceCommitId :: Lens.Lens' PullRequestCreatedEventMetadata (Prelude.Maybe Prelude.Text)
pullRequestCreatedEventMetadata_sourceCommitId :: (Maybe Text -> f (Maybe Text))
-> PullRequestCreatedEventMetadata
-> f PullRequestCreatedEventMetadata
pullRequestCreatedEventMetadata_sourceCommitId = (PullRequestCreatedEventMetadata -> Maybe Text)
-> (PullRequestCreatedEventMetadata
    -> Maybe Text -> PullRequestCreatedEventMetadata)
-> Lens
     PullRequestCreatedEventMetadata
     PullRequestCreatedEventMetadata
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PullRequestCreatedEventMetadata' {Maybe Text
sourceCommitId :: Maybe Text
$sel:sourceCommitId:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
sourceCommitId} -> Maybe Text
sourceCommitId) (\s :: PullRequestCreatedEventMetadata
s@PullRequestCreatedEventMetadata' {} Maybe Text
a -> PullRequestCreatedEventMetadata
s {$sel:sourceCommitId:PullRequestCreatedEventMetadata' :: Maybe Text
sourceCommitId = Maybe Text
a} :: PullRequestCreatedEventMetadata)

instance
  Core.FromJSON
    PullRequestCreatedEventMetadata
  where
  parseJSON :: Value -> Parser PullRequestCreatedEventMetadata
parseJSON =
    String
-> (Object -> Parser PullRequestCreatedEventMetadata)
-> Value
-> Parser PullRequestCreatedEventMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PullRequestCreatedEventMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PullRequestCreatedEventMetadata
PullRequestCreatedEventMetadata'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> PullRequestCreatedEventMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> PullRequestCreatedEventMetadata)
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
"destinationCommitId")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> PullRequestCreatedEventMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> PullRequestCreatedEventMetadata)
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 -> PullRequestCreatedEventMetadata)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PullRequestCreatedEventMetadata)
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 -> PullRequestCreatedEventMetadata)
-> Parser (Maybe Text) -> Parser PullRequestCreatedEventMetadata
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
"sourceCommitId")
      )

instance
  Prelude.Hashable
    PullRequestCreatedEventMetadata

instance
  Prelude.NFData
    PullRequestCreatedEventMetadata