{-# 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.GreengrassV2.Types.LambdaLinuxProcessParams
-- 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.GreengrassV2.Types.LambdaLinuxProcessParams where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.LambdaContainerParams
import Amazonka.GreengrassV2.Types.LambdaIsolationMode
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains parameters for a Linux process that contains an Lambda
-- function.
--
-- /See:/ 'newLambdaLinuxProcessParams' smart constructor.
data LambdaLinuxProcessParams = LambdaLinuxProcessParams'
  { -- | The parameters for the container in which the Lambda function runs.
    LambdaLinuxProcessParams -> Maybe LambdaContainerParams
containerParams :: Prelude.Maybe LambdaContainerParams,
    -- | The isolation mode for the process that contains the Lambda function.
    -- The process can run in an isolated runtime environment inside the IoT
    -- Greengrass container, or as a regular process outside any container.
    --
    -- Default: @GreengrassContainer@
    LambdaLinuxProcessParams -> Maybe LambdaIsolationMode
isolationMode :: Prelude.Maybe LambdaIsolationMode
  }
  deriving (LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool
(LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool)
-> (LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool)
-> Eq LambdaLinuxProcessParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool
$c/= :: LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool
== :: LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool
$c== :: LambdaLinuxProcessParams -> LambdaLinuxProcessParams -> Bool
Prelude.Eq, ReadPrec [LambdaLinuxProcessParams]
ReadPrec LambdaLinuxProcessParams
Int -> ReadS LambdaLinuxProcessParams
ReadS [LambdaLinuxProcessParams]
(Int -> ReadS LambdaLinuxProcessParams)
-> ReadS [LambdaLinuxProcessParams]
-> ReadPrec LambdaLinuxProcessParams
-> ReadPrec [LambdaLinuxProcessParams]
-> Read LambdaLinuxProcessParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaLinuxProcessParams]
$creadListPrec :: ReadPrec [LambdaLinuxProcessParams]
readPrec :: ReadPrec LambdaLinuxProcessParams
$creadPrec :: ReadPrec LambdaLinuxProcessParams
readList :: ReadS [LambdaLinuxProcessParams]
$creadList :: ReadS [LambdaLinuxProcessParams]
readsPrec :: Int -> ReadS LambdaLinuxProcessParams
$creadsPrec :: Int -> ReadS LambdaLinuxProcessParams
Prelude.Read, Int -> LambdaLinuxProcessParams -> ShowS
[LambdaLinuxProcessParams] -> ShowS
LambdaLinuxProcessParams -> String
(Int -> LambdaLinuxProcessParams -> ShowS)
-> (LambdaLinuxProcessParams -> String)
-> ([LambdaLinuxProcessParams] -> ShowS)
-> Show LambdaLinuxProcessParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaLinuxProcessParams] -> ShowS
$cshowList :: [LambdaLinuxProcessParams] -> ShowS
show :: LambdaLinuxProcessParams -> String
$cshow :: LambdaLinuxProcessParams -> String
showsPrec :: Int -> LambdaLinuxProcessParams -> ShowS
$cshowsPrec :: Int -> LambdaLinuxProcessParams -> ShowS
Prelude.Show, (forall x.
 LambdaLinuxProcessParams -> Rep LambdaLinuxProcessParams x)
-> (forall x.
    Rep LambdaLinuxProcessParams x -> LambdaLinuxProcessParams)
-> Generic LambdaLinuxProcessParams
forall x.
Rep LambdaLinuxProcessParams x -> LambdaLinuxProcessParams
forall x.
LambdaLinuxProcessParams -> Rep LambdaLinuxProcessParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LambdaLinuxProcessParams x -> LambdaLinuxProcessParams
$cfrom :: forall x.
LambdaLinuxProcessParams -> Rep LambdaLinuxProcessParams x
Prelude.Generic)

-- |
-- Create a value of 'LambdaLinuxProcessParams' 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:
--
-- 'containerParams', 'lambdaLinuxProcessParams_containerParams' - The parameters for the container in which the Lambda function runs.
--
-- 'isolationMode', 'lambdaLinuxProcessParams_isolationMode' - The isolation mode for the process that contains the Lambda function.
-- The process can run in an isolated runtime environment inside the IoT
-- Greengrass container, or as a regular process outside any container.
--
-- Default: @GreengrassContainer@
newLambdaLinuxProcessParams ::
  LambdaLinuxProcessParams
newLambdaLinuxProcessParams :: LambdaLinuxProcessParams
newLambdaLinuxProcessParams =
  LambdaLinuxProcessParams' :: Maybe LambdaContainerParams
-> Maybe LambdaIsolationMode -> LambdaLinuxProcessParams
LambdaLinuxProcessParams'
    { $sel:containerParams:LambdaLinuxProcessParams' :: Maybe LambdaContainerParams
containerParams =
        Maybe LambdaContainerParams
forall a. Maybe a
Prelude.Nothing,
      $sel:isolationMode:LambdaLinuxProcessParams' :: Maybe LambdaIsolationMode
isolationMode = Maybe LambdaIsolationMode
forall a. Maybe a
Prelude.Nothing
    }

-- | The parameters for the container in which the Lambda function runs.
lambdaLinuxProcessParams_containerParams :: Lens.Lens' LambdaLinuxProcessParams (Prelude.Maybe LambdaContainerParams)
lambdaLinuxProcessParams_containerParams :: (Maybe LambdaContainerParams -> f (Maybe LambdaContainerParams))
-> LambdaLinuxProcessParams -> f LambdaLinuxProcessParams
lambdaLinuxProcessParams_containerParams = (LambdaLinuxProcessParams -> Maybe LambdaContainerParams)
-> (LambdaLinuxProcessParams
    -> Maybe LambdaContainerParams -> LambdaLinuxProcessParams)
-> Lens
     LambdaLinuxProcessParams
     LambdaLinuxProcessParams
     (Maybe LambdaContainerParams)
     (Maybe LambdaContainerParams)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaLinuxProcessParams' {Maybe LambdaContainerParams
containerParams :: Maybe LambdaContainerParams
$sel:containerParams:LambdaLinuxProcessParams' :: LambdaLinuxProcessParams -> Maybe LambdaContainerParams
containerParams} -> Maybe LambdaContainerParams
containerParams) (\s :: LambdaLinuxProcessParams
s@LambdaLinuxProcessParams' {} Maybe LambdaContainerParams
a -> LambdaLinuxProcessParams
s {$sel:containerParams:LambdaLinuxProcessParams' :: Maybe LambdaContainerParams
containerParams = Maybe LambdaContainerParams
a} :: LambdaLinuxProcessParams)

-- | The isolation mode for the process that contains the Lambda function.
-- The process can run in an isolated runtime environment inside the IoT
-- Greengrass container, or as a regular process outside any container.
--
-- Default: @GreengrassContainer@
lambdaLinuxProcessParams_isolationMode :: Lens.Lens' LambdaLinuxProcessParams (Prelude.Maybe LambdaIsolationMode)
lambdaLinuxProcessParams_isolationMode :: (Maybe LambdaIsolationMode -> f (Maybe LambdaIsolationMode))
-> LambdaLinuxProcessParams -> f LambdaLinuxProcessParams
lambdaLinuxProcessParams_isolationMode = (LambdaLinuxProcessParams -> Maybe LambdaIsolationMode)
-> (LambdaLinuxProcessParams
    -> Maybe LambdaIsolationMode -> LambdaLinuxProcessParams)
-> Lens
     LambdaLinuxProcessParams
     LambdaLinuxProcessParams
     (Maybe LambdaIsolationMode)
     (Maybe LambdaIsolationMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaLinuxProcessParams' {Maybe LambdaIsolationMode
isolationMode :: Maybe LambdaIsolationMode
$sel:isolationMode:LambdaLinuxProcessParams' :: LambdaLinuxProcessParams -> Maybe LambdaIsolationMode
isolationMode} -> Maybe LambdaIsolationMode
isolationMode) (\s :: LambdaLinuxProcessParams
s@LambdaLinuxProcessParams' {} Maybe LambdaIsolationMode
a -> LambdaLinuxProcessParams
s {$sel:isolationMode:LambdaLinuxProcessParams' :: Maybe LambdaIsolationMode
isolationMode = Maybe LambdaIsolationMode
a} :: LambdaLinuxProcessParams)

instance Prelude.Hashable LambdaLinuxProcessParams

instance Prelude.NFData LambdaLinuxProcessParams

instance Core.ToJSON LambdaLinuxProcessParams where
  toJSON :: LambdaLinuxProcessParams -> Value
toJSON LambdaLinuxProcessParams' {Maybe LambdaIsolationMode
Maybe LambdaContainerParams
isolationMode :: Maybe LambdaIsolationMode
containerParams :: Maybe LambdaContainerParams
$sel:isolationMode:LambdaLinuxProcessParams' :: LambdaLinuxProcessParams -> Maybe LambdaIsolationMode
$sel:containerParams:LambdaLinuxProcessParams' :: LambdaLinuxProcessParams -> Maybe LambdaContainerParams
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"containerParams" Text -> LambdaContainerParams -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LambdaContainerParams -> Pair)
-> Maybe LambdaContainerParams -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaContainerParams
containerParams,
            (Text
"isolationMode" Text -> LambdaIsolationMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LambdaIsolationMode -> Pair)
-> Maybe LambdaIsolationMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaIsolationMode
isolationMode
          ]
      )