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

import Amazonka.CodeCommit.Types.FileModeTypeEnum
import Amazonka.CodeCommit.Types.ReplacementTypeEnum
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a replacement content entry in the conflict of a merge
-- or pull request operation.
--
-- /See:/ 'newReplaceContentEntry' smart constructor.
data ReplaceContentEntry = ReplaceContentEntry'
  { -- | The file mode to apply during conflict resoltion.
    ReplaceContentEntry -> Maybe FileModeTypeEnum
fileMode :: Prelude.Maybe FileModeTypeEnum,
    -- | The base-64 encoded content to use when the replacement type is
    -- USE_NEW_CONTENT.
    ReplaceContentEntry -> Maybe Base64
content :: Prelude.Maybe Core.Base64,
    -- | The path of the conflicting file.
    ReplaceContentEntry -> Text
filePath :: Prelude.Text,
    -- | The replacement type to use when determining how to resolve the
    -- conflict.
    ReplaceContentEntry -> ReplacementTypeEnum
replacementType :: ReplacementTypeEnum
  }
  deriving (ReplaceContentEntry -> ReplaceContentEntry -> Bool
(ReplaceContentEntry -> ReplaceContentEntry -> Bool)
-> (ReplaceContentEntry -> ReplaceContentEntry -> Bool)
-> Eq ReplaceContentEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplaceContentEntry -> ReplaceContentEntry -> Bool
$c/= :: ReplaceContentEntry -> ReplaceContentEntry -> Bool
== :: ReplaceContentEntry -> ReplaceContentEntry -> Bool
$c== :: ReplaceContentEntry -> ReplaceContentEntry -> Bool
Prelude.Eq, ReadPrec [ReplaceContentEntry]
ReadPrec ReplaceContentEntry
Int -> ReadS ReplaceContentEntry
ReadS [ReplaceContentEntry]
(Int -> ReadS ReplaceContentEntry)
-> ReadS [ReplaceContentEntry]
-> ReadPrec ReplaceContentEntry
-> ReadPrec [ReplaceContentEntry]
-> Read ReplaceContentEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplaceContentEntry]
$creadListPrec :: ReadPrec [ReplaceContentEntry]
readPrec :: ReadPrec ReplaceContentEntry
$creadPrec :: ReadPrec ReplaceContentEntry
readList :: ReadS [ReplaceContentEntry]
$creadList :: ReadS [ReplaceContentEntry]
readsPrec :: Int -> ReadS ReplaceContentEntry
$creadsPrec :: Int -> ReadS ReplaceContentEntry
Prelude.Read, Int -> ReplaceContentEntry -> ShowS
[ReplaceContentEntry] -> ShowS
ReplaceContentEntry -> String
(Int -> ReplaceContentEntry -> ShowS)
-> (ReplaceContentEntry -> String)
-> ([ReplaceContentEntry] -> ShowS)
-> Show ReplaceContentEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplaceContentEntry] -> ShowS
$cshowList :: [ReplaceContentEntry] -> ShowS
show :: ReplaceContentEntry -> String
$cshow :: ReplaceContentEntry -> String
showsPrec :: Int -> ReplaceContentEntry -> ShowS
$cshowsPrec :: Int -> ReplaceContentEntry -> ShowS
Prelude.Show, (forall x. ReplaceContentEntry -> Rep ReplaceContentEntry x)
-> (forall x. Rep ReplaceContentEntry x -> ReplaceContentEntry)
-> Generic ReplaceContentEntry
forall x. Rep ReplaceContentEntry x -> ReplaceContentEntry
forall x. ReplaceContentEntry -> Rep ReplaceContentEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplaceContentEntry x -> ReplaceContentEntry
$cfrom :: forall x. ReplaceContentEntry -> Rep ReplaceContentEntry x
Prelude.Generic)

-- |
-- Create a value of 'ReplaceContentEntry' 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:
--
-- 'fileMode', 'replaceContentEntry_fileMode' - The file mode to apply during conflict resoltion.
--
-- 'content', 'replaceContentEntry_content' - The base-64 encoded content to use when the replacement type is
-- USE_NEW_CONTENT.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'filePath', 'replaceContentEntry_filePath' - The path of the conflicting file.
--
-- 'replacementType', 'replaceContentEntry_replacementType' - The replacement type to use when determining how to resolve the
-- conflict.
newReplaceContentEntry ::
  -- | 'filePath'
  Prelude.Text ->
  -- | 'replacementType'
  ReplacementTypeEnum ->
  ReplaceContentEntry
newReplaceContentEntry :: Text -> ReplacementTypeEnum -> ReplaceContentEntry
newReplaceContentEntry Text
pFilePath_ ReplacementTypeEnum
pReplacementType_ =
  ReplaceContentEntry' :: Maybe FileModeTypeEnum
-> Maybe Base64
-> Text
-> ReplacementTypeEnum
-> ReplaceContentEntry
ReplaceContentEntry'
    { $sel:fileMode:ReplaceContentEntry' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:content:ReplaceContentEntry' :: Maybe Base64
content = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:filePath:ReplaceContentEntry' :: Text
filePath = Text
pFilePath_,
      $sel:replacementType:ReplaceContentEntry' :: ReplacementTypeEnum
replacementType = ReplacementTypeEnum
pReplacementType_
    }

-- | The file mode to apply during conflict resoltion.
replaceContentEntry_fileMode :: Lens.Lens' ReplaceContentEntry (Prelude.Maybe FileModeTypeEnum)
replaceContentEntry_fileMode :: (Maybe FileModeTypeEnum -> f (Maybe FileModeTypeEnum))
-> ReplaceContentEntry -> f ReplaceContentEntry
replaceContentEntry_fileMode = (ReplaceContentEntry -> Maybe FileModeTypeEnum)
-> (ReplaceContentEntry
    -> Maybe FileModeTypeEnum -> ReplaceContentEntry)
