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

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 source file that is part of changes made in a
-- commit.
--
-- /See:/ 'newSourceFileSpecifier' smart constructor.
data SourceFileSpecifier = SourceFileSpecifier'
  { -- | Whether to remove the source file from the parent commit.
    SourceFileSpecifier -> Maybe Bool
isMove :: Prelude.Maybe Prelude.Bool,
    -- | The full path to the file, including the name of the file.
    SourceFileSpecifier -> Text
filePath :: Prelude.Text
  }
  deriving (SourceFileSpecifier -> SourceFileSpecifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceFileSpecifier -> SourceFileSpecifier -> Bool
$c/= :: SourceFileSpecifier -> SourceFileSpecifier -> Bool
== :: SourceFileSpecifier -> SourceFileSpecifier -> Bool
$c== :: SourceFileSpecifier -> SourceFileSpecifier -> Bool
Prelude.Eq, ReadPrec [SourceFileSpecifier]
ReadPrec SourceFileSpecifier
Int -> ReadS SourceFileSpecifier
ReadS [SourceFileSpecifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceFileSpecifier]
$creadListPrec :: ReadPrec [SourceFileSpecifier]
readPrec :: ReadPrec SourceFileSpecifier
$creadPrec :: ReadPrec SourceFileSpecifier
readList :: ReadS [SourceFileSpecifier]
$creadList :: ReadS [SourceFileSpecifier]
readsPrec :: Int -> ReadS SourceFileSpecifier
$creadsPrec :: Int -> ReadS SourceFileSpecifier
Prelude.Read, Int -> SourceFileSpecifier -> ShowS
[SourceFileSpecifier] -> ShowS
SourceFileSpecifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceFileSpecifier] -> ShowS
$cshowList :: [SourceFileSpecifier] -> ShowS
show :: SourceFileSpecifier -> String
$cshow :: SourceFileSpecifier -> String
showsPrec :: Int -> SourceFileSpecifier -> ShowS
$cshowsPrec :: Int -> SourceFileSpecifier -> ShowS
Prelude.Show, forall x. Rep SourceFileSpecifier x -> SourceFileSpecifier
forall x. SourceFileSpecifier -> Rep SourceFileSpecifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceFileSpecifier x -> SourceFileSpecifier
$cfrom :: forall x. SourceFileSpecifier -> Rep SourceFileSpecifier x
Prelude.Generic)

-- |
-- Create a value of 'SourceFileSpecifier' 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:
--
-- 'isMove', 'sourceFileSpecifier_isMove' - Whether to remove the source file from the parent commit.
--
-- 'filePath', 'sourceFileSpecifier_filePath' - The full path to the file, including the name of the file.
newSourceFileSpecifier ::
  -- | 'filePath'
  Prelude.Text ->
  SourceFileSpecifier
newSourceFileSpecifier :: Text -> SourceFileSpecifier
newSourceFileSpecifier Text
pFilePath_ =
  SourceFileSpecifier'
    { $sel:isMove:SourceFileSpecifier' :: Maybe Bool
isMove = forall a. Maybe a
Prelude.Nothing,
      $sel:filePath:SourceFileSpecifier' :: Text
filePath = Text
pFilePath_
    }

-- | Whether to remove the source file from the parent commit.
sourceFileSpecifier_isMove :: Lens.Lens' SourceFileSpecifier (Prelude.Maybe Prelude.Bool)
sourceFileSpecifier_isMove :: Lens' SourceFileSpecifier (Maybe Bool)
sourceFileSpecifier_isMove = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceFileSpecifier' {Maybe Bool
isMove :: Maybe Bool
$sel:isMove:SourceFileSpecifier' :: SourceFileSpecifier -> Maybe Bool
isMove} -> Maybe Bool
isMove) (\s :: SourceFileSpecifier
s@SourceFileSpecifier' {} Maybe Bool
a -> SourceFileSpecifier
s {$sel:isMove:SourceFileSpecifier' :: Maybe Bool
isMove = Maybe Bool
a} :: SourceFileSpecifier)

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

instance Prelude.Hashable SourceFileSpecifier where
  hashWithSalt :: Int -> SourceFileSpecifier -> Int
hashWithSalt Int
_salt SourceFileSpecifier' {Maybe Bool
Text
filePath :: Text
isMove :: Maybe Bool
$sel:filePath:SourceFileSpecifier' :: SourceFileSpecifier -> Text
$sel:isMove:SourceFileSpecifier' :: SourceFileSpecifier -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isMove
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
filePath

instance Prelude.NFData SourceFileSpecifier where
  rnf :: SourceFileSpecifier -> ()
rnf SourceFileSpecifier' {Maybe Bool
Text
filePath :: Text
isMove :: Maybe Bool
$sel:filePath:SourceFileSpecifier' :: SourceFileSpecifier -> Text
$sel:isMove:SourceFileSpecifier' :: SourceFileSpecifier -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isMove
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
filePath

instance Data.ToJSON SourceFileSpecifier where
  toJSON :: SourceFileSpecifier -> Value
toJSON SourceFileSpecifier' {Maybe Bool
Text
filePath :: Text
isMove :: Maybe Bool
$sel:filePath:SourceFileSpecifier' :: SourceFileSpecifier -> Text
$sel:isMove:SourceFileSpecifier' :: SourceFileSpecifier -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"isMove" 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 Bool
isMove,
            forall a. a -> Maybe a
Prelude.Just (Key
"filePath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
filePath)
          ]
      )