{-# 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.ChimeSDKMessaging.Types.ProcessorConfiguration
-- 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.ChimeSDKMessaging.Types.ProcessorConfiguration where

import Amazonka.ChimeSDKMessaging.Types.LambdaConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A processor\'s metadata.
--
-- /See:/ 'newProcessorConfiguration' smart constructor.
data ProcessorConfiguration = ProcessorConfiguration'
  { -- | Indicates that the processor is of type Lambda.
    ProcessorConfiguration -> LambdaConfiguration
lambda :: LambdaConfiguration
  }
  deriving (ProcessorConfiguration -> ProcessorConfiguration -> Bool
(ProcessorConfiguration -> ProcessorConfiguration -> Bool)
-> (ProcessorConfiguration -> ProcessorConfiguration -> Bool)
-> Eq ProcessorConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessorConfiguration -> ProcessorConfiguration -> Bool
$c/= :: ProcessorConfiguration -> ProcessorConfiguration -> Bool
== :: ProcessorConfiguration -> ProcessorConfiguration -> Bool
$c== :: ProcessorConfiguration -> ProcessorConfiguration -> Bool
Prelude.Eq, ReadPrec [ProcessorConfiguration]
ReadPrec ProcessorConfiguration
Int -> ReadS ProcessorConfiguration
ReadS [ProcessorConfiguration]
(Int -> ReadS ProcessorConfiguration)
-> ReadS [ProcessorConfiguration]
-> ReadPrec ProcessorConfiguration
-> ReadPrec [ProcessorConfiguration]
-> Read ProcessorConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessorConfiguration]
$creadListPrec :: ReadPrec [ProcessorConfiguration]
readPrec :: ReadPrec ProcessorConfiguration
$creadPrec :: ReadPrec ProcessorConfiguration
readList :: ReadS [ProcessorConfiguration]
$creadList :: ReadS [ProcessorConfiguration]
readsPrec :: Int -> ReadS ProcessorConfiguration
$creadsPrec :: Int -> ReadS ProcessorConfiguration
Prelude.Read, Int -> ProcessorConfiguration -> ShowS
[ProcessorConfiguration] -> ShowS
ProcessorConfiguration -> String
(Int -> ProcessorConfiguration -> ShowS)
-> (ProcessorConfiguration -> String)
-> ([ProcessorConfiguration] -> ShowS)
-> Show ProcessorConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessorConfiguration] -> ShowS
$cshowList :: [ProcessorConfiguration] -> ShowS
show :: ProcessorConfiguration -> String
$cshow :: ProcessorConfiguration -> String
showsPrec :: Int -> ProcessorConfiguration -> ShowS
$cshowsPrec :: Int -> ProcessorConfiguration -> ShowS
Prelude.Show, (forall x. ProcessorConfiguration -> Rep ProcessorConfiguration x)
-> (forall x.
    Rep ProcessorConfiguration x -> ProcessorConfiguration)
-> Generic ProcessorConfiguration
forall x. Rep ProcessorConfiguration x -> ProcessorConfiguration
forall x. ProcessorConfiguration -> Rep ProcessorConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessorConfiguration x -> ProcessorConfiguration
$cfrom :: forall x. ProcessorConfiguration -> Rep ProcessorConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ProcessorConfiguration' 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:
--
-- 'lambda', 'processorConfiguration_lambda' - Indicates that the processor is of type Lambda.
newProcessorConfiguration ::
  -- | 'lambda'
  LambdaConfiguration ->
  ProcessorConfiguration
newProcessorConfiguration :: LambdaConfiguration -> ProcessorConfiguration
newProcessorConfiguration LambdaConfiguration
pLambda_ =
  ProcessorConfiguration' :: LambdaConfiguration -> ProcessorConfiguration
ProcessorConfiguration' {$sel:lambda:ProcessorConfiguration' :: LambdaConfiguration
lambda = LambdaConfiguration
pLambda_}

-- | Indicates that the processor is of type Lambda.
processorConfiguration_lambda :: Lens.Lens' ProcessorConfiguration LambdaConfiguration
processorConfiguration_lambda :: (LambdaConfiguration -> f LambdaConfiguration)
-> ProcessorConfiguration -> f ProcessorConfiguration
processorConfiguration_lambda = (ProcessorConfiguration -> LambdaConfiguration)
-> (ProcessorConfiguration
    -> LambdaConfiguration -> ProcessorConfiguration)
-> Lens
     ProcessorConfiguration
     ProcessorConfiguration
     LambdaConfiguration
     LambdaConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessorConfiguration' {LambdaConfiguration
lambda :: LambdaConfiguration
$sel:lambda:ProcessorConfiguration' :: ProcessorConfiguration -> LambdaConfiguration
lambda} -> LambdaConfiguration
lambda) (\s :: ProcessorConfiguration
s@ProcessorConfiguration' {} LambdaConfiguration
a -> ProcessorConfiguration
s {$sel:lambda:ProcessorConfiguration' :: LambdaConfiguration
lambda = LambdaConfiguration
a} :: ProcessorConfiguration)

instance Core.FromJSON ProcessorConfiguration where
  parseJSON :: Value -> Parser ProcessorConfiguration
parseJSON =
    String
-> (Object -> Parser ProcessorConfiguration)
-> Value
-> Parser ProcessorConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessorConfiguration"
      ( \Object
x ->
          LambdaConfiguration -> ProcessorConfiguration
ProcessorConfiguration'
            (LambdaConfiguration -> ProcessorConfiguration)
-> Parser LambdaConfiguration -> Parser ProcessorConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser LambdaConfiguration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Lambda")
      )

instance Prelude.Hashable ProcessorConfiguration

instance Prelude.NFData ProcessorConfiguration

instance Core.ToJSON ProcessorConfiguration where
  toJSON :: ProcessorConfiguration -> Value
toJSON ProcessorConfiguration' {LambdaConfiguration
lambda :: LambdaConfiguration
$sel:lambda:ProcessorConfiguration' :: ProcessorConfiguration -> LambdaConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Lambda" Text -> LambdaConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LambdaConfiguration
lambda)]
      )