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

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

-- | Returns information about a file in a repository.
--
-- /See:/ 'newFile' smart constructor.
data File = File'
  { -- | The fully qualified path to the file in the repository.
    File -> Maybe Text
absolutePath :: Prelude.Maybe Prelude.Text,
    -- | The blob ID that contains the file information.
    File -> Maybe Text
blobId :: Prelude.Maybe Prelude.Text,
    -- | The extrapolated file mode permissions for the file. Valid values
    -- include EXECUTABLE and NORMAL.
    File -> Maybe FileModeTypeEnum
fileMode :: Prelude.Maybe FileModeTypeEnum,
    -- | The relative path of the file from the folder where the query
    -- originated.
    File -> Maybe Text
relativePath :: Prelude.Maybe Prelude.Text
  }
  deriving (File -> File -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: File -> File -> Bool
$c/= :: File -> File -> Bool
== :: File -> File -> Bool
$c== :: File -> File -> Bool
Prelude.Eq, ReadPrec [File]
ReadPrec File
Int -> ReadS File
ReadS [File]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [File]
$creadListPrec :: ReadPrec [File]
readPrec :: ReadPrec File
$creadPrec :: ReadPrec File
readList :: ReadS [File]
$creadList :: ReadS [File]
readsPrec :: Int -> ReadS File
$creadsPrec :: Int -> ReadS File
Prelude.Read, Int -> File -> ShowS
[File] -> ShowS
File -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [File] -> ShowS
$cshowList :: [File] -> ShowS
show :: File -> String
$cshow :: File -> String
showsPrec :: Int -> File -> ShowS
$cshowsPrec :: Int -> File -> ShowS
Prelude.Show, forall x. Rep File x -> File
forall x. File -> Rep File x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep File x -> File
$cfrom :: forall x. File -> Rep File x
Prelude.Generic)

-- |
-- Create a value of 'File' 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', 'file_absolutePath' - The fully qualified path to the file in the repository.
--
-- 'blobId', 'file_blobId' - The blob ID that contains the file information.
--
-- 'fileMode', 'file_fileMode' - The extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
--
-- 'relativePath', 'file_relativePath' - The relative path of the file from the folder where the query
-- originated.
newFile ::
  File
newFile :: File
newFile =
  File'
    { $sel:absolutePath:File' :: Maybe Text
absolutePath = forall a. Maybe a
Prelude.Nothing,
      $sel:blobId:File' :: Maybe Text
blobId = forall a. Maybe a
Prelude.Nothing,
      $sel:fileMode:File' :: Maybe FileModeTypeEnum
fileMode = forall a. Maybe a
Prelude.Nothing,
      $sel:relativePath:File' :: Maybe Text
relativePath = forall a. Maybe a
Prelude.Nothing
    }

-- | The fully qualified path to the file in the repository.
file_absolutePath :: Lens.Lens' File (Prelude.Maybe Prelude.Text)
file_absolutePath :: Lens' File (Maybe Text)
file_absolutePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\File' {Maybe Text
absolutePath :: Maybe Text
$sel:absolutePath:File' :: File -> Maybe Text
absolutePath} -> Maybe Text
absolutePath) (\s :: File
s@File' {} Maybe Text
a -> File
s {$sel:absolutePath:File' :: Maybe Text
absolutePath = Maybe Text
a} :: File)

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

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

-- | The relative path of the file from the folder where the query
-- originated.
file_relativePath :: Lens.Lens' File (Prelude.Maybe Prelude.Text)
file_relativePath :: Lens' File (Maybe Text)
file_relativePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\File' {Maybe Text
relativePath :: Maybe Text
$sel:relativePath:File' :: File -> Maybe Text
relativePath} -> Maybe Text
relativePath) (\s :: File
s@File' {} Maybe Text
a -> File
s {$sel:relativePath:File' :: Maybe Text
relativePath = Maybe Text
a} :: File)

instance Data.FromJSON File where
  parseJSON :: Value -> Parser File
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"File"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe FileModeTypeEnum -> Maybe Text -> File
File'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"absolutePath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"blobId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"fileMode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"relativePath")
      )

instance Prelude.Hashable File where
  hashWithSalt :: Int -> File -> Int
hashWithSalt Int
_salt File' {Maybe Text
Maybe FileModeTypeEnum
relativePath :: Maybe Text
fileMode :: Maybe FileModeTypeEnum
blobId :: Maybe Text
absolutePath :: Maybe Text
$sel:relativePath:File' :: File -> Maybe Text
$sel:fileMode:File' :: File -> Maybe FileModeTypeEnum
$sel:blobId:File' :: File -> Maybe Text
$sel:absolutePath:File' :: File -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
absolutePath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
blobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FileModeTypeEnum
fileMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
relativePath

instance Prelude.NFData File where
  rnf :: File -> ()
rnf File' {Maybe Text
Maybe FileModeTypeEnum
relativePath :: Maybe Text
fileMode :: Maybe FileModeTypeEnum
blobId :: Maybe Text
absolutePath :: Maybe Text
$sel:relativePath:File' :: File -> Maybe Text
$sel:fileMode:File' :: File -> Maybe FileModeTypeEnum
$sel:blobId:File' :: File -> Maybe Text
$sel:absolutePath:File' :: File -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
absolutePath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
blobId
      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 Text
relativePath