{-# 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.ECS.Types.EnvironmentFile
-- 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.ECS.Types.EnvironmentFile where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.EnvironmentFileType
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:/ 'newEnvironmentFile' smart constructor.
data EnvironmentFile = EnvironmentFile'
  { -- | The Amazon Resource Name (ARN) of the Amazon S3 object containing the
    -- environment variable file.
    EnvironmentFile -> Text
value :: Prelude.Text,
    -- | The file type to use. The only supported value is @s3@.
    EnvironmentFile -> EnvironmentFileType
type' :: EnvironmentFileType
  }
  deriving (EnvironmentFile -> EnvironmentFile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentFile -> EnvironmentFile -> Bool
$c/= :: EnvironmentFile -> EnvironmentFile -> Bool
== :: EnvironmentFile -> EnvironmentFile -> Bool
$c== :: EnvironmentFile -> EnvironmentFile -> Bool
Prelude.Eq, ReadPrec [EnvironmentFile]
ReadPrec EnvironmentFile
Int -> ReadS EnvironmentFile
ReadS [EnvironmentFile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnvironmentFile]
$creadListPrec :: ReadPrec [EnvironmentFile]
readPrec :: ReadPrec EnvironmentFile
$creadPrec :: ReadPrec EnvironmentFile
readList :: ReadS [EnvironmentFile]
$creadList :: ReadS [EnvironmentFile]
readsPrec :: Int -> ReadS EnvironmentFile
$creadsPrec :: Int -> ReadS EnvironmentFile
Prelude.Read, Int -> EnvironmentFile -> ShowS
[EnvironmentFile] -> ShowS
EnvironmentFile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentFile] -> ShowS
$cshowList :: [EnvironmentFile] -> ShowS
show :: EnvironmentFile -> String
$cshow :: EnvironmentFile -> String
showsPrec :: Int -> EnvironmentFile -> ShowS
$cshowsPrec :: Int -> EnvironmentFile -> ShowS
Prelude.Show, forall x. Rep EnvironmentFile x -> EnvironmentFile
forall x. EnvironmentFile -> Rep EnvironmentFile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnvironmentFile x -> EnvironmentFile
$cfrom :: forall x. EnvironmentFile -> Rep EnvironmentFile x
Prelude.Generic)

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

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

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

instance Data.FromJSON EnvironmentFile where
  parseJSON :: Value -> Parser EnvironmentFile
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EnvironmentFile"
      ( \Object
x ->
          Text -> EnvironmentFileType -> EnvironmentFile
EnvironmentFile'
            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
"value")
            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
"type")
      )

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

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

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