{-# 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.OpsWorks.Types.EnvironmentVariable
-- 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.OpsWorks.Types.EnvironmentVariable where

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

-- | Represents an app\'s environment variable.
--
-- /See:/ 'newEnvironmentVariable' smart constructor.
data EnvironmentVariable = EnvironmentVariable'
  { -- | (Optional) Whether the variable\'s value will be returned by the
    -- DescribeApps action. To conceal an environment variable\'s value, set
    -- @Secure@ to @true@. @DescribeApps@ then returns @*****FILTERED*****@
    -- instead of the actual value. The default value for @Secure@ is @false@.
    EnvironmentVariable -> Maybe Bool
secure :: Prelude.Maybe Prelude.Bool,
    -- | (Required) The environment variable\'s name, which can consist of up to
    -- 64 characters and must be specified. The name can contain upper- and
    -- lowercase letters, numbers, and underscores (_), but it must start with
    -- a letter or underscore.
    EnvironmentVariable -> Text
key :: Prelude.Text,
    -- | (Optional) The environment variable\'s value, which can be left empty.
    -- If you specify a value, it can contain up to 256 characters, which must
    -- all be printable.
    EnvironmentVariable -> Text
value :: Prelude.Text
  }
  deriving (EnvironmentVariable -> EnvironmentVariable -> Bool
(EnvironmentVariable -> EnvironmentVariable -> Bool)
-> (EnvironmentVariable -> EnvironmentVariable -> Bool)
-> Eq EnvironmentVariable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentVariable -> EnvironmentVariable -> Bool
$c/= :: EnvironmentVariable -> EnvironmentVariable -> Bool
== :: EnvironmentVariable -> EnvironmentVariable -> Bool
$c== :: EnvironmentVariable -> EnvironmentVariable -> Bool
Prelude.Eq, ReadPrec [EnvironmentVariable]
ReadPrec EnvironmentVariable
Int -> ReadS EnvironmentVariable
ReadS [EnvironmentVariable]
(Int -> ReadS EnvironmentVariable)
-> ReadS [EnvironmentVariable]
-> ReadPrec EnvironmentVariable
-> ReadPrec [EnvironmentVariable]
-> Read EnvironmentVariable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnvironmentVariable]
$creadListPrec :: ReadPrec [EnvironmentVariable]
readPrec :: ReadPrec EnvironmentVariable
$creadPrec :: ReadPrec EnvironmentVariable
readList :: ReadS [EnvironmentVariable]
$creadList :: ReadS [EnvironmentVariable]
readsPrec :: Int -> ReadS EnvironmentVariable
$creadsPrec :: Int -> ReadS EnvironmentVariable
Prelude.Read, Int -> EnvironmentVariable -> ShowS
[EnvironmentVariable] -> ShowS
EnvironmentVariable -> String
(Int -> EnvironmentVariable -> ShowS)
-> (EnvironmentVariable -> String)
-> ([EnvironmentVariable] -> ShowS)
-> Show EnvironmentVariable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentVariable] -> ShowS
$cshowList :: [EnvironmentVariable] -> ShowS
show :: EnvironmentVariable -> String
$cshow :: EnvironmentVariable -> String
showsPrec :: Int -> EnvironmentVariable -> ShowS
$cshowsPrec :: Int -> EnvironmentVariable -> ShowS
Prelude.Show, (forall x. EnvironmentVariable -> Rep EnvironmentVariable x)
-> (forall x. Rep EnvironmentVariable x -> EnvironmentVariable)
-> Generic EnvironmentVariable
forall x. Rep EnvironmentVariable x -> EnvironmentVariable
forall x. EnvironmentVariable -> Rep EnvironmentVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentVariable x -> EnvironmentVariable
$cfrom :: forall x. EnvironmentVariable -> Rep EnvironmentVariable x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentVariable' 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:
--
-- 'secure', 'environmentVariable_secure' - (Optional) Whether the variable\'s value will be returned by the
-- DescribeApps action. To conceal an environment variable\'s value, set
-- @Secure@ to @true@. @DescribeApps@ then returns @*****FILTERED*****@
-- instead of the actual value. The default value for @Secure@ is @false@.
--
-- 'key', 'environmentVariable_key' - (Required) The environment variable\'s name, which can consist of up to
-- 64 characters and must be specified. The name can contain upper- and
-- lowercase letters, numbers, and underscores (_), but it must start with
-- a letter or underscore.
--
-- 'value', 'environmentVariable_value' - (Optional) The environment variable\'s value, which can be left empty.
-- If you specify a value, it can contain up to 256 characters, which must
-- all be printable.
newEnvironmentVariable ::
  -- | 'key'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  EnvironmentVariable
newEnvironmentVariable :: Text -> Text -> EnvironmentVariable
newEnvironmentVariable Text
pKey_ Text
pValue_ =
  EnvironmentVariable' :: Maybe Bool -> Text -> Text -> EnvironmentVariable
