{-# 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.Lambda.Types.ImageConfig
-- 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.Lambda.Types.ImageConfig 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

-- | Configuration values that override the container image Dockerfile
-- settings. For more information, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-parms Container image settings>.
--
-- /See:/ 'newImageConfig' smart constructor.
data ImageConfig = ImageConfig'
  { -- | Specifies parameters that you want to pass in with ENTRYPOINT.
    ImageConfig -> Maybe [Text]
command :: Prelude.Maybe [Prelude.Text],
    -- | Specifies the entry point to their application, which is typically the
    -- location of the runtime executable.
    ImageConfig -> Maybe [Text]
entryPoint :: Prelude.Maybe [Prelude.Text],
    -- | Specifies the working directory.
    ImageConfig -> Maybe Text
workingDirectory :: Prelude.Maybe Prelude.Text
  }
  deriving (ImageConfig -> ImageConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageConfig -> ImageConfig -> Bool
$c/= :: ImageConfig -> ImageConfig -> Bool
== :: ImageConfig -> ImageConfig -> Bool
$c== :: ImageConfig -> ImageConfig -> Bool
Prelude.Eq, ReadPrec [ImageConfig]
ReadPrec ImageConfig
Int -> ReadS ImageConfig
ReadS [ImageConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageConfig]
$creadListPrec :: ReadPrec [ImageConfig]
readPrec :: ReadPrec ImageConfig
$creadPrec :: ReadPrec ImageConfig
readList :: ReadS [ImageConfig]
$creadList :: ReadS [ImageConfig]
readsPrec :: Int -> ReadS ImageConfig
$creadsPrec :: Int -> ReadS ImageConfig
Prelude.Read, Int -> ImageConfig -> ShowS
[ImageConfig] -> ShowS
ImageConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageConfig] -> ShowS
$cshowList :: [ImageConfig] -> ShowS
show :: ImageConfig -> String
$cshow :: ImageConfig -> String
showsPrec :: Int -> ImageConfig -> ShowS
$cshowsPrec :: Int -> ImageConfig -> ShowS
Prelude.Show, forall x. Rep ImageConfig x -> ImageConfig
forall x. ImageConfig -> Rep ImageConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageConfig x -> ImageConfig
$cfrom :: forall x. ImageConfig -> Rep ImageConfig x
Prelude.Generic)

-- |
-- Create a value of 'ImageConfig' 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:
--
-- 'command', 'imageConfig_command' - Specifies parameters that you want to pass in with ENTRYPOINT.
--
-- 'entryPoint', 'imageConfig_entryPoint' - Specifies the entry point to their application, which is typically the
-- location of the runtime executable.
--
-- 'workingDirectory', 'imageConfig_workingDirectory' - Specifies the working directory.
newImageConfig ::
  ImageConfig
newImageConfig :: ImageConfig
newImageConfig =
  ImageConfig'
    { $sel:command:ImageConfig' :: Maybe [Text]
command = forall a. Maybe a
Prelude.Nothing,
      $sel:entryPoint:ImageConfig' :: Maybe [Text]
entryPoint = forall a. Maybe a
Prelude.Nothing,
      $sel:workingDirectory:ImageConfig' :: Maybe Text
workingDirectory = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies parameters that you want to pass in with ENTRYPOINT.
imageConfig_command :: Lens.Lens' ImageConfig (Prelude.Maybe [Prelude.Text])
imageConfig_command :: Lens' ImageConfig (Maybe [Text])
imageConfig_command = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageConfig' {Maybe [Text]
command :: Maybe [Text]
$sel:command:ImageConfig' :: ImageConfig -> Maybe [Text]
command} -> Maybe [Text]
command) (\s :: ImageConfig
s@ImageConfig' {} Maybe [Text]
a -> ImageConfig
s {$sel:command:ImageConfig' :: Maybe [Text]
command = Maybe [Text]
a} :: ImageConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the entry point to their application, which is typically the
-- location of the runtime executable.
imageConfig_entryPoint :: Lens.Lens' ImageConfig (Prelude.Maybe [Prelude.Text])
imageConfig_entryPoint :: Lens' ImageConfig (Maybe [Text])
imageConfig_entryPoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageConfig' {Maybe [Text]
entryPoint :: Maybe [Text]
$sel:entryPoint:ImageConfig' :: ImageConfig -> Maybe [Text]
entryPoint} -> Maybe [Text]
entryPoint) (\s :: ImageConfig
s@ImageConfig' {} Maybe [Text]
a -> ImageConfig
s {$sel:entryPoint:ImageConfig' :: Maybe [Text]
entryPoint = Maybe [Text]
a} :: ImageConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the working directory.
imageConfig_workingDirectory :: Lens.Lens' ImageConfig (Prelude.Maybe Prelude.Text)
imageConfig_workingDirectory :: Lens' ImageConfig (Maybe Text)
imageConfig_workingDirectory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageConfig' {Maybe Text
workingDirectory :: Maybe Text
$sel:workingDirectory:ImageConfig' :: ImageConfig -> Maybe Text
workingDirectory} -> Maybe Text
workingDirectory) (\s :: ImageConfig
s@ImageConfig' {} Maybe Text
a -> ImageConfig
s {$sel:workingDirectory:ImageConfig' :: Maybe Text
workingDirectory = Maybe Text
a} :: ImageConfig)

instance Data.FromJSON ImageConfig where
  parseJSON :: Value -> Parser ImageConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ImageConfig"
      ( \Object
x ->
          Maybe [Text] -> Maybe [Text] -> Maybe Text -> ImageConfig
ImageConfig'
            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
"Command" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"EntryPoint" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"WorkingDirectory")
      )

instance Prelude.Hashable ImageConfig where
  hashWithSalt :: Int -> ImageConfig -> Int
hashWithSalt Int
_salt ImageConfig' {Maybe [Text]
Maybe Text
workingDirectory :: Maybe Text
entryPoint :: Maybe [Text]
command :: Maybe [Text]
$sel:workingDirectory:ImageConfig' :: ImageConfig -> Maybe Text
$sel:entryPoint:ImageConfig' :: ImageConfig -> Maybe [Text]
$sel:command:ImageConfig' :: ImageConfig -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
command
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
entryPoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
workingDirectory

instance Prelude.NFData ImageConfig where
  rnf :: ImageConfig -> ()
rnf ImageConfig' {Maybe [Text]
Maybe Text
workingDirectory :: Maybe Text
entryPoint :: Maybe [Text]
command :: Maybe [Text]
$sel:workingDirectory:ImageConfig' :: ImageConfig -> Maybe Text
$sel:entryPoint:ImageConfig' :: ImageConfig -> Maybe [Text]
$sel:command:ImageConfig' :: ImageConfig -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
command
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
entryPoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
workingDirectory

instance Data.ToJSON ImageConfig where
  toJSON :: ImageConfig -> Value
toJSON ImageConfig' {Maybe [Text]
Maybe Text
workingDirectory :: Maybe Text
entryPoint :: Maybe [Text]
command :: Maybe [Text]
$sel:workingDirectory:ImageConfig' :: ImageConfig -> Maybe Text
$sel:entryPoint:ImageConfig' :: ImageConfig -> Maybe [Text]
$sel:command:ImageConfig' :: ImageConfig -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Command" 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]
command,
            (Key
"EntryPoint" 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]
entryPoint,
            (Key
"WorkingDirectory" 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
workingDirectory
          ]
      )