{-# 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.EcsEnvironmentFile
-- 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.EcsEnvironmentFile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pipes.Types.EcsEnvironmentFileType
import qualified Amazonka.Prelude as Prelude

-- | A list of files containing the environment variables to pass to a
-- container. You can specify up to ten environment files. The file must
-- have a @.env@ file extension. Each line in an environment file should
-- contain an environment variable in @VARIABLE=VALUE@ format. Lines
-- beginning with @#@ are treated as comments and are ignored. For more
-- information about the environment variable file syntax, see
-- <https://docs.docker.com/compose/env-file/ Declare default environment variables in file>.
--
-- If there are environment variables specified using the @environment@
-- parameter in a container definition, they take precedence over the
-- variables contained within an environment file. If multiple environment
-- files are specified that contain the same variable, they\'re processed
-- from the top down. We recommend that you use unique variable names. For
-- more information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html Specifying environment variables>
-- in the /Amazon Elastic Container Service Developer Guide/.
--
-- This parameter is only supported for tasks hosted on Fargate using the
-- following platform versions:
--
-- -   Linux platform version @1.4.0@ or later.
--
-- -   Windows platform version @1.0.0@ or later.
--
-- /See:/ 'newEcsEnvironmentFile' smart constructor.
data EcsEnvironmentFile = EcsEnvironmentFile'
  { -- | The file type to use. The only supported value is @s3@.
    EcsEnvironmentFile -> EcsEnvironmentFileType
type' :: EcsEnvironmentFileType,
    -- | The Amazon Resource Name (ARN) of the Amazon S3 object containing the
    -- environment variable file.
    EcsEnvironmentFile -> Text
value :: Prelude.Text
  }
  deriving (EcsEnvironmentFile -> EcsEnvironmentFile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EcsEnvironmentFile -> EcsEnvironmentFile -> Bool
$c/= :: EcsEnvironmentFile -> EcsEnvironmentFile -> Bool
== :: EcsEnvironmentFile -> EcsEnvironmentFile -> Bool
$c== :: EcsEnvironmentFile -> EcsEnvironmentFile -> Bool
Prelude.Eq, ReadPrec [EcsEnvironmentFile]
ReadPrec EcsEnvironmentFile
Int -> ReadS EcsEnvironmentFile
ReadS [EcsEnvironmentFile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EcsEnvironmentFile]
$creadListPrec :: ReadPrec [EcsEnvironmentFile]
readPrec :: ReadPrec EcsEnvironmentFile
$creadPrec :: ReadPrec EcsEnvironmentFile
readList :: ReadS [EcsEnvironmentFile]
$creadList :: ReadS [EcsEnvironmentFile]
readsPrec :: Int -> ReadS EcsEnvironmentFile
$creadsPrec :: Int -> ReadS EcsEnvironmentFile
Prelude.Read, Int -> EcsEnvironmentFile -> ShowS
[EcsEnvironmentFile] -> ShowS
EcsEnvironmentFile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EcsEnvironmentFile] -> ShowS
$cshowList :: [EcsEnvironmentFile] -> ShowS
show :: EcsEnvironmentFile -> String
$cshow :: EcsEnvironmentFile -> String
showsPrec :: Int -> EcsEnvironmentFile -> ShowS
$cshowsPrec :: Int -> EcsEnvironmentFile -> ShowS
Prelude.Show, forall x. Rep EcsEnvironmentFile x -> EcsEnvironmentFile
forall x. EcsEnvironmentFile -> Rep EcsEnvironmentFile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EcsEnvironmentFile x -> EcsEnvironmentFile
$cfrom :: forall x. EcsEnvironmentFile -> Rep EcsEnvironmentFile x
Prelude.Generic)

-- |
-- Create a value of 'EcsEnvironmentFile' 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'', 'ecsEnvironmentFile_type' - The file type to use. The only supported value is @s3@.
--
-- 'value', 'ecsEnvironmentFile_value' - The Amazon Resource Name (ARN) of the Amazon S3 object containing the
-- environment variable file.
newEcsEnvironmentFile ::
  -- | 'type''
  EcsEnvironmentFileType ->
  -- | 'value'
  Prelude.Text ->
  EcsEnvironmentFile
newEcsEnvironmentFile :: EcsEnvironmentFileType -> Text -> EcsEnvironmentFile
newEcsEnvironmentFile EcsEnvironmentFileType
pType_ Text
pValue_ =
  EcsEnvironmentFile'
    { $sel:type':EcsEnvironmentFile' :: EcsEnvironmentFileType
type' = EcsEnvironmentFileType
pType_,
      $sel:value:EcsEnvironmentFile' :: Text
value = Text
pValue_
    }

-- | The file type to use. The only supported value is @s3@.
ecsEnvironmentFile_type :: Lens.Lens' EcsEnvironmentFile EcsEnvironmentFileType
ecsEnvironmentFile_type :: Lens' EcsEnvironmentFile EcsEnvironmentFileType
ecsEnvironmentFile_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EcsEnvironmentFile' {EcsEnvironmentFileType
type' :: EcsEnvironmentFileType
$sel:type':EcsEnvironmentFile' :: EcsEnvironmentFile -> EcsEnvironmentFileType
type'} -> EcsEnvironmentFileType
type') (\s :: EcsEnvironmentFile
s@EcsEnvironmentFile' {} EcsEnvironmentFileType
a -> EcsEnvironmentFile
s {$sel:type':EcsEnvironmentFile' :: EcsEnvironmentFileType
type' = EcsEnvironmentFileType
a} :: EcsEnvironmentFile)

-- | The Amazon Resource Name (ARN) of the Amazon S3 object containing the
-- environment variable file.
ecsEnvironmentFile_value :: Lens.Lens' EcsEnvironmentFile Prelude.Text
ecsEnvironmentFile_value :: Lens' EcsEnvironmentFile Text
ecsEnvironmentFile_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EcsEnvironmentFile' {Text
value :: Text
$sel:value:EcsEnvironmentFile' :: EcsEnvironmentFile -> Text
value} -> Text
value) (\s :: EcsEnvironmentFile
s@EcsEnvironmentFile' {} Text
a -> EcsEnvironmentFile
s {$sel:value:EcsEnvironmentFile' :: Text
value = Text
a} :: EcsEnvironmentFile)

instance Data.FromJSON EcsEnvironmentFile where
  parseJSON :: Value -> Parser EcsEnvironmentFile
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EcsEnvironmentFile"
      ( \Object
x ->
          EcsEnvironmentFileType -> Text -> EcsEnvironmentFile
EcsEnvironmentFile'
            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 EcsEnvironmentFile where
  hashWithSalt :: Int -> EcsEnvironmentFile -> Int
hashWithSalt Int
_salt EcsEnvironmentFile' {Text
EcsEnvironmentFileType
value :: Text
type' :: EcsEnvironmentFileType
$sel:value:EcsEnvironmentFile' :: EcsEnvironmentFile -> Text
$sel:type':EcsEnvironmentFile' :: EcsEnvironmentFile -> EcsEnvironmentFileType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EcsEnvironmentFileType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
value

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

instance Data.ToJSON EcsEnvironmentFile where
  toJSON :: EcsEnvironmentFile -> Value
toJSON EcsEnvironmentFile' {Text
EcsEnvironmentFileType
value :: Text
type' :: EcsEnvironmentFileType
$sel:value:EcsEnvironmentFile' :: EcsEnvironmentFile -> Text
$sel:type':EcsEnvironmentFile' :: EcsEnvironmentFile -> EcsEnvironmentFileType
..} =
    [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..= EcsEnvironmentFileType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
value)
          ]
      )