{-# 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.FunctionDefaultConfig
-- 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.FunctionDefaultConfig where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types.FunctionDefaultExecutionConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The default configuration that applies to all Lambda functions in the
-- group. Individual Lambda functions can override these settings.
--
-- /See:/ 'newFunctionDefaultConfig' smart constructor.
data FunctionDefaultConfig = FunctionDefaultConfig'
  { FunctionDefaultConfig -> Maybe FunctionDefaultExecutionConfig
execution :: Prelude.Maybe FunctionDefaultExecutionConfig
  }
  deriving (FunctionDefaultConfig -> FunctionDefaultConfig -> Bool
(FunctionDefaultConfig -> FunctionDefaultConfig -> Bool)
-> (FunctionDefaultConfig -> FunctionDefaultConfig -> Bool)
-> Eq FunctionDefaultConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionDefaultConfig -> FunctionDefaultConfig -> Bool
$c/= :: FunctionDefaultConfig -> FunctionDefaultConfig -> Bool
== :: FunctionDefaultConfig -> FunctionDefaultConfig -> Bool
$c== :: FunctionDefaultConfig -> FunctionDefaultConfig -> Bool
Prelude.Eq, ReadPrec [FunctionDefaultConfig]
ReadPrec FunctionDefaultConfig
Int -> ReadS FunctionDefaultConfig
ReadS [FunctionDefaultConfig]
(Int -> ReadS FunctionDefaultConfig)
-> ReadS [FunctionDefaultConfig]
-> ReadPrec FunctionDefaultConfig
-> ReadPrec [FunctionDefaultConfig]
-> Read FunctionDefaultConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FunctionDefaultConfig]
$creadListPrec :: ReadPrec [FunctionDefaultConfig]
readPrec :: ReadPrec FunctionDefaultConfig
$creadPrec :: ReadPrec FunctionDefaultConfig
readList :: ReadS [FunctionDefaultConfig]
$creadList :: ReadS [FunctionDefaultConfig]
readsPrec :: Int -> ReadS FunctionDefaultConfig
$creadsPrec :: Int -> ReadS FunctionDefaultConfig
Prelude.Read, Int -> FunctionDefaultConfig -> ShowS
[FunctionDefaultConfig] -> ShowS
FunctionDefaultConfig -> String
(Int -> FunctionDefaultConfig -> ShowS)
-> (FunctionDefaultConfig -> String)
-> ([FunctionDefaultConfig] -> ShowS)
-> Show FunctionDefaultConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionDefaultConfig] -> ShowS
$cshowList :: [FunctionDefaultConfig] -> ShowS
show :: FunctionDefaultConfig -> String
$cshow :: FunctionDefaultConfig -> String
showsPrec :: Int -> FunctionDefaultConfig -> ShowS
$cshowsPrec :: Int -> FunctionDefaultConfig -> ShowS
Prelude.Show, (forall x. FunctionDefaultConfig -> Rep FunctionDefaultConfig x)
-> (forall x. Rep FunctionDefaultConfig x -> FunctionDefaultConfig)
-> Generic FunctionDefaultConfig
forall x. Rep FunctionDefaultConfig x -> FunctionDefaultConfig
forall x. FunctionDefaultConfig -> Rep FunctionDefaultConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FunctionDefaultConfig x -> FunctionDefaultConfig
$cfrom :: forall x. FunctionDefaultConfig -> Rep FunctionDefaultConfig x
Prelude.Generic)

-- |
-- Create a value of 'FunctionDefaultConfig' 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:
--
-- 'execution', 'functionDefaultConfig_execution' - Undocumented member.
newFunctionDefaultConfig ::
  FunctionDefaultConfig
newFunctionDefaultConfig :: FunctionDefaultConfig
newFunctionDefaultConfig =
  FunctionDefaultConfig' :: Maybe FunctionDefaultExecutionConfig -> FunctionDefaultConfig
FunctionDefaultConfig' {$sel:execution:FunctionDefaultConfig' :: Maybe FunctionDefaultExecutionConfig
execution = Maybe FunctionDefaultExecutionConfig
forall a. Maybe a
Prelude.Nothing}

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

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

instance Prelude.Hashable FunctionDefaultConfig

instance Prelude.NFData FunctionDefaultConfig

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