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

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

-- | Returns information about a merge or potential merge between a source
-- reference and a destination reference in a pull request.
--
-- /See:/ 'newMergeMetadata' smart constructor.
data MergeMetadata = MergeMetadata'
  { -- | The Amazon Resource Name (ARN) of the user who merged the branches.
    MergeMetadata -> Maybe Text
mergedBy :: Prelude.Maybe Prelude.Text,
    -- | The merge strategy used in the merge.
    MergeMetadata -> Maybe MergeOptionTypeEnum
mergeOption :: Prelude.Maybe MergeOptionTypeEnum,
    -- | A Boolean value indicating whether the merge has been made.
    MergeMetadata -> Maybe Bool
isMerged :: Prelude.Maybe Prelude.Bool,
    -- | The commit ID for the merge commit, if any.
    MergeMetadata -> Maybe Text
mergeCommitId :: Prelude.Maybe Prelude.Text
  }
  deriving (MergeMetadata -> MergeMetadata -> Bool
(MergeMetadata -> MergeMetadata -> Bool)
-> (MergeMetadata -> MergeMetadata -> Bool) -> Eq MergeMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeMetadata -> MergeMetadata -> Bool
$c/= :: MergeMetadata -> MergeMetadata -> Bool
== :: MergeMetadata -> MergeMetadata -> Bool
$c== :: MergeMetadata -> MergeMetadata -> Bool
Prelude.Eq, ReadPrec [MergeMetadata]
ReadPrec MergeMetadata
Int -> ReadS MergeMetadata
ReadS [MergeMetadata]
(Int -> ReadS MergeMetadata)
-> ReadS [MergeMetadata]
-> ReadPrec MergeMetadata
-> ReadPrec [MergeMetadata]
-> Read MergeMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeMetadata]
$creadListPrec :: ReadPrec [MergeMetadata]
readPrec :: ReadPrec MergeMetadata
$creadPrec :: ReadPrec MergeMetadata
readList :: ReadS [MergeMetadata]
$creadList :: ReadS [MergeMetadata]
readsPrec :: Int -> ReadS MergeMetadata
$creadsPrec :: Int -> ReadS MergeMetadata
Prelude.Read, Int -> MergeMetadata -> ShowS
[MergeMetadata] -> ShowS
MergeMetadata -> String
(Int -> MergeMetadata -> ShowS)
-> (MergeMetadata -> String)
-> ([MergeMetadata] -> ShowS)
-> Show MergeMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeMetadata] -> ShowS
$cshowList :: [MergeMetadata] -> ShowS
show :: MergeMetadata -> String
$cshow :: MergeMetadata -> String
showsPrec :: Int -> MergeMetadata -> ShowS
$cshowsPrec :: Int -> MergeMetadata -> ShowS
Prelude.Show, (forall x. MergeMetadata -> Rep MergeMetadata x)
-> (forall x. Rep MergeMetadata x -> MergeMetadata)
-> Generic MergeMetadata
forall x. Rep MergeMetadata x -> MergeMetadata
forall x. MergeMetadata -> Rep MergeMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeMetadata x -> MergeMetadata
$cfrom :: forall x. MergeMetadata -> Rep MergeMetadata x
Prelude.Generic)

-- |
-- Create a value of 'MergeMetadata' 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:
--
-- 'mergedBy', 'mergeMetadata_mergedBy' - The Amazon Resource Name (ARN) of the user who merged the branches.
--
-- 'mergeOption', 'mergeMetadata_mergeOption' - The merge strategy used in the merge.
--
-- 'isMerged', 'mergeMetadata_isMerged' - A Boolean value indicating whether the merge has been made.
--
-- 'mergeCommitId', 'mergeMetadata_mergeCommitId' - The commit ID for the merge commit, if any.
newMergeMetadata ::
  MergeMetadata
newMergeMetadata :: MergeMetadata
newMergeMetadata =
  MergeMetadata' :: Maybe Text
-> Maybe MergeOptionTypeEnum
-> Maybe Bool
-> Maybe Text
-> MergeMetadata
MergeMetadata'
    { $sel:mergedBy:MergeMetadata' :: Maybe Text
mergedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mergeOption:MergeMetadata' :: Maybe MergeOptionTypeEnum
mergeOption = Maybe MergeOptionTypeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:isMerged:MergeMetadata' :: Maybe Bool
isMerged = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:mergeCommitId:MergeMetadata' :: Maybe Text
mergeCommitId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the user who merged the branches.
mergeMetadata_mergedBy :: Lens.Lens' MergeMetadata (Prelude.Maybe Prelude.Text)
mergeMetadata_mergedBy :: (Maybe Text -> f (Maybe Text)) -> MergeMetadata -> f MergeMetadata
mergeMetadata_mergedBy = (MergeMetadata -> Maybe Text)
-> (MergeMetadata -> Maybe Text -> MergeMetadata)
-> Lens MergeMetadata MergeMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeMetadata' {Maybe Text
mergedBy :: Maybe Text
$sel:mergedBy:MergeMetadata' :: MergeMetadata -> Maybe Text
mergedBy} -> Maybe Text
mergedBy) (\s :: MergeMetadata
s@MergeMetadata' {} Maybe Text
a -> MergeMetadata
s {$sel:mergedBy:MergeMetadata' :: Maybe Text
mergedBy = Maybe Text
a} :: MergeMetadata)

-- | The merge strategy used in the merge.
mergeMetadata_mergeOption :: Lens.Lens' MergeMetadata (Prelude.Maybe MergeOptionTypeEnum)
mergeMetadata_mergeOption :: (Maybe MergeOptionTypeEnum -> f (Maybe MergeOptionTypeEnum))
-> MergeMetadata -> f MergeMetadata
mergeMetadata_mergeOption = (MergeMetadata -> Maybe MergeOptionTypeEnum)
-> (MergeMetadata -> Maybe MergeOptionTypeEnum -> MergeMetadata)
-> Lens
     MergeMetadata
     MergeMetadata
     (Maybe MergeOptionTypeEnum)
     (Maybe MergeOptionTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeMetadata' {Maybe MergeOptionTypeEnum
mergeOption :: Maybe MergeOptionTypeEnum
$sel:mergeOption:MergeMetadata' :: MergeMetadata -> Maybe MergeOptionTypeEnum
mergeOption} -> Maybe MergeOptionTypeEnum
mergeOption) (\s :: MergeMetadata
s@MergeMetadata' {} Maybe MergeOptionTypeEnum
a -> MergeMetadata
s {$sel:mergeOption:MergeMetadata' :: Maybe MergeOptionTypeEnum
mergeOption = Maybe MergeOptionTypeEnum
a} :: MergeMetadata)

-- | A Boolean value indicating whether the merge has been made.
mergeMetadata_isMerged :: Lens.Lens' MergeMetadata (Prelude.Maybe Prelude.Bool)
mergeMetadata_isMerged :: (Maybe Bool -> f (Maybe Bool)) -> MergeMetadata -> f MergeMetadata
mergeMetadata_isMerged = (MergeMetadata -> Maybe Bool)
-> (MergeMetadata -> Maybe Bool -> MergeMetadata)
-> Lens MergeMetadata MergeMetadata (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeMetadata' {Maybe Bool
isMerged :: Maybe Bool
$sel:isMerged:MergeMetadata' :: MergeMetadata -> Maybe Bool
isMerged} -> Maybe Bool
isMerged) (\s :: MergeMetadata
s@MergeMetadata' {} Maybe Bool
a -> MergeMetadata
s {$sel:isMerged:MergeMetadata' :: Maybe Bool
isMerged = Maybe Bool
a} :: MergeMetadata)

-- | The commit ID for the merge commit, if any.
mergeMetadata_mergeCommitId :: Lens.Lens' MergeMetadata (Prelude.Maybe Prelude.Text)
mergeMetadata_mergeCommitId :: (Maybe Text -> f (Maybe Text)) -> MergeMetadata -> f MergeMetadata
mergeMetadata_mergeCommitId = (MergeMetadata -> Maybe Text)
-> (MergeMetadata -> Maybe Text -> MergeMetadata)
-> Lens MergeMetadata MergeMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeMetadata' {Maybe Text
mergeCommitId :: Maybe Text
$sel:mergeCommitId:MergeMetadata' :: MergeMetadata -> Maybe Text
mergeCommitId} -> Maybe Text
mergeCommitId) (\s :: MergeMetadata
s@MergeMetadata' {} Maybe Text
a -> MergeMetadata
s {$sel:mergeCommitId:MergeMetadata' :: Maybe Text
mergeCommitId = Maybe Text
a} :: MergeMetadata)

instance Core.FromJSON MergeMetadata where
  parseJSON :: Value -> Parser MergeMetadata
parseJSON =
    String
-> (Object -> Parser MergeMetadata)
-> Value
-> Parser MergeMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MergeMetadata"
      ( \Object
x ->
          Maybe Text
-> Maybe MergeOptionTypeEnum
-> Maybe Bool
-> Maybe Text
-> MergeMetadata
MergeMetadata'
            (Maybe Text
 -> Maybe MergeOptionTypeEnum
 -> Maybe Bool
 -> Maybe Text
 -> MergeMetadata)
-> Parser (Maybe Text)
-> Parser
     (Maybe MergeOptionTypeEnum
      -> Maybe Bool -> Maybe Text -> MergeMetadata)
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
"mergedBy")
            Parser
  (Maybe MergeOptionTypeEnum
   -> Maybe Bool -> Maybe Text -> MergeMetadata)
-> Parser (Maybe MergeOptionTypeEnum)
-> Parser (Maybe Bool -> Maybe Text -> MergeMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe MergeOptionTypeEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mergeOption")
            Parser (Maybe Bool -> Maybe Text -> MergeMetadata)
-> Parser (Maybe Bool) -> Parser (Maybe Text -> MergeMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isMerged")
            Parser (Maybe Text -> MergeMetadata)
-> Parser (Maybe Text) -> Parser MergeMetadata
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
"mergeCommitId")
      )

instance Prelude.Hashable MergeMetadata

instance Prelude.NFData MergeMetadata