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

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

-- | Information about a file added or updated as part of a commit.
--
-- /See:/ 'newPutFileEntry' smart constructor.
data PutFileEntry = PutFileEntry'
  { -- | The content of the file, if a source file is not specified.
    PutFileEntry -> Maybe Base64
fileContent :: Prelude.Maybe Core.Base64,
    -- | The extrapolated file mode permissions for the file. Valid values
    -- include EXECUTABLE and NORMAL.
    PutFileEntry -> Maybe FileModeTypeEnum
fileMode :: Prelude.Maybe FileModeTypeEnum,
    -- | The name and full path of the file that contains the changes you want to
    -- make as part of the commit, if you are not providing the file content
    -- directly.
    PutFileEntry -> Maybe SourceFileSpecifier
sourceFile :: Prelude.Maybe SourceFileSpecifier,
    -- | The full path to the file in the repository, including the name of the
    -- file.
    PutFileEntry -> Text
filePath :: Prelude.Text
  }
  deriving (PutFileEntry -> PutFileEntry -> Bool
(PutFileEntry -> PutFileEntry -> Bool)
-> (PutFileEntry -> PutFileEntry -> Bool) -> Eq PutFileEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutFileEntry -> PutFileEntry -> Bool
$c/= :: PutFileEntry -> PutFileEntry -> Bool
== :: PutFileEntry -> PutFileEntry -> Bool
$c== :: PutFileEntry -> PutFileEntry -> Bool
Prelude.Eq, ReadPrec [PutFileEntry]
ReadPrec PutFileEntry
Int -> ReadS PutFileEntry
ReadS [PutFileEntry]
(Int -> ReadS PutFileEntry)
-> ReadS [PutFileEntry]
-> ReadPrec PutFileEntry
-> ReadPrec [PutFileEntry]
-> Read PutFileEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutFileEntry]
$creadListPrec :: ReadPrec [PutFileEntry]
readPrec :: ReadPrec PutFileEntry
$creadPrec :: ReadPrec PutFileEntry
readList :: ReadS [PutFileEntry]
$creadList :: ReadS [PutFileEntry]
readsPrec :: Int -> ReadS PutFileEntry
$creadsPrec :: Int -> ReadS PutFileEntry
Prelude.Read, Int -> PutFileEntry -> ShowS
[PutFileEntry] -> ShowS
PutFileEntry -> String
(Int -> PutFileEntry -> ShowS)
-> (PutFileEntry -> String)
-> ([PutFileEntry] -> ShowS)
-> Show PutFileEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutFileEntry] -> ShowS
$cshowList :: [PutFileEntry] -> ShowS
show :: PutFileEntry -> String
$cshow :: PutFileEntry -> String
showsPrec :: Int -> PutFileEntry -> ShowS
$cshowsPrec :: Int -> PutFileEntry -> ShowS
Prelude.Show, (forall x. PutFileEntry -> Rep PutFileEntry x)
-> (forall x. Rep PutFileEntry x -> PutFileEntry)
-> Generic PutFileEntry
forall x. Rep PutFileEntry x -> PutFileEntry
forall x. PutFileEntry -> Rep PutFileEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutFileEntry x -> PutFileEntry
$cfrom :: forall x. PutFileEntry -> Rep PutFileEntry x
Prelude.Generic)

-- |
-- Create a value of 'PutFileEntry' 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:
--
-- 'fileContent', 'putFileEntry_fileContent' - The content of the file, if a source file is not specified.--
-- -- /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.
--
-- 'fileMode', 'putFileEntry_fileMode' - The extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
--
-- 'sourceFile', 'putFileEntry_sourceFile' - The name and full path of the file that contains the changes you want to
-- make as part of the commit, if you are not providing the file content
-- directly.
--
-- 'filePath', 'putFileEntry_filePath' - The full path to the file in the repository, including the name of the
-- file.
newPutFileEntry ::
  -- | 'filePath'
  Prelude.Text ->
  PutFileEntry
newPutFileEntry :: Text -> PutFileEntry
newPutFileEntry Text
pFilePath_ =
  PutFileEntry' :: Maybe Base64
-> Maybe FileModeTypeEnum
-> Maybe SourceFileSpecifier
-> Text
-> PutFileEntry
PutFileEntry'
    { $sel:fileContent:PutFileEntry' :: Maybe Base64
fileContent = Maybe Base64
forall a. Maybe a
Prelude.Nothing,
      $sel:fileMode:PutFileEntry' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceFile:PutFileEntry' :: Maybe SourceFileSpecifier
sourceFile = Maybe SourceFileSpecifier
forall a. Maybe a
Prelude.Nothing,
      $sel:filePath:PutFileEntry' :: Text
filePath = Text
pFilePath_
    }

