{-# 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.Greengrass.Types.FunctionDefaultExecutionConfig
-- 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.Greengrass.Types.FunctionDefaultExecutionConfig where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types.FunctionIsolationMode
import Amazonka.Greengrass.Types.FunctionRunAsConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information that specifies how a Lambda function runs.
--
-- /See:/ 'newFunctionDefaultExecutionConfig' smart constructor.
data FunctionDefaultExecutionConfig = FunctionDefaultExecutionConfig'
  { FunctionDefaultExecutionConfig -> Maybe FunctionRunAsConfig
runAs :: Prelude.Maybe FunctionRunAsConfig,
    FunctionDefaultExecutionConfig -> Maybe FunctionIsolationMode
isolationMode :: Prelude.Maybe FunctionIsolationMode
  }
  deriving (FunctionDefaultExecutionConfig
-> FunctionDefaultExecutionConfig -> Bool
(FunctionDefaultExecutionConfig
 -> FunctionDefaultExecutionConfig -> Bool)
-> (FunctionDefaultExecutionConfig
    -> FunctionDefaultExecutionConfig -> Bool)
-> Eq FunctionDefaultExecutionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionDefaultExecutionConfig
-> FunctionDefaultExecutionConfig -> Bool
$c/= :: FunctionDefaultExecutionConfig
-> FunctionDefaultExecutionConfig -> Bool
== :: FunctionDefaultExecutionConfig
-> FunctionDefaultExecutionConfig -> Bool
$c== :: FunctionDefaultExecutionConfig
-> FunctionDefaultExecutionConfig -> Bool
Prelude.Eq, ReadPrec [FunctionDefaultExecutionConfig]
ReadPrec FunctionDefaultExecutionConfig
Int -> ReadS FunctionDefaultExecutionConfig
ReadS [FunctionDefaultExecutionConfig]
(Int -> ReadS FunctionDefaultExecutionConfig)
-> ReadS [FunctionDefaultExecutionConfig]
-> ReadPrec FunctionDefaultExecutionConfig
-> ReadPrec [FunctionDefaultExecutionConfig]
-> Read FunctionDefaultExecutionConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionDefaultExecutionConfig]
$creadListPrec :: ReadPrec [FunctionDefaultExecutionConfig]
readPrec :: ReadPrec FunctionDefaultExecutionConfig
$creadPrec :: ReadPrec FunctionDefaultExecutionConfig
readList :: ReadS [FunctionDefaultExecutionConfig]
$creadList :: ReadS [FunctionDefaultExecutionConfig]
readsPrec :: Int -> ReadS FunctionDefaultExecutionConfig
$creadsPrec :: Int -> ReadS FunctionDefaultExecutionConfig
Prelude.Read, Int -> FunctionDefaultExecutionConfig -> ShowS
[FunctionDefaultExecutionConfig] -> ShowS
FunctionDefaultExecutionConfig -> String
(Int -> FunctionDefaultExecutionConfig -> ShowS)
-> (FunctionDefaultExecutionConfig -> String)
-> ([FunctionDefaultExecutionConfig] -> ShowS)
-> Show FunctionDefaultExecutionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionDefaultExecutionConfig] -> ShowS
$cshowList :: [FunctionDefaultExecutionConfig] -> ShowS
show :: FunctionDefaultExecutionConfig -> String
$cshow :: FunctionDefaultExecutionConfig -> String
showsPrec :: Int -> FunctionDefaultExecutionConfig -> ShowS
$cshowsPrec :: Int -> FunctionDefaultExecutionConfig -> ShowS
Prelude.Show, (forall x.
 FunctionDefaultExecutionConfig
 -> Rep FunctionDefaultExecutionConfig x)
-> (forall x.
    Rep FunctionDefaultExecutionConfig x
    -> FunctionDefaultExecutionConfig)
-> Generic FunctionDefaultExecutionConfig
forall x.
Rep FunctionDefaultExecutionConfig x
-> FunctionDefaultExecutionConfig
forall x.
FunctionDefaultExecutionConfig
-> Rep FunctionDefaultExecutionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep FunctionDefaultExecutionConfig x
-> FunctionDefaultExecutionConfig
$cfrom :: forall x.
FunctionDefaultExecutionConfig
-> Rep FunctionDefaultExecutionConfig x
Prelude.Generic)

-- |
-- Create a value of 'FunctionDefaultExecutionConfig' 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:
--
-- 'runAs', 'functionDefaultExecutionConfig_runAs' - Undocumented member.
--
-- 'isolationMode', 'functionDefaultExecutionConfig_isolationMode' - Undocumented member.
newFunctionDefaultExecutionConfig ::
  FunctionDefaultExecutionConfig
newFunctionDefaultExecutionConfig :: FunctionDefaultExecutionConfig
newFunctionDefaultExecutionConfig =
  FunctionDefaultExecutionConfig' :: Maybe FunctionRunAsConfig
