{-# 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.MigrationHubStrategy.Types.SourceCode
-- 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.MigrationHubStrategy.Types.SourceCode where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MigrationHubStrategy.Types.VersionControl
import qualified Amazonka.Prelude as Prelude

-- | Object containing source code information that is linked to an
-- application component.
--
-- /See:/ 'newSourceCode' smart constructor.
data SourceCode = SourceCode'
  { -- | The repository name for the source code.
    SourceCode -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
    -- | The name of the project.
    SourceCode -> Maybe Text
projectName :: Prelude.Maybe Prelude.Text,
    -- | The branch of the source code.
    SourceCode -> Maybe Text
sourceVersion :: Prelude.Maybe Prelude.Text,
    -- | The type of repository to use for the source code.
    SourceCode -> Maybe VersionControl
versionControl :: Prelude.Maybe VersionControl
  }
  deriving (SourceCode -> SourceCode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceCode -> SourceCode -> Bool
$c/= :: SourceCode -> SourceCode -> Bool
== :: SourceCode -> SourceCode -> Bool
$c== :: SourceCode -> SourceCode -> Bool
Prelude.Eq, ReadPrec [SourceCode]
ReadPrec SourceCode
Int -> ReadS SourceCode
ReadS [SourceCode]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceCode]
$creadListPrec :: ReadPrec [SourceCode]
readPrec :: ReadPrec SourceCode
$creadPrec :: ReadPrec SourceCode
readList :: ReadS [SourceCode]
$creadList :: ReadS [SourceCode]
readsPrec :: Int -> ReadS SourceCode
$creadsPrec :: Int -> ReadS SourceCode
Prelude.Read, Int -> SourceCode -> ShowS
[SourceCode] -> ShowS
SourceCode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceCode] -> ShowS
$cshowList :: [SourceCode] -> ShowS
show :: SourceCode -> String
$cshow :: SourceCode -> String
showsPrec :: Int -> SourceCode -> ShowS
$cshowsPrec :: Int -> SourceCode -> ShowS
Prelude.Show, forall x. Rep SourceCode x -> SourceCode
forall x. SourceCode -> Rep SourceCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceCode x -> SourceCode
$cfrom :: forall x. SourceCode -> Rep SourceCode x
Prelude.Generic)

-- |
-- Create a value of 'SourceCode' 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:
--
-- 'location', 'sourceCode_location' - The repository name for the source code.
--
-- 'projectName', 'sourceCode_projectName' - The name of the project.
--
-- 'sourceVersion', 'sourceCode_sourceVersion' - The branch of the source code.
--
-- 'versionControl', 'sourceCode_versionControl' - The type of repository to use for the source code.
newSourceCode ::
  SourceCode
newSourceCode :: SourceCode
newSourceCode =
  SourceCode'
    { $sel:location:SourceCode' :: Maybe Text
location = forall a. Maybe a
Prelude.Nothing,
      $sel:projectName:SourceCode' :: Maybe Text
projectName = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceVersion:SourceCode' :: Maybe Text
sourceVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:versionControl:SourceCode' :: Maybe VersionControl
versionControl = forall a. Maybe a
Prelude.Nothing
    }

-- | The repository name for the source code.
sourceCode_location :: Lens.Lens' SourceCode (Prelude.Maybe Prelude.Text)
sourceCode_location :: Lens' SourceCode (Maybe Text)
sourceCode_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCode' {Maybe Text
location :: Maybe Text
$sel:location:SourceCode' :: SourceCode -> Maybe Text
location} -> Maybe Text
location) (\s :: SourceCode
s@SourceCode' {} Maybe Text
a -> SourceCode
s {$sel:location:SourceCode' :: Maybe Text
location = Maybe Text
a} :: SourceCode)

-- | The name of the project.
sourceCode_projectName :: Lens.Lens' SourceCode (Prelude.Maybe Prelude.Text)
sourceCode_projectName :: Lens' SourceCode (Maybe Text)
sourceCode_projectName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCode' {Maybe Text
projectName :: Maybe Text
$sel:projectName:SourceCode' :: SourceCode -> Maybe Text
projectName} -> Maybe Text
projectName) (\s :: SourceCode
s@SourceCode' {} Maybe Text
a -> SourceCode
s {$sel:projectName:SourceCode' :: Maybe Text
projectName = Maybe Text
a} :: SourceCode)

-- | The branch of the source code.
sourceCode_sourceVersion :: Lens.Lens' SourceCode (Prelude.Maybe Prelude.Text)
sourceCode_sourceVersion :: Lens' SourceCode (Maybe Text)
sourceCode_sourceVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCode' {Maybe Text
sourceVersion :: Maybe Text
$sel:sourceVersion:SourceCode' :: SourceCode -> Maybe Text
sourceVersion} -> Maybe Text
sourceVersion) (\s :: SourceCode
s@SourceCode' {} Maybe Text
a -> SourceCode
s {$sel:sourceVersion:SourceCode' :: Maybe Text
sourceVersion = Maybe Text
a} :: SourceCode)

-- | The type of repository to use for the source code.
sourceCode_versionControl :: Lens.Lens' SourceCode (Prelude.Maybe VersionControl)
sourceCode_versionControl :: Lens' SourceCode (Maybe VersionControl)
sourceCode_versionControl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCode' {Maybe VersionControl
versionControl :: Maybe VersionControl
$sel:versionControl:SourceCode' :: SourceCode -> Maybe VersionControl
versionControl} -> Maybe VersionControl
versionControl) (\s :: SourceCode
s@SourceCode' {} Maybe VersionControl
a -> SourceCode
s {$sel:versionControl:SourceCode' :: Maybe VersionControl
versionControl = Maybe VersionControl
a} :: SourceCode)

instance Prelude.Hashable SourceCode where
  hashWithSalt :: Int -> SourceCode -> Int
hashWithSalt Int
_salt SourceCode' {Maybe Text
Maybe VersionControl
versionControl :: Maybe VersionControl
sourceVersion :: Maybe Text
projectName :: Maybe Text
location :: Maybe Text
$sel:versionControl:SourceCode' :: SourceCode -> Maybe VersionControl
$sel:sourceVersion:SourceCode' :: SourceCode -> Maybe Text
$sel:projectName:SourceCode' :: SourceCode -> Maybe Text
$sel:location:SourceCode' :: SourceCode -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
location
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
projectName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VersionControl
versionControl

instance Prelude.NFData SourceCode where
  rnf :: SourceCode -> ()
rnf SourceCode' {Maybe Text
Maybe VersionControl
versionControl :: Maybe VersionControl
sourceVersion :: Maybe Text
projectName :: Maybe Text
location :: Maybe Text
$sel:versionControl:SourceCode' :: SourceCode -> Maybe VersionControl
$sel:sourceVersion:SourceCode' :: SourceCode -> Maybe Text
$sel:projectName:SourceCode' :: SourceCode -> Maybe Text
$sel:location:SourceCode' :: SourceCode -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
location
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
projectName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VersionControl
versionControl

instance Data.ToJSON SourceCode where
  toJSON :: SourceCode -> Value
toJSON SourceCode' {Maybe Text
Maybe VersionControl
versionControl :: Maybe VersionControl
sourceVersion :: Maybe Text
projectName :: Maybe Text
location :: Maybe Text
$sel:versionControl:SourceCode' :: SourceCode -> Maybe VersionControl
$sel:sourceVersion:SourceCode' :: SourceCode -> Maybe Text
$sel:projectName:SourceCode' :: SourceCode -> Maybe Text
$sel:location:SourceCode' :: SourceCode -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"location" 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 Text
location,
            (Key
"projectName" 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 Text
projectName,
            (Key
"sourceVersion" 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 Text
sourceVersion,
            (Key
"versionControl" 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 VersionControl
versionControl
          ]
      )