-> Lens
     ReplaceContentEntry
     ReplaceContentEntry
     (Maybe FileModeTypeEnum)
     (Maybe FileModeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceContentEntry' {Maybe FileModeTypeEnum
fileMode :: Maybe FileModeTypeEnum
$sel:fileMode:ReplaceContentEntry' :: ReplaceContentEntry -> Maybe FileModeTypeEnum
fileMode} -> Maybe FileModeTypeEnum
fileMode) (\s :: ReplaceContentEntry
s@ReplaceContentEntry' {} Maybe FileModeTypeEnum
a -> ReplaceContentEntry
s {$sel:fileMode:ReplaceContentEntry' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
a} :: ReplaceContentEntry)

-- | The base-64 encoded content to use when the replacement type is
-- USE_NEW_CONTENT.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
replaceContentEntry_content :: Lens.Lens' ReplaceContentEntry (Prelude.Maybe Prelude.ByteString)
replaceContentEntry_content :: (Maybe ByteString -> f (Maybe ByteString))
-> ReplaceContentEntry -> f ReplaceContentEntry
replaceContentEntry_content = (ReplaceContentEntry -> Maybe Base64)
-> (ReplaceContentEntry -> Maybe Base64 -> ReplaceContentEntry)
-> Lens
     ReplaceContentEntry
     ReplaceContentEntry
     (Maybe Base64)
     (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceContentEntry' {Maybe Base64
content :: Maybe Base64
$sel:content:ReplaceContentEntry' :: ReplaceContentEntry -> Maybe Base64
content} -> Maybe Base64
content) (\s :: ReplaceContentEntry
s@ReplaceContentEntry' {} Maybe Base64
a -> ReplaceContentEntry
s {$sel:content:ReplaceContentEntry' :: Maybe Base64
content = Maybe Base64
a} :: ReplaceContentEntry) ((Maybe Base64 -> f (Maybe Base64))
 -> ReplaceContentEntry -> f ReplaceContentEntry)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> ReplaceContentEntry
-> f ReplaceContentEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

-- | The path of the conflicting file.
replaceContentEntry_filePath :: Lens.Lens' ReplaceContentEntry Prelude.Text
replaceContentEntry_filePath :: (Text -> f Text) -> ReplaceContentEntry -> f ReplaceContentEntry
replaceContentEntry_filePath = (ReplaceContentEntry -> Text)
-> (ReplaceContentEntry -> Text -> ReplaceContentEntry)
-> Lens ReplaceContentEntry ReplaceContentEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceContentEntry' {Text
filePath :: Text
$sel:filePath:ReplaceContentEntry' :: ReplaceContentEntry -> Text
filePath} -> Text
filePath) (\s :: ReplaceContentEntry
s@ReplaceContentEntry' {} Text
a -> ReplaceContentEntry
s {$sel:filePath:ReplaceContentEntry' :: Text
filePath = Text
a} :: ReplaceContentEntry)

-- | The replacement type to use when determining how to resolve the
-- conflict.
replaceContentEntry_replacementType :: Lens.Lens' ReplaceContentEntry ReplacementTypeEnum
replaceContentEntry_replacementType :: (ReplacementTypeEnum -> f ReplacementTypeEnum)
-> ReplaceContentEntry -> f ReplaceContentEntry
replaceContentEntry_replacementType = (ReplaceContentEntry -> ReplacementTypeEnum)
-> (ReplaceContentEntry
    -> ReplacementTypeEnum -> ReplaceContentEntry)
-> Lens
     ReplaceContentEntry
     ReplaceContentEntry
     ReplacementTypeEnum
     ReplacementTypeEnum
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceContentEntry' {ReplacementTypeEnum
replacementType :: ReplacementTypeEnum
$sel:replacementType:ReplaceContentEntry' :: ReplaceContentEntry -> ReplacementTypeEnum
replacementType} -> ReplacementTypeEnum
replacementType) (\s :: ReplaceContentEntry
s@ReplaceContentEntry' {} ReplacementTypeEnum
a -> ReplaceContentEntry
s {$sel:replacementType:ReplaceContentEntry' :: ReplacementTypeEnum
replacementType = ReplacementTypeEnum
a} :: ReplaceContentEntry)

instance Prelude.Hashable ReplaceContentEntry

instance Prelude.NFData ReplaceContentEntry

instance Core.ToJSON ReplaceContentEntry where
  toJSON :: ReplaceContentEntry -> Value
toJSON ReplaceContentEntry' {Maybe Base64
Maybe FileModeTypeEnum
Text
ReplacementTypeEnum
replacementType :: ReplacementTypeEnum
filePath :: Text
content :: Maybe Base64
fileMode :: Maybe FileModeTypeEnum
$sel:replacementType:ReplaceContentEntry' :: ReplaceContentEntry -> ReplacementTypeEnum
$sel:filePath:ReplaceContentEntry' :: ReplaceContentEntry -> Text
$sel:content:ReplaceContentEntry' :: ReplaceContentEntry -> Maybe Base64
$sel:fileMode:ReplaceContentEntry' :: ReplaceContentEntry -> Maybe FileModeTypeEnum
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"fileMode" Text -> FileModeTypeEnum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FileModeTypeEnum -> Pair) -> Maybe FileModeTypeEnum -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileModeTypeEnum
fileMode,
            (Text
"content" Text -> Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Base64 -> Pair) -> Maybe Base64 -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Base64
content,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"filePath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
filePath),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"replacementType" Text -> ReplacementTypeEnum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ReplacementTypeEnum
replacementType)
          ]
      )