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

import Amazonka.CodeCommit.Types.FileModeTypeEnum
import Amazonka.CodeCommit.Types.SourceFileSpecifier
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

-- | 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 Data.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
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]
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
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. 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'
    { $sel:fileContent:PutFileEntry' :: Maybe Base64
fileContent = forall a. Maybe a
Prelude.Nothing,
      $sel:fileMode:PutFileEntry' :: Maybe FileModeTypeEnum
fileMode = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceFile:PutFileEntry' :: Maybe SourceFileSpecifier
sourceFile = 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 :: Lens' PutFileEntry (Maybe ByteString)
putFileEntry_fileContent = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 Iso' Base64 ByteString
Data._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 :: Lens' PutFileEntry (Maybe FileModeTypeEnum)
putFileEntry_fileMode = 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 :: Lens' PutFileEntry (Maybe SourceFileSpecifier)
putFileEntry_sourceFile = 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 :: Lens' PutFileEntry Text
putFileEntry_filePath = 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 where
  hashWithSalt :: Int -> PutFileEntry -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Base64
fileContent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FileModeTypeEnum
fileMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SourceFileSpecifier
sourceFile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
filePath

instance Prelude.NFData PutFileEntry where
  rnf :: PutFileEntry -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Base64
fileContent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FileModeTypeEnum
fileMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SourceFileSpecifier
sourceFile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
filePath

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"fileContent" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Base64
fileContent,
            (Key
"fileMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileModeTypeEnum
fileMode,
            (Key
"sourceFile" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourceFileSpecifier
sourceFile,
            forall a. a -> Maybe a
Prelude.Just (Key
"filePath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
filePath)
          ]
      )