{-# 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.AppRunner.Types.SourceCodeVersion
-- 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.AppRunner.Types.SourceCodeVersion where

import Amazonka.AppRunner.Types.SourceCodeVersionType
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

-- | Identifies a version of code that App Runner refers to within a source
-- code repository.
--
-- /See:/ 'newSourceCodeVersion' smart constructor.
data SourceCodeVersion = SourceCodeVersion'
  { -- | The type of version identifier.
    --
    -- For a git-based repository, branches represent versions.
    SourceCodeVersion -> SourceCodeVersionType
type' :: SourceCodeVersionType,
    -- | A source code version.
    --
    -- For a git-based repository, a branch name maps to a specific version.
    -- App Runner uses the most recent commit to the branch.
    SourceCodeVersion -> Text
value :: Prelude.Text
  }
  deriving (SourceCodeVersion -> SourceCodeVersion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceCodeVersion -> SourceCodeVersion -> Bool
$c/= :: SourceCodeVersion -> SourceCodeVersion -> Bool
== :: SourceCodeVersion -> SourceCodeVersion -> Bool
$c== :: SourceCodeVersion -> SourceCodeVersion -> Bool
Prelude.Eq, ReadPrec [SourceCodeVersion]
ReadPrec SourceCodeVersion
Int -> ReadS SourceCodeVersion
ReadS [SourceCodeVersion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceCodeVersion]
$creadListPrec :: ReadPrec [SourceCodeVersion]
readPrec :: ReadPrec SourceCodeVersion
$creadPrec :: ReadPrec SourceCodeVersion
readList :: ReadS [SourceCodeVersion]
$creadList :: ReadS [SourceCodeVersion]
readsPrec :: Int -> ReadS SourceCodeVersion
$creadsPrec :: Int -> ReadS SourceCodeVersion
Prelude.Read, Int -> SourceCodeVersion -> ShowS
[SourceCodeVersion] -> ShowS
SourceCodeVersion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceCodeVersion] -> ShowS
$cshowList :: [SourceCodeVersion] -> ShowS
show :: SourceCodeVersion -> String
$cshow :: SourceCodeVersion -> String
showsPrec :: Int -> SourceCodeVersion -> ShowS
$cshowsPrec :: Int -> SourceCodeVersion -> ShowS
Prelude.Show, forall x. Rep SourceCodeVersion x -> SourceCodeVersion
forall x. SourceCodeVersion -> Rep SourceCodeVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceCodeVersion x -> SourceCodeVersion
$cfrom :: forall x. SourceCodeVersion -> Rep SourceCodeVersion x
Prelude.Generic)

-- |
-- Create a value of 'SourceCodeVersion' 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:
--
-- 'type'', 'sourceCodeVersion_type' - The type of version identifier.
--
-- For a git-based repository, branches represent versions.
--
-- 'value', 'sourceCodeVersion_value' - A source code version.
--
-- For a git-based repository, a branch name maps to a specific version.
-- App Runner uses the most recent commit to the branch.
newSourceCodeVersion ::
  -- | 'type''
  SourceCodeVersionType ->
  -- | 'value'
  Prelude.Text ->
  SourceCodeVersion
newSourceCodeVersion :: SourceCodeVersionType -> Text -> SourceCodeVersion
newSourceCodeVersion SourceCodeVersionType
pType_ Text
pValue_ =
  SourceCodeVersion' {$sel:type':SourceCodeVersion' :: SourceCodeVersionType
type' = SourceCodeVersionType
pType_, $sel:value:SourceCodeVersion' :: Text
value = Text
pValue_}

-- | The type of version identifier.
--
-- For a git-based repository, branches represent versions.
sourceCodeVersion_type :: Lens.Lens' SourceCodeVersion SourceCodeVersionType
sourceCodeVersion_type :: Lens' SourceCodeVersion SourceCodeVersionType
sourceCodeVersion_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCodeVersion' {SourceCodeVersionType
type' :: SourceCodeVersionType
$sel:type':SourceCodeVersion' :: SourceCodeVersion -> SourceCodeVersionType
type'} -> SourceCodeVersionType
type') (\s :: SourceCodeVersion
s@SourceCodeVersion' {} SourceCodeVersionType
a -> SourceCodeVersion
s {$sel:type':SourceCodeVersion' :: SourceCodeVersionType
type' = SourceCodeVersionType
a} :: SourceCodeVersion)

-- | A source code version.
--
-- For a git-based repository, a branch name maps to a specific version.
-- App Runner uses the most recent commit to the branch.
sourceCodeVersion_value :: Lens.Lens' SourceCodeVersion Prelude.Text
sourceCodeVersion_value :: Lens' SourceCodeVersion Text
sourceCodeVersion_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCodeVersion' {Text
value :: Text
$sel:value:SourceCodeVersion' :: SourceCodeVersion -> Text
value} -> Text
value) (\s :: SourceCodeVersion
s@SourceCodeVersion' {} Text
a -> SourceCodeVersion
s {$sel:value:SourceCodeVersion' :: Text
value = Text
a} :: SourceCodeVersion)

instance Data.FromJSON SourceCodeVersion where
  parseJSON :: Value -> Parser SourceCodeVersion
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourceCodeVersion"
      ( \Object
x ->
          SourceCodeVersionType -> Text -> SourceCodeVersion
SourceCodeVersion'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
      )

instance Prelude.Hashable SourceCodeVersion where
  hashWithSalt :: Int -> SourceCodeVersion -> Int
hashWithSalt Int
_salt SourceCodeVersion' {Text
SourceCodeVersionType
value :: Text
type' :: SourceCodeVersionType
$sel:value:SourceCodeVersion' :: SourceCodeVersion -> Text
$sel:type':SourceCodeVersion' :: SourceCodeVersion -> SourceCodeVersionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SourceCodeVersionType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

instance Prelude.NFData SourceCodeVersion where
  rnf :: SourceCodeVersion -> ()
rnf SourceCodeVersion' {Text
SourceCodeVersionType
value :: Text
type' :: SourceCodeVersionType
$sel:value:SourceCodeVersion' :: SourceCodeVersion -> Text
$sel:type':SourceCodeVersion' :: SourceCodeVersion -> SourceCodeVersionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf SourceCodeVersionType
type' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
value

instance Data.ToJSON SourceCodeVersion where
  toJSON :: SourceCodeVersion -> Value
toJSON SourceCodeVersion' {Text
SourceCodeVersionType
value :: Text
type' :: SourceCodeVersionType
$sel:value:SourceCodeVersion' :: SourceCodeVersion -> Text
$sel:type':SourceCodeVersion' :: SourceCodeVersion -> SourceCodeVersionType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SourceCodeVersionType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )