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

import Amazonka.CodeCommit.Types.FileModeTypeEnum
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 extrapolated file mode permissions for the file. Valid values
    -- include EXECUTABLE and NORMAL.
    File -> Maybe FileModeTypeEnum
fileMode :: Prelude.Maybe FileModeTypeEnum,
    -- | The blob ID that contains the file information.
    File -> Maybe Text
blobId :: Prelude.Maybe Prelude.Text,
    -- | 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
(File -> File -> Bool) -> (File -> File -> Bool) -> Eq File
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]
(Int -> ReadS File)
-> ReadS [File] -> ReadPrec File -> ReadPrec [File] -> Read 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
(Int -> File -> ShowS)
-> (File -> String) -> ([File] -> ShowS) -> Show File
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. File -> Rep File x)
-> (forall x. Rep File x -> File) -> Generic File
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.
--
-- 'fileMode', 'file_fileMode' - The extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
--
-- 'blobId', 'file_blobId' - The blob ID that contains the file information.
--
-- 'relativePath', 'file_relativePath' - The relative path of the file from the folder where the query
-- originated.
newFile ::
  File
newFile :: File
newFile =
  File' :: Maybe Text
-> Maybe FileModeTypeEnum -> Maybe Text -> Maybe Text -> File
File'
    { $sel:absolutePath:File' :: Maybe Text
absolutePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fileMode:File' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
forall a. Maybe a
Prelude.Nothing,
      $sel:blobId:File' :: Maybe Text
blobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relativePath:File' :: Maybe Text
relativePath = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> File -> f File
file_absolutePath = (File -> Maybe Text)
-> (File -> Maybe Text -> File)
-> Lens File File (Maybe Text) (Maybe Text)
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 extrapolated file mode permissions for the file. Valid values
-- include EXECUTABLE and NORMAL.
file_fileMode :: Lens.Lens' File (Prelude.Maybe FileModeTypeEnum)
file_fileMode :: (Maybe FileModeTypeEnum -> f (Maybe FileModeTypeEnum))
-> File -> f File
file_fileMode = (File -> Maybe FileModeTypeEnum)
-> (File -> Maybe FileModeTypeEnum -> File)
-> Lens File File (Maybe FileModeTypeEnum) (Maybe FileModeTypeEnum)
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 blob ID that contains the file information.
file_blobId :: Lens.Lens' File (Prelude.Maybe Prelude.Text)
file_blobId :: (Maybe Text -> f (Maybe Text)) -> File -> f File
file_blobId = (File -> Maybe Text)
-> (File -> Maybe Text -> File)
-> Lens File File (Maybe Text) (Maybe Text)
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 relative path of the file from the folder where the query
-- originated.
file_relativePath :: Lens.Lens' File (Prelude.Maybe Prelude.Text)
file_relativePath :: (Maybe Text -> f (Maybe Text)) -> File -> f File
file_relativePath = (File -> Maybe Text)
-> (File -> Maybe Text -> File)
-> Lens File File (Maybe Text) (Maybe Text)
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 Core.FromJSON File where
  parseJSON :: Value -> Parser File
parseJSON =
    String -> (Object -> Parser File) -> Value -> Parser File
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"File"
      ( \Object
x ->
          Maybe Text
-> Maybe FileModeTypeEnum -> Maybe Text -> Maybe Text -> File
File'
            (Maybe Text
 -> Maybe FileModeTypeEnum -> Maybe Text -> Maybe Text -> File)
-> Parser (Maybe Text)
-> Parser
     (Maybe FileModeTypeEnum -> Maybe Text -> Maybe Text -> File)
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 -> Maybe Text -> File)
-> Parser (Maybe FileModeTypeEnum)
-> Parser (Maybe Text -> Maybe Text -> File)
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 -> Maybe Text -> File)
-> Parser (Maybe Text) -> Parser (Maybe Text -> File)
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")
            Parser (Maybe Text -> File) -> Parser (Maybe Text) -> Parser File
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
"relativePath")
      )

instance Prelude.Hashable File

instance Prelude.NFData File