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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about a submodule reference in a repository folder.
--
-- /See:/ 'newSubModule' smart constructor.
data SubModule = SubModule'
  { -- | The commit ID that contains the reference to the submodule.
    SubModule -> Maybe Text
commitId :: Prelude.Maybe Prelude.Text,
    -- | The fully qualified path to the folder that contains the reference to
    -- the submodule.
    SubModule -> Maybe Text
absolutePath :: Prelude.Maybe Prelude.Text,
    -- | The relative path of the submodule from the folder where the query
    -- originated.
    SubModule -> Maybe Text
relativePath :: Prelude.Maybe Prelude.Text
  }
  deriving (SubModule -> SubModule -> Bool
(SubModule -> SubModule -> Bool)
-> (SubModule -> SubModule -> Bool) -> Eq SubModule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubModule -> SubModule -> Bool
$c/= :: SubModule -> SubModule -> Bool
== :: SubModule -> SubModule -> Bool
$c== :: SubModule -> SubModule -> Bool
Prelude.Eq, ReadPrec [SubModule]
ReadPrec SubModule
Int -> ReadS SubModule
ReadS [SubModule]
(Int -> ReadS SubModule)
-> ReadS [SubModule]
-> ReadPrec SubModule
-> ReadPrec [SubModule]
-> Read SubModule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubModule]
$creadListPrec :: ReadPrec [SubModule]
readPrec :: ReadPrec SubModule
$creadPrec :: ReadPrec SubModule
readList :: ReadS [SubModule]
$creadList :: ReadS [SubModule]
readsPrec :: Int -> ReadS SubModule
$creadsPrec :: Int -> ReadS SubModule
Prelude.Read, Int -> SubModule -> ShowS
[SubModule] -> ShowS
SubModule -> String
(Int -> SubModule -> ShowS)
-> (SubModule -> String)
-> ([SubModule] -> ShowS)
-> Show SubModule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubModule] -> ShowS
$cshowList :: [SubModule] -> ShowS
show :: SubModule -> String
$cshow :: SubModule -> String
showsPrec :: Int -> SubModule -> ShowS
$cshowsPrec :: Int -> SubModule -> ShowS
Prelude.Show, (forall x. SubModule -> Rep SubModule x)
-> (forall x. Rep SubModule x -> SubModule) -> Generic SubModule
forall x. Rep SubModule x -> SubModule
forall x. SubModule -> Rep SubModule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubModule x -> SubModule
$cfrom :: forall x. SubModule -> Rep SubModule x
Prelude.Generic)

-- |
-- Create a value of 'SubModule' 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:
--
-- 'commitId', 'subModule_commitId' - The commit ID that contains the reference to the submodule.
--
-- 'absolutePath', 'subModule_absolutePath' - The fully qualified path to the folder that contains the reference to
-- the submodule.
--
-- 'relativePath', 'subModule_relativePath' - The relative path of the submodule from the folder where the query
-- originated.
newSubModule ::
  SubModule
newSubModule :: SubModule
newSubModule =
  SubModule' :: Maybe Text -> Maybe Text -> Maybe Text -> SubModule
SubModule'
    { $sel:commitId:SubModule' :: Maybe Text
commitId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:absolutePath:SubModule' :: Maybe Text
absolutePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:relativePath:SubModule' :: Maybe Text
relativePath = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The commit ID that contains the reference to the submodule.
subModule_commitId :: Lens.Lens' SubModule (Prelude.Maybe Prelude.Text)
subModule_commitId :: (Maybe Text -> f (Maybe Text)) -> SubModule -> f SubModule
subModule_commitId = (SubModule -> Maybe Text)
-> (SubModule -> Maybe Text -> SubModule)
-> Lens SubModule SubModule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubModule' {Maybe Text
commitId :: Maybe Text
$sel:commitId:SubModule' :: SubModule -> Maybe Text
commitId} -> Maybe Text
commitId) (\s :: SubModule
s@SubModule' {} Maybe Text
a -> SubModule
s {$sel:commitId:SubModule' :: Maybe Text
commitId = Maybe Text
a} :: SubModule)

-- | The fully qualified path to the folder that contains the reference to
-- the submodule.
subModule_absolutePath :: Lens.Lens' SubModule (Prelude.Maybe Prelude.Text)
subModule_absolutePath :: (Maybe Text -> f (Maybe Text)) -> SubModule -> f SubModule
subModule_absolutePath = (SubModule -> Maybe Text)
-> (SubModule -> Maybe Text -> SubModule)
-> Lens SubModule SubModule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubModule' {Maybe Text
absolutePath :: Maybe Text
$sel:absolutePath:SubModule' :: SubModule -> Maybe Text
absolutePath} -> Maybe Text
absolutePath) (\s :: SubModule
s@SubModule' {} Maybe Text
a -> SubModule
s {$sel:absolutePath:SubModule' :: Maybe Text
absolutePath = Maybe Text
a} :: SubModule)

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

instance Core.FromJSON SubModule where
  parseJSON :: Value -> Parser SubModule
parseJSON =
    String -> (Object -> Parser SubModule) -> Value -> Parser SubModule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SubModule"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> SubModule
SubModule'
            (Maybe Text -> Maybe Text -> Maybe Text -> SubModule)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> SubModule)
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
"commitId")
            Parser (Maybe Text -> Maybe Text -> SubModule)
-> Parser (Maybe Text) -> Parser (Maybe Text -> SubModule)
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
"absolutePath")
            Parser (Maybe Text -> SubModule)
-> Parser (Maybe Text) -> Parser SubModule
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 SubModule

instance Prelude.NFData SubModule