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

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

-- | Configuration values that override the container image Dockerfile
-- settings. See
-- <https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-parms Container 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
(ImageConfig -> ImageConfig -> Bool)
-> (ImageConfig -> ImageConfig -> Bool) -> Eq ImageConfig
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]
(Int -> ReadS ImageConfig)
-> ReadS [ImageConfig]
-> ReadPrec ImageConfig
-> ReadPrec [ImageConfig]
-> Read 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
(Int -> ImageConfig -> ShowS)
-> (ImageConfig -> String)
-> ([ImageConfig] -> ShowS)
-> Show ImageConfig
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. ImageConfig -> Rep ImageConfig x)
-> (forall x. Rep ImageConfig x -> ImageConfig)
-> Generic ImageConfig
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' :: Maybe [Text] -> Maybe [Text] -> Maybe Text -> ImageConfig
ImageConfig'
    { $sel:command:ImageConfig' :: Maybe [Text]
command = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:entryPoint:ImageConfig' :: Maybe [Text]
entryPoint = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:workingDirectory:ImageConfig' :: Maybe Text
workingDirectory = Maybe Text
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 :: (Maybe [Text] -> f (Maybe [Text])) -> ImageConfig -> f ImageConfig
imageConfig_command = (ImageConfig -> Maybe [Text])
-> (ImageConfig -> Maybe [Text] -> ImageConfig)
-> Lens ImageConfig ImageConfig (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ImageConfig -> f ImageConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ImageConfig
-> f ImageConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe [Text] -> f (Maybe [Text])) -> ImageConfig -> f ImageConfig
imageConfig_entryPoint = (ImageConfig -> Maybe [Text])
-> (ImageConfig -> Maybe [Text] -> ImageConfig)
-> Lens ImageConfig ImageConfig (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ImageConfig -> f ImageConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ImageConfig
-> f ImageConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: (Maybe Text -> f (Maybe Text)) -> ImageConfig -> f ImageConfig
imageConfig_workingDirectory = (ImageConfig -> Maybe Text)
-> (ImageConfig -> Maybe Text -> ImageConfig)
-> Lens ImageConfig ImageConfig (Maybe Text) (Maybe Text)
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 Core.FromJSON ImageConfig where
  parseJSON :: Value -> Parser ImageConfig
parseJSON =
    String
-> (Object -> Parser ImageConfig) -> Value -> Parser ImageConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageConfig"
      ( \Object
x ->
          Maybe [Text] -> Maybe [Text] -> Maybe Text -> ImageConfig
ImageConfig'
            (Maybe [Text] -> Maybe [Text] -> Maybe Text -> ImageConfig)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> Maybe Text -> ImageConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Command" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Text] -> Maybe Text -> ImageConfig)
-> Parser (Maybe [Text]) -> Parser (Maybe Text -> ImageConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EntryPoint" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ImageConfig)
-> Parser (Maybe Text) -> Parser ImageConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"WorkingDirectory")
      )

instance Prelude.Hashable ImageConfig

instance Prelude.NFData ImageConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Command" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
command,
            (Text
"EntryPoint" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
entryPoint,
            (Text
"WorkingDirectory" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
workingDirectory
          ]
      )