-> Maybe FunctionIsolationMode -> FunctionDefaultExecutionConfig
FunctionDefaultExecutionConfig'
    { $sel:runAs:FunctionDefaultExecutionConfig' :: Maybe FunctionRunAsConfig
runAs =
        Maybe FunctionRunAsConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:isolationMode:FunctionDefaultExecutionConfig' :: Maybe FunctionIsolationMode
isolationMode = Maybe FunctionIsolationMode
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
functionDefaultExecutionConfig_runAs :: Lens.Lens' FunctionDefaultExecutionConfig (Prelude.Maybe FunctionRunAsConfig)
functionDefaultExecutionConfig_runAs :: (Maybe FunctionRunAsConfig -> f (Maybe FunctionRunAsConfig))
-> FunctionDefaultExecutionConfig
-> f FunctionDefaultExecutionConfig
functionDefaultExecutionConfig_runAs = (FunctionDefaultExecutionConfig -> Maybe FunctionRunAsConfig)
-> (FunctionDefaultExecutionConfig
    -> Maybe FunctionRunAsConfig -> FunctionDefaultExecutionConfig)
-> Lens
     FunctionDefaultExecutionConfig
     FunctionDefaultExecutionConfig
     (Maybe FunctionRunAsConfig)
     (Maybe FunctionRunAsConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionDefaultExecutionConfig' {Maybe FunctionRunAsConfig
runAs :: Maybe FunctionRunAsConfig
$sel:runAs:FunctionDefaultExecutionConfig' :: FunctionDefaultExecutionConfig -> Maybe FunctionRunAsConfig
runAs} -> Maybe FunctionRunAsConfig
runAs) (\s :: FunctionDefaultExecutionConfig
s@FunctionDefaultExecutionConfig' {} Maybe FunctionRunAsConfig
a -> FunctionDefaultExecutionConfig
s {$sel:runAs:FunctionDefaultExecutionConfig' :: Maybe FunctionRunAsConfig
runAs = Maybe FunctionRunAsConfig
a} :: FunctionDefaultExecutionConfig)

-- | Undocumented member.
functionDefaultExecutionConfig_isolationMode :: Lens.Lens' FunctionDefaultExecutionConfig (Prelude.Maybe FunctionIsolationMode)
functionDefaultExecutionConfig_isolationMode :: (Maybe FunctionIsolationMode -> f (Maybe FunctionIsolationMode))
-> FunctionDefaultExecutionConfig
-> f FunctionDefaultExecutionConfig
functionDefaultExecutionConfig_isolationMode = (FunctionDefaultExecutionConfig -> Maybe FunctionIsolationMode)
-> (FunctionDefaultExecutionConfig
    -> Maybe FunctionIsolationMode -> FunctionDefaultExecutionConfig)
-> Lens
     FunctionDefaultExecutionConfig
     FunctionDefaultExecutionConfig
     (Maybe FunctionIsolationMode)
     (Maybe FunctionIsolationMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FunctionDefaultExecutionConfig' {Maybe FunctionIsolationMode
isolationMode :: Maybe FunctionIsolationMode
$sel:isolationMode:FunctionDefaultExecutionConfig' :: FunctionDefaultExecutionConfig -> Maybe FunctionIsolationMode
isolationMode} -> Maybe FunctionIsolationMode
isolationMode) (\s :: FunctionDefaultExecutionConfig
s@FunctionDefaultExecutionConfig' {} Maybe FunctionIsolationMode
a -> FunctionDefaultExecutionConfig
s {$sel:isolationMode:FunctionDefaultExecutionConfig' :: Maybe FunctionIsolationMode
isolationMode = Maybe FunctionIsolationMode
a} :: FunctionDefaultExecutionConfig)

instance Core.FromJSON FunctionDefaultExecutionConfig where
  parseJSON :: Value -> Parser FunctionDefaultExecutionConfig
parseJSON =
    String
-> (Object -> Parser FunctionDefaultExecutionConfig)
-> Value
-> Parser FunctionDefaultExecutionConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FunctionDefaultExecutionConfig"
      ( \Object
x ->
          Maybe FunctionRunAsConfig
-> Maybe FunctionIsolationMode -> FunctionDefaultExecutionConfig
FunctionDefaultExecutionConfig'
            (Maybe FunctionRunAsConfig
 -> Maybe FunctionIsolationMode -> FunctionDefaultExecutionConfig)
-> Parser (Maybe FunctionRunAsConfig)
-> Parser
     (Maybe FunctionIsolationMode -> FunctionDefaultExecutionConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe FunctionRunAsConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RunAs")
            Parser
  (Maybe FunctionIsolationMode -> FunctionDefaultExecutionConfig)
-> Parser (Maybe FunctionIsolationMode)
-> Parser FunctionDefaultExecutionConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FunctionIsolationMode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IsolationMode")
      )

instance
  Prelude.Hashable
    FunctionDefaultExecutionConfig

instance
  Prelude.NFData
    FunctionDefaultExecutionConfig

instance Core.ToJSON FunctionDefaultExecutionConfig where
  toJSON :: FunctionDefaultExecutionConfig -> Value
toJSON FunctionDefaultExecutionConfig' {Maybe FunctionIsolationMode
Maybe FunctionRunAsConfig
isolationMode :: Maybe FunctionIsolationMode
runAs :: Maybe FunctionRunAsConfig
$sel:isolationMode:FunctionDefaultExecutionConfig' :: FunctionDefaultExecutionConfig -> Maybe FunctionIsolationMode
$sel:runAs:FunctionDefaultExecutionConfig' :: FunctionDefaultExecutionConfig -> Maybe FunctionRunAsConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RunAs" Text -> FunctionRunAsConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FunctionRunAsConfig -> Pair)
-> Maybe FunctionRunAsConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FunctionRunAsConfig
runAs,
            (Text
"IsolationMode" Text -> FunctionIsolationMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FunctionIsolationMode -> Pair)
-> Maybe FunctionIsolationMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FunctionIsolationMode
isolationMode
          ]
      )