EnvironmentVariable'
    { $sel:secure:EnvironmentVariable' :: Maybe Bool
secure = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:key:EnvironmentVariable' :: Text
key = Text
pKey_,
      $sel:value:EnvironmentVariable' :: Text
value = Text
pValue_
    }

-- | (Optional) Whether the variable\'s value will be returned by the
-- DescribeApps action. To conceal an environment variable\'s value, set
-- @Secure@ to @true@. @DescribeApps@ then returns @*****FILTERED*****@
-- instead of the actual value. The default value for @Secure@ is @false@.
environmentVariable_secure :: Lens.Lens' EnvironmentVariable (Prelude.Maybe Prelude.Bool)
environmentVariable_secure :: (Maybe Bool -> f (Maybe Bool))
-> EnvironmentVariable -> f EnvironmentVariable
environmentVariable_secure = (EnvironmentVariable -> Maybe Bool)
-> (EnvironmentVariable -> Maybe Bool -> EnvironmentVariable)
-> Lens
     EnvironmentVariable EnvironmentVariable (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentVariable' {Maybe Bool
secure :: Maybe Bool
$sel:secure:EnvironmentVariable' :: EnvironmentVariable -> Maybe Bool
secure} -> Maybe Bool
secure) (\s :: EnvironmentVariable
s@EnvironmentVariable' {} Maybe Bool
a -> EnvironmentVariable
s {$sel:secure:EnvironmentVariable' :: Maybe Bool
secure = Maybe Bool
a} :: EnvironmentVariable)

-- | (Required) The environment variable\'s name, which can consist of up to
-- 64 characters and must be specified. The name can contain upper- and
-- lowercase letters, numbers, and underscores (_), but it must start with
-- a letter or underscore.
environmentVariable_key :: Lens.Lens' EnvironmentVariable Prelude.Text
environmentVariable_key :: (Text -> f Text) -> EnvironmentVariable -> f EnvironmentVariable
environmentVariable_key = (EnvironmentVariable -> Text)
-> (EnvironmentVariable -> Text -> EnvironmentVariable)
-> Lens EnvironmentVariable EnvironmentVariable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentVariable' {Text
key :: Text
$sel:key:EnvironmentVariable' :: EnvironmentVariable -> Text
key} -> Text
key) (\s :: EnvironmentVariable
s@EnvironmentVariable' {} Text
a -> EnvironmentVariable
s {$sel:key:EnvironmentVariable' :: Text
key = Text
a} :: EnvironmentVariable)

-- | (Optional) The environment variable\'s value, which can be left empty.
-- If you specify a value, it can contain up to 256 characters, which must
-- all be printable.
environmentVariable_value :: Lens.Lens' EnvironmentVariable Prelude.Text
environmentVariable_value :: (Text -> f Text) -> EnvironmentVariable -> f EnvironmentVariable
environmentVariable_value = (EnvironmentVariable -> Text)
-> (EnvironmentVariable -> Text -> EnvironmentVariable)
-> Lens EnvironmentVariable EnvironmentVariable Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentVariable' {Text
value :: Text
$sel:value:EnvironmentVariable' :: EnvironmentVariable -> Text
value} -> Text
value) (\s :: EnvironmentVariable
s@EnvironmentVariable' {} Text
a -> EnvironmentVariable
s {$sel:value:EnvironmentVariable' :: Text
value = Text
a} :: EnvironmentVariable)

instance Core.FromJSON EnvironmentVariable where
  parseJSON :: Value -> Parser EnvironmentVariable
parseJSON =
    String
-> (Object -> Parser EnvironmentVariable)
-> Value
-> Parser EnvironmentVariable
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EnvironmentVariable"
      ( \Object
x ->
          Maybe Bool -> Text -> Text -> EnvironmentVariable
EnvironmentVariable'
            (Maybe Bool -> Text -> Text -> EnvironmentVariable)
-> Parser (Maybe Bool)
-> Parser (Text -> Text -> EnvironmentVariable)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Secure")
            Parser (Text -> Text -> EnvironmentVariable)
-> Parser Text -> Parser (Text -> EnvironmentVariable)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Key")
            Parser (Text -> EnvironmentVariable)
-> Parser Text -> Parser EnvironmentVariable
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Value")
      )

instance Prelude.Hashable EnvironmentVariable

instance Prelude.NFData EnvironmentVariable

instance Core.ToJSON EnvironmentVariable where
  toJSON :: EnvironmentVariable -> Value
toJSON EnvironmentVariable' {Maybe Bool
Text
value :: Text
key :: Text
secure :: Maybe Bool
$sel:value:EnvironmentVariable' :: EnvironmentVariable -> Text
$sel:key:EnvironmentVariable' :: EnvironmentVariable -> Text
$sel:secure:EnvironmentVariable' :: EnvironmentVariable -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Secure" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
secure,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )