{-# 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.CodeBuild.Types.ExportedEnvironmentVariable
-- 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.CodeBuild.Types.ExportedEnvironmentVariable where

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

-- | Contains information about an exported environment variable.
--
-- Exported environment variables are used in conjunction with CodePipeline
-- to export environment variables from the current build stage to
-- subsequent stages in the pipeline. For more information, see
-- <https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-variables.html Working with variables>
-- in the /CodePipeline User Guide/.
--
-- During a build, the value of a variable is available starting with the
-- @install@ phase. It can be updated between the start of the @install@
-- phase and the end of the @post_build@ phase. After the @post_build@
-- phase ends, the value of exported variables cannot change.
--
-- /See:/ 'newExportedEnvironmentVariable' smart constructor.
data ExportedEnvironmentVariable = ExportedEnvironmentVariable'
  { -- | The value assigned to the exported environment variable.
    ExportedEnvironmentVariable -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The name of the exported environment variable.
    ExportedEnvironmentVariable -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (ExportedEnvironmentVariable -> ExportedEnvironmentVariable -> Bool
(ExportedEnvironmentVariable
 -> ExportedEnvironmentVariable -> Bool)
-> (ExportedEnvironmentVariable
    -> ExportedEnvironmentVariable -> Bool)
-> Eq ExportedEnvironmentVariable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportedEnvironmentVariable -> ExportedEnvironmentVariable -> Bool
$c/= :: ExportedEnvironmentVariable -> ExportedEnvironmentVariable -> Bool
== :: ExportedEnvironmentVariable -> ExportedEnvironmentVariable -> Bool
$c== :: ExportedEnvironmentVariable -> ExportedEnvironmentVariable -> Bool
Prelude.Eq, ReadPrec [ExportedEnvironmentVariable]
ReadPrec ExportedEnvironmentVariable
Int -> ReadS ExportedEnvironmentVariable
ReadS [ExportedEnvironmentVariable]
(Int -> ReadS ExportedEnvironmentVariable)
-> ReadS [ExportedEnvironmentVariable]
-> ReadPrec ExportedEnvironmentVariable
-> ReadPrec [ExportedEnvironmentVariable]
-> Read ExportedEnvironmentVariable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportedEnvironmentVariable]
$creadListPrec :: ReadPrec [ExportedEnvironmentVariable]
readPrec :: ReadPrec ExportedEnvironmentVariable
$creadPrec :: ReadPrec ExportedEnvironmentVariable
readList :: ReadS [ExportedEnvironmentVariable]
$creadList :: ReadS [ExportedEnvironmentVariable]
readsPrec :: Int -> ReadS ExportedEnvironmentVariable
$creadsPrec :: Int -> ReadS ExportedEnvironmentVariable
Prelude.Read, Int -> ExportedEnvironmentVariable -> ShowS
[ExportedEnvironmentVariable] -> ShowS
ExportedEnvironmentVariable -> String
(Int -> ExportedEnvironmentVariable -> ShowS)
-> (ExportedEnvironmentVariable -> String)
-> ([ExportedEnvironmentVariable] -> ShowS)
-> Show ExportedEnvironmentVariable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportedEnvironmentVariable] -> ShowS
$cshowList :: [ExportedEnvironmentVariable] -> ShowS
show :: ExportedEnvironmentVariable -> String
$cshow :: ExportedEnvironmentVariable -> String
showsPrec :: Int -> ExportedEnvironmentVariable -> ShowS
$cshowsPrec :: Int -> ExportedEnvironmentVariable -> ShowS
Prelude.Show, (forall x.
 ExportedEnvironmentVariable -> Rep ExportedEnvironmentVariable x)
-> (forall x.
    Rep ExportedEnvironmentVariable x -> ExportedEnvironmentVariable)
-> Generic ExportedEnvironmentVariable
forall x.
Rep ExportedEnvironmentVariable x -> ExportedEnvironmentVariable
forall x.
ExportedEnvironmentVariable -> Rep ExportedEnvironmentVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExportedEnvironmentVariable x -> ExportedEnvironmentVariable
$cfrom :: forall x.
ExportedEnvironmentVariable -> Rep ExportedEnvironmentVariable x
Prelude.Generic)

-- |
-- Create a value of 'ExportedEnvironmentVariable' 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:
--
-- 'value', 'exportedEnvironmentVariable_value' - The value assigned to the exported environment variable.
--
-- 'name', 'exportedEnvironmentVariable_name' - The name of the exported environment variable.
newExportedEnvironmentVariable ::
  ExportedEnvironmentVariable
newExportedEnvironmentVariable :: ExportedEnvironmentVariable
newExportedEnvironmentVariable =
  ExportedEnvironmentVariable' :: Maybe Text -> Maybe Text -> ExportedEnvironmentVariable
ExportedEnvironmentVariable'
    { $sel:value:ExportedEnvironmentVariable' :: Maybe Text
value =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ExportedEnvironmentVariable' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value assigned to the exported environment variable.
exportedEnvironmentVariable_value :: Lens.Lens' ExportedEnvironmentVariable (Prelude.Maybe Prelude.Text)
exportedEnvironmentVariable_value :: (Maybe Text -> f (Maybe Text))
-> ExportedEnvironmentVariable -> f ExportedEnvironmentVariable
exportedEnvironmentVariable_value = (ExportedEnvironmentVariable -> Maybe Text)
-> (ExportedEnvironmentVariable
    -> Maybe Text -> ExportedEnvironmentVariable)
-> Lens
     ExportedEnvironmentVariable
     ExportedEnvironmentVariable
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportedEnvironmentVariable' {Maybe Text
value :: Maybe Text
$sel:value:ExportedEnvironmentVariable' :: ExportedEnvironmentVariable -> Maybe Text
value} -> Maybe Text
value) (\s :: ExportedEnvironmentVariable
s@ExportedEnvironmentVariable' {} Maybe Text
a -> ExportedEnvironmentVariable
s {$sel:value:ExportedEnvironmentVariable' :: Maybe Text
value = Maybe Text
a} :: ExportedEnvironmentVariable)

-- | The name of the exported environment variable.
exportedEnvironmentVariable_name :: Lens.Lens' ExportedEnvironmentVariable (Prelude.Maybe Prelude.Text)
exportedEnvironmentVariable_name :: (Maybe Text -> f (Maybe Text))
-> ExportedEnvironmentVariable -> f ExportedEnvironmentVariable
exportedEnvironmentVariable_name = (ExportedEnvironmentVariable -> Maybe Text)
-> (ExportedEnvironmentVariable
    -> Maybe Text -> ExportedEnvironmentVariable)
-> Lens
     ExportedEnvironmentVariable
     ExportedEnvironmentVariable
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportedEnvironmentVariable' {Maybe Text
name :: Maybe Text
$sel:name:ExportedEnvironmentVariable' :: ExportedEnvironmentVariable -> Maybe Text
name} -> Maybe Text
name) (\s :: ExportedEnvironmentVariable
s@ExportedEnvironmentVariable' {} Maybe Text
a -> ExportedEnvironmentVariable
s {$sel:name:ExportedEnvironmentVariable' :: Maybe Text
name = Maybe Text
a} :: ExportedEnvironmentVariable)

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

instance Prelude.Hashable ExportedEnvironmentVariable

instance Prelude.NFData ExportedEnvironmentVariable