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

-- | 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
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]
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
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.
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'
    { $sel:destinationCommitId:PullRequestCreatedEventMetadata' :: Maybe Text
destinationCommitId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:mergeBase:PullRequestCreatedEventMetadata' :: Maybe Text
mergeBase = forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:PullRequestCreatedEventMetadata' :: Maybe Text
repositoryName = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceCommitId:PullRequestCreatedEventMetadata' :: Maybe Text
sourceCommitId = 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 :: Lens' PullRequestCreatedEventMetadata (Maybe Text)
pullRequestCreatedEventMetadata_destinationCommitId = 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 :: Lens' PullRequestCreatedEventMetadata (Maybe Text)
pullRequestCreatedEventMetadata_mergeBase = 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 :: Lens' PullRequestCreatedEventMetadata (Maybe Text)
pullRequestCreatedEventMetadata_repositoryName = 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 :: Lens' PullRequestCreatedEventMetadata (Maybe Text)
pullRequestCreatedEventMetadata_sourceCommitId = 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
  Data.FromJSON
    PullRequestCreatedEventMetadata
  where
  parseJSON :: Value -> Parser PullRequestCreatedEventMetadata
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PullRequestCreatedEventMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PullRequestCreatedEventMetadata
PullRequestCreatedEventMetadata'
            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
"destinationCommitId")
            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
"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
"sourceCommitId")
      )

instance
  Prelude.Hashable
    PullRequestCreatedEventMetadata
  where
  hashWithSalt :: Int -> PullRequestCreatedEventMetadata -> Int
hashWithSalt
    Int
_salt
    PullRequestCreatedEventMetadata' {Maybe Text
sourceCommitId :: Maybe Text
repositoryName :: Maybe Text
mergeBase :: Maybe Text
destinationCommitId :: Maybe Text
$sel:sourceCommitId:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
$sel:repositoryName:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
$sel:mergeBase:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
$sel:destinationCommitId:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
destinationCommitId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mergeBase
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
repositoryName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceCommitId

instance
  Prelude.NFData
    PullRequestCreatedEventMetadata
  where
  rnf :: PullRequestCreatedEventMetadata -> ()
rnf PullRequestCreatedEventMetadata' {Maybe Text
sourceCommitId :: Maybe Text
repositoryName :: Maybe Text
mergeBase :: Maybe Text
destinationCommitId :: Maybe Text
$sel:sourceCommitId:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
$sel:repositoryName:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
$sel:mergeBase:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
$sel:destinationCommitId:PullRequestCreatedEventMetadata' :: PullRequestCreatedEventMetadata -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
destinationCommitId
      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 Text
repositoryName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceCommitId