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

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

-- | A file to be added, updated, or deleted as part of a commit.
--
-- /See:/ 'newFileMetadata' smart constructor.
data FileMetadata = FileMetadata'
  { -- | The full path to the file to be added or updated, including the name of
    -- the file.
    FileMetadata -> Maybe Text
absolutePath :: Prelude.Maybe Prelude.Text,
    -- | The extrapolated file mode permissions for the file. Valid values
    -- include EXECUTABLE and NORMAL.
    FileMetadata -> Maybe FileModeTypeEnum
fileMode :: Prelude.Maybe FileModeTypeEnum,
    -- | The blob ID that contains the file information.
    FileMetadata -> Maybe Text
blobId :: Prelude.Maybe Prelude.Text
  }
  deriving (FileMetadata -> FileMetadata -> Bool
(FileMetadata -> FileMetadata -> Bool)
-> (FileMetadata -> FileMetadata -> Bool) -> Eq FileMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileMetadata -> FileMetadata -> Bool
$c/= :: FileMetadata -> FileMetadata -> Bool
== :: FileMetadata -> FileMetadata -> Bool
$c== :: FileMetadata -> FileMetadata -> Bool
Prelude.Eq, ReadPrec [FileMetadata]
ReadPrec FileMetadata
Int -> ReadS FileMetadata
ReadS [FileMetadata]
(Int -> ReadS FileMetadata)
-> ReadS [FileMetadata]
-> ReadPrec FileMetadata
-> ReadPrec [FileMetadata]
-> Read FileMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileMetadata]
$creadListPrec :: ReadPrec [FileMetadata]
readPrec :: ReadPrec FileMetadata
$creadPrec :: ReadPrec FileMetadata
readList :: ReadS [FileMetadata]
$creadList :: ReadS [FileMetadata]
readsPrec :: Int -> ReadS FileMetadata
$creadsPrec :: Int -> ReadS FileMetadata
Prelude.Read, Int -> FileMetadata -> ShowS
[FileMetadata] -> ShowS
FileMetadata -> String
(Int -> FileMetadata -> ShowS)
-> (FileMetadata -> String)
-> ([FileMetadata] -> ShowS)
-> Show FileMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileMetadata] -> ShowS
$cshowList :: [FileMetadata] -> ShowS
show :: FileMetadata -> String
$cshow :: FileMetadata -> String
showsPrec :: Int -> FileMetadata -> ShowS
$cshowsPrec :: Int -> FileMetadata -> ShowS
Prelude.Show, (forall x. FileMetadata -> Rep FileMetadata x)
-> (forall x. Rep FileMetadata x -> FileMetadata)
-> Generic FileMetadata
forall x. Rep FileMetadata x -> FileMetadata
forall x. FileMetadata -> Rep FileMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileMetadata x -> FileMetadata
$cfrom :: forall x. FileMetadata -> Rep FileMetadata x
Prelude.Generic)

-- |
-- Create a value of 'FileMetadata' 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:
--
-- 'absolutePath', 'fileMetadata_absolutePath' - The full path to the file to be added or updated, including the name of
-- the file.
--
-- 'fileMode', 'fileMetadata_fileMode' - The extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
--
-- 'blobId', 'fileMetadata_blobId' - The blob ID that contains the file information.
newFileMetadata ::
  FileMetadata
newFileMetadata :: FileMetadata
newFileMetadata =
  FileMetadata' :: Maybe Text -> Maybe FileModeTypeEnum -> Maybe Text -> FileMetadata
FileMetadata'
    { $sel:absolutePath:FileMetadata' :: Maybe Text
absolutePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fileMode:FileMetadata' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:blobId:FileMetadata' :: Maybe Text
blobId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The full path to the file to be added or updated, including the name of
-- the file.
fileMetadata_absolutePath :: Lens.Lens' FileMetadata (Prelude.Maybe Prelude.Text)
fileMetadata_absolutePath :: (Maybe Text -> f (Maybe Text)) -> FileMetadata -> f FileMetadata
fileMetadata_absolutePath = (FileMetadata -> Maybe Text)
-> (FileMetadata -> Maybe Text -> FileMetadata)
-> Lens FileMetadata FileMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileMetadata' {Maybe Text
absolutePath :: Maybe Text
$sel:absolutePath:FileMetadata' :: FileMetadata -> Maybe Text
absolutePath} -> Maybe Text
absolutePath) (\s :: FileMetadata
s@FileMetadata' {} Maybe Text
a -> FileMetadata
s {$sel:absolutePath:FileMetadata' :: Maybe Text
absolutePath = Maybe Text
a} :: FileMetadata)

-- | The extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
fileMetadata_fileMode :: Lens.Lens' FileMetadata (Prelude.Maybe FileModeTypeEnum)
fileMetadata_fileMode :: (Maybe FileModeTypeEnum -> f (Maybe FileModeTypeEnum))
-> FileMetadata -> f FileMetadata
fileMetadata_fileMode = (FileMetadata -> Maybe FileModeTypeEnum)
-> (FileMetadata -> Maybe FileModeTypeEnum -> FileMetadata)
-> Lens
     FileMetadata
     FileMetadata
     (Maybe FileModeTypeEnum)
     (Maybe FileModeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileMetadata' {Maybe FileModeTypeEnum
fileMode :: Maybe FileModeTypeEnum
$sel:fileMode:FileMetadata' :: FileMetadata -> Maybe FileModeTypeEnum
fileMode} -> Maybe FileModeTypeEnum
fileMode) (\s :: FileMetadata
s@FileMetadata' {} Maybe FileModeTypeEnum
a -> FileMetadata
s {$sel:fileMode:FileMetadata' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
a} :: FileMetadata)

-- | The blob ID that contains the file information.
fileMetadata_blobId :: Lens.Lens' FileMetadata (Prelude.Maybe Prelude.Text)
fileMetadata_blobId :: (Maybe Text -> f (Maybe Text)) -> FileMetadata -> f FileMetadata
fileMetadata_blobId = (FileMetadata -> Maybe Text)
-> (FileMetadata -> Maybe Text -> FileMetadata)
-> Lens FileMetadata FileMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileMetadata' {Maybe Text
blobId :: Maybe Text
$sel:blobId:FileMetadata' :: FileMetadata -> Maybe Text
blobId} -> Maybe Text
blobId) (\s :: FileMetadata
s@FileMetadata' {} Maybe Text
a -> FileMetadata
s {$sel:blobId:FileMetadata' :: Maybe Text
blobId = Maybe Text
a} :: FileMetadata)

instance Core.FromJSON FileMetadata where
  parseJSON :: Value -> Parser FileMetadata
parseJSON =
    String
-> (Object -> Parser FileMetadata) -> Value -> Parser FileMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FileMetadata"
      ( \Object
x ->
          Maybe Text -> Maybe FileModeTypeEnum -> Maybe Text -> FileMetadata
FileMetadata'
            (Maybe Text
 -> Maybe FileModeTypeEnum -> Maybe Text -> FileMetadata)
-> Parser (Maybe Text)
-> Parser (Maybe FileModeTypeEnum -> Maybe Text -> FileMetadata)
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
"absolutePath")
            Parser (Maybe FileModeTypeEnum -> Maybe Text -> FileMetadata)
-> Parser (Maybe FileModeTypeEnum)
-> Parser (Maybe Text -> FileMetadata)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FileModeTypeEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"fileMode")
            Parser (Maybe Text -> FileMetadata)
-> Parser (Maybe Text) -> Parser FileMetadata
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
"blobId")
      )

instance Prelude.Hashable FileMetadata

instance Prelude.NFData FileMetadata