{-# 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.Pipes.Types.EcsEnvironmentVariable
-- 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.Pipes.Types.EcsEnvironmentVariable where

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

-- | The environment variables to send to the container. You can add new
-- environment variables, which are added to the container at launch, or
-- you can override the existing environment variables from the Docker
-- image or the task definition. You must also specify a container name.
--
-- /See:/ 'newEcsEnvironmentVariable' smart constructor.
data EcsEnvironmentVariable = EcsEnvironmentVariable'
  { -- | The name of the key-value pair. For environment variables, this is the
    -- name of the environment variable.
    EcsEnvironmentVariable -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The value of the key-value pair. For environment variables, this is the
    -- value of the environment variable.
    EcsEnvironmentVariable -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (EcsEnvironmentVariable -> EcsEnvironmentVariable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EcsEnvironmentVariable -> EcsEnvironmentVariable -> Bool
$c/= :: EcsEnvironmentVariable -> EcsEnvironmentVariable -> Bool
== :: EcsEnvironmentVariable -> EcsEnvironmentVariable -> Bool
$c== :: EcsEnvironmentVariable -> EcsEnvironmentVariable -> Bool
Prelude.Eq, ReadPrec [EcsEnvironmentVariable]
ReadPrec EcsEnvironmentVariable
Int -> ReadS EcsEnvironmentVariable
ReadS [EcsEnvironmentVariable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EcsEnvironmentVariable]
$creadListPrec :: ReadPrec [EcsEnvironmentVariable]
readPrec :: ReadPrec EcsEnvironmentVariable
$creadPrec :: ReadPrec EcsEnvironmentVariable
readList :: ReadS [EcsEnvironmentVariable]
$creadList :: ReadS [EcsEnvironmentVariable]
readsPrec :: Int -> ReadS EcsEnvironmentVariable
$creadsPrec :: Int -> ReadS EcsEnvironmentVariable
Prelude.Read, Int -> EcsEnvironmentVariable -> ShowS
[EcsEnvironmentVariable] -> ShowS
EcsEnvironmentVariable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EcsEnvironmentVariable] -> ShowS
$cshowList :: [EcsEnvironmentVariable] -> ShowS
show :: EcsEnvironmentVariable -> String
$cshow :: EcsEnvironmentVariable -> String
showsPrec :: Int -> EcsEnvironmentVariable -> ShowS
$cshowsPrec :: Int -> EcsEnvironmentVariable -> ShowS
Prelude.Show, forall x. Rep EcsEnvironmentVariable x -> EcsEnvironmentVariable
forall x. EcsEnvironmentVariable -> Rep EcsEnvironmentVariable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EcsEnvironmentVariable x -> EcsEnvironmentVariable
$cfrom :: forall x. EcsEnvironmentVariable -> Rep EcsEnvironmentVariable x
Prelude.Generic)

-- |
-- Create a value of 'EcsEnvironmentVariable' 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:
--
-- 'name', 'ecsEnvironmentVariable_name' - The name of the key-value pair. For environment variables, this is the
-- name of the environment variable.
--
-- 'value', 'ecsEnvironmentVariable_value' - The value of the key-value pair. For environment variables, this is the
-- value of the environment variable.
newEcsEnvironmentVariable ::
  EcsEnvironmentVariable
newEcsEnvironmentVariable :: EcsEnvironmentVariable
newEcsEnvironmentVariable =
  EcsEnvironmentVariable'
    { $sel:name:EcsEnvironmentVariable' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:EcsEnvironmentVariable' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the key-value pair. For environment variables, this is the
-- name of the environment variable.
ecsEnvironmentVariable_name :: Lens.Lens' EcsEnvironmentVariable (Prelude.Maybe Prelude.Text)
ecsEnvironmentVariable_name :: Lens' EcsEnvironmentVariable (Maybe Text)
ecsEnvironmentVariable_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EcsEnvironmentVariable' {Maybe Text
name :: Maybe Text
$sel:name:EcsEnvironmentVariable' :: EcsEnvironmentVariable -> Maybe Text
name} -> Maybe Text
name) (\s :: EcsEnvironmentVariable
s@EcsEnvironmentVariable' {} Maybe Text
a -> EcsEnvironmentVariable
s {$sel:name:EcsEnvironmentVariable' :: Maybe Text
name = Maybe Text
a} :: EcsEnvironmentVariable)

-- | The value of the key-value pair. For environment variables, this is the
-- value of the environment variable.
ecsEnvironmentVariable_value :: Lens.Lens' EcsEnvironmentVariable (Prelude.Maybe Prelude.Text)
ecsEnvironmentVariable_value :: Lens' EcsEnvironmentVariable (Maybe Text)
ecsEnvironmentVariable_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EcsEnvironmentVariable' {Maybe Text
value :: Maybe Text
$sel:value:EcsEnvironmentVariable' :: EcsEnvironmentVariable -> Maybe Text
value} -> Maybe Text
value) (\s :: EcsEnvironmentVariable
s@EcsEnvironmentVariable' {} Maybe Text
a -> EcsEnvironmentVariable
s {$sel:value:EcsEnvironmentVariable' :: Maybe Text
value = Maybe Text
a} :: EcsEnvironmentVariable)

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

instance Prelude.Hashable EcsEnvironmentVariable where
  hashWithSalt :: Int -> EcsEnvironmentVariable -> Int
hashWithSalt Int
_salt EcsEnvironmentVariable' {Maybe Text
value :: Maybe Text
name :: Maybe Text
$sel:value:EcsEnvironmentVariable' :: EcsEnvironmentVariable -> Maybe Text
$sel:name:EcsEnvironmentVariable' :: EcsEnvironmentVariable -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

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

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