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

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

-- | Information about the file operation conflicts in a merge operation.
--
-- /See:/ 'newMergeOperations' smart constructor.
data MergeOperations = MergeOperations'
  { -- | The operation on a file in the destination of a merge or pull request.
    MergeOperations -> Maybe ChangeTypeEnum
destination :: Prelude.Maybe ChangeTypeEnum,
    -- | The operation (add, modify, or delete) on a file in the source of a
    -- merge or pull request.
    MergeOperations -> Maybe ChangeTypeEnum
source :: Prelude.Maybe ChangeTypeEnum
  }
  deriving (MergeOperations -> MergeOperations -> Bool
(MergeOperations -> MergeOperations -> Bool)
-> (MergeOperations -> MergeOperations -> Bool)
-> Eq MergeOperations
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MergeOperations -> MergeOperations -> Bool
$c/= :: MergeOperations -> MergeOperations -> Bool
== :: MergeOperations -> MergeOperations -> Bool
$c== :: MergeOperations -> MergeOperations -> Bool
Prelude.Eq, ReadPrec [MergeOperations]
ReadPrec MergeOperations
Int -> ReadS MergeOperations
ReadS [MergeOperations]
(Int -> ReadS MergeOperations)
-> ReadS [MergeOperations]
-> ReadPrec MergeOperations
-> ReadPrec [MergeOperations]
-> Read MergeOperations
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MergeOperations]
$creadListPrec :: ReadPrec [MergeOperations]
readPrec :: ReadPrec MergeOperations
$creadPrec :: ReadPrec MergeOperations
readList :: ReadS [MergeOperations]
$creadList :: ReadS [MergeOperations]
readsPrec :: Int -> ReadS MergeOperations
$creadsPrec :: Int -> ReadS MergeOperations
Prelude.Read, Int -> MergeOperations -> ShowS
[MergeOperations] -> ShowS
MergeOperations -> String
(Int -> MergeOperations -> ShowS)
-> (MergeOperations -> String)
-> ([MergeOperations] -> ShowS)
-> Show MergeOperations
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MergeOperations] -> ShowS
$cshowList :: [MergeOperations] -> ShowS
show :: MergeOperations -> String
$cshow :: MergeOperations -> String
showsPrec :: Int -> MergeOperations -> ShowS
$cshowsPrec :: Int -> MergeOperations -> ShowS
Prelude.Show, (forall x. MergeOperations -> Rep MergeOperations x)
-> (forall x. Rep MergeOperations x -> MergeOperations)
-> Generic MergeOperations
forall x. Rep MergeOperations x -> MergeOperations
forall x. MergeOperations -> Rep MergeOperations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MergeOperations x -> MergeOperations
$cfrom :: forall x. MergeOperations -> Rep MergeOperations x
Prelude.Generic)

-- |
-- Create a value of 'MergeOperations' 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:
--
-- 'destination', 'mergeOperations_destination' - The operation on a file in the destination of a merge or pull request.
--
-- 'source', 'mergeOperations_source' - The operation (add, modify, or delete) on a file in the source of a
-- merge or pull request.
newMergeOperations ::
  MergeOperations
newMergeOperations :: MergeOperations
newMergeOperations =
  MergeOperations' :: Maybe ChangeTypeEnum -> Maybe ChangeTypeEnum -> MergeOperations
MergeOperations'
    { $sel:destination:MergeOperations' :: Maybe ChangeTypeEnum
destination = Maybe ChangeTypeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:source:MergeOperations' :: Maybe ChangeTypeEnum
source = Maybe ChangeTypeEnum
forall a. Maybe a
Prelude.Nothing
    }

-- | The operation on a file in the destination of a merge or pull request.
mergeOperations_destination :: Lens.Lens' MergeOperations (Prelude.Maybe ChangeTypeEnum)
mergeOperations_destination :: (Maybe ChangeTypeEnum -> f (Maybe ChangeTypeEnum))
-> MergeOperations -> f MergeOperations
mergeOperations_destination = (MergeOperations -> Maybe ChangeTypeEnum)
-> (MergeOperations -> Maybe ChangeTypeEnum -> MergeOperations)
-> Lens
     MergeOperations
     MergeOperations
     (Maybe ChangeTypeEnum)
     (Maybe ChangeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeOperations' {Maybe ChangeTypeEnum
destination :: Maybe ChangeTypeEnum
$sel:destination:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
destination} -> Maybe ChangeTypeEnum
destination) (\s :: MergeOperations
s@MergeOperations' {} Maybe ChangeTypeEnum
a -> MergeOperations
s {$sel:destination:MergeOperations' :: Maybe ChangeTypeEnum
destination = Maybe ChangeTypeEnum
a} :: MergeOperations)

-- | The operation (add, modify, or delete) on a file in the source of a
-- merge or pull request.
mergeOperations_source :: Lens.Lens' MergeOperations (Prelude.Maybe ChangeTypeEnum)
mergeOperations_source :: (Maybe ChangeTypeEnum -> f (Maybe ChangeTypeEnum))
-> MergeOperations -> f MergeOperations
mergeOperations_source = (MergeOperations -> Maybe ChangeTypeEnum)
-> (MergeOperations -> Maybe ChangeTypeEnum -> MergeOperations)
-> Lens
     MergeOperations
     MergeOperations
     (Maybe ChangeTypeEnum)
     (Maybe ChangeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MergeOperations' {Maybe ChangeTypeEnum
source :: Maybe ChangeTypeEnum
$sel:source:MergeOperations' :: MergeOperations -> Maybe ChangeTypeEnum
source} -> Maybe ChangeTypeEnum
source) (\s :: MergeOperations
s@MergeOperations' {} Maybe ChangeTypeEnum
a -> MergeOperations
s {$sel:source:MergeOperations' :: Maybe ChangeTypeEnum
source = Maybe ChangeTypeEnum
a} :: MergeOperations)

instance Core.FromJSON MergeOperations where
  parseJSON :: Value -> Parser MergeOperations
parseJSON =
    String
-> (Object -> Parser MergeOperations)
-> Value
-> Parser MergeOperations
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MergeOperations"
      ( \Object
x ->
          Maybe ChangeTypeEnum -> Maybe ChangeTypeEnum -> MergeOperations
MergeOperations'
            (Maybe ChangeTypeEnum -> Maybe ChangeTypeEnum -> MergeOperations)
-> Parser (Maybe ChangeTypeEnum)
-> Parser (Maybe ChangeTypeEnum -> MergeOperations)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ChangeTypeEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"destination")
            Parser (Maybe ChangeTypeEnum -> MergeOperations)
-> Parser (Maybe ChangeTypeEnum) -> Parser MergeOperations
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChangeTypeEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"source")
      )

instance Prelude.Hashable MergeOperations

instance Prelude.NFData MergeOperations