-- | The content of the file, if a source file is not specified.--
-- -- /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.
putFileEntry_fileContent :: Lens.Lens' PutFileEntry (Prelude.Maybe Prelude.ByteString)
putFileEntry_fileContent :: (Maybe ByteString -> f (Maybe ByteString))
-> PutFileEntry -> f PutFileEntry
putFileEntry_fileContent = (PutFileEntry -> Maybe Base64)
-> (PutFileEntry -> Maybe Base64 -> PutFileEntry)
-> Lens PutFileEntry PutFileEntry (Maybe Base64) (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileEntry' {Maybe Base64
fileContent :: Maybe Base64
$sel:fileContent:PutFileEntry' :: PutFileEntry -> Maybe Base64
fileContent} -> Maybe Base64
fileContent) (\s :: PutFileEntry
s@PutFileEntry' {} Maybe Base64
a -> PutFileEntry
s {$sel:fileContent:PutFileEntry' :: Maybe Base64
fileContent = Maybe Base64
a} :: PutFileEntry) ((Maybe Base64 -> f (Maybe Base64))
 -> PutFileEntry -> f PutFileEntry)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> PutFileEntry
-> f PutFileEntry
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 extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
putFileEntry_fileMode :: Lens.Lens' PutFileEntry (Prelude.Maybe FileModeTypeEnum)
putFileEntry_fileMode :: (Maybe FileModeTypeEnum -> f (Maybe FileModeTypeEnum))
-> PutFileEntry -> f PutFileEntry
putFileEntry_fileMode = (PutFileEntry -> Maybe FileModeTypeEnum)
-> (PutFileEntry -> Maybe FileModeTypeEnum -> PutFileEntry)
-> Lens
     PutFileEntry
     PutFileEntry
     (Maybe FileModeTypeEnum)
     (Maybe FileModeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileEntry' {Maybe FileModeTypeEnum
fileMode :: Maybe FileModeTypeEnum
$sel:fileMode:PutFileEntry' :: PutFileEntry -> Maybe FileModeTypeEnum
fileMode} -> Maybe FileModeTypeEnum
fileMode) (\s :: PutFileEntry
s@PutFileEntry' {} Maybe FileModeTypeEnum
a -> PutFileEntry
s {$sel:fileMode:PutFileEntry' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
a} :: PutFileEntry)

-- | The name and full path of the file that contains the changes you want to
-- make as part of the commit, if you are not providing the file content
-- directly.
putFileEntry_sourceFile :: Lens.Lens' PutFileEntry (Prelude.Maybe SourceFileSpecifier)
putFileEntry_sourceFile :: (Maybe SourceFileSpecifier -> f (Maybe SourceFileSpecifier))
-> PutFileEntry -> f PutFileEntry
putFileEntry_sourceFile = (PutFileEntry -> Maybe SourceFileSpecifier)
-> (PutFileEntry -> Maybe SourceFileSpecifier -> PutFileEntry)
-> Lens
     PutFileEntry
     PutFileEntry
     (Maybe SourceFileSpecifier)
     (Maybe SourceFileSpecifier)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileEntry' {Maybe SourceFileSpecifier
sourceFile :: Maybe SourceFileSpecifier
$sel:sourceFile:PutFileEntry' :: PutFileEntry -> Maybe SourceFileSpecifier
sourceFile} -> Maybe SourceFileSpecifier
sourceFile) (\s :: PutFileEntry
s@PutFileEntry' {} Maybe SourceFileSpecifier
a -> PutFileEntry
s {$sel:sourceFile:PutFileEntry' :: Maybe SourceFileSpecifier
sourceFile = Maybe SourceFileSpecifier
a} :: PutFileEntry)

-- | The full path to the file in the repository, including the name of the
-- file.
putFileEntry_filePath :: Lens.Lens' PutFileEntry Prelude.Text
putFileEntry_filePath :: (Text -> f Text) -> PutFileEntry -> f PutFileEntry
putFileEntry_filePath = (PutFileEntry -> Text)
-> (PutFileEntry -> Text -> PutFileEntry)
-> Lens PutFileEntry PutFileEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileEntry' {Text
filePath :: Text
$sel:filePath:PutFileEntry' :: PutFileEntry -> Text
filePath} -> Text
filePath) (\s :: PutFileEntry
s@PutFileEntry' {} Text
a -> PutFileEntry
s {$sel:filePath:PutFileEntry' :: Text
filePath = Text
a} :: PutFileEntry)

instance Prelude.Hashable PutFileEntry

instance Prelude.NFData PutFileEntry

instance Core.ToJSON PutFileEntry where
  toJSON :: PutFileEntry -> Value
toJSON PutFileEntry' {Maybe Base64
Maybe FileModeTypeEnum
Maybe SourceFileSpecifier
Text
filePath :: Text
sourceFile :: Maybe SourceFileSpecifier
fileMode :: Maybe FileModeTypeEnum
fileContent :: Maybe Base64
$sel:filePath:PutFileEntry' :: PutFileEntry -> Text
$sel:sourceFile:PutFileEntry' :: PutFileEntry -> Maybe SourceFileSpecifier
$sel:fileMode:PutFileEntry' :: PutFileEntry -> Maybe FileModeTypeEnum
$sel:fileContent:PutFileEntry' :: PutFileEntry -> Maybe Base64
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"fileContent" 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
fileContent,
            (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
"sourceFile" Text -> SourceFileSpecifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SourceFileSpecifier -> Pair)
-> Maybe SourceFileSpecifier -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourceFileSpecifier
sourceFile,
            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)
          ]
      )