{-# 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.Firehose.Types.ProcessingConfiguration
-- 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.Firehose.Types.ProcessingConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.Processor
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a data processing configuration.
--
-- /See:/ 'newProcessingConfiguration' smart constructor.
data ProcessingConfiguration = ProcessingConfiguration'
  { -- | Enables or disables data processing.
    ProcessingConfiguration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The data processors.
    ProcessingConfiguration -> Maybe [Processor]
processors :: Prelude.Maybe [Processor]
  }
  deriving (ProcessingConfiguration -> ProcessingConfiguration -> Bool
(ProcessingConfiguration -> ProcessingConfiguration -> Bool)
-> (ProcessingConfiguration -> ProcessingConfiguration -> Bool)
-> Eq ProcessingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessingConfiguration -> ProcessingConfiguration -> Bool
$c/= :: ProcessingConfiguration -> ProcessingConfiguration -> Bool
== :: ProcessingConfiguration -> ProcessingConfiguration -> Bool
$c== :: ProcessingConfiguration -> ProcessingConfiguration -> Bool
Prelude.Eq, ReadPrec [ProcessingConfiguration]
ReadPrec ProcessingConfiguration
Int -> ReadS ProcessingConfiguration
ReadS [ProcessingConfiguration]
(Int -> ReadS ProcessingConfiguration)
-> ReadS [ProcessingConfiguration]
-> ReadPrec ProcessingConfiguration
-> ReadPrec [ProcessingConfiguration]
-> Read ProcessingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessingConfiguration]
$creadListPrec :: ReadPrec [ProcessingConfiguration]
readPrec :: ReadPrec ProcessingConfiguration
$creadPrec :: ReadPrec ProcessingConfiguration
readList :: ReadS [ProcessingConfiguration]
$creadList :: ReadS [ProcessingConfiguration]
readsPrec :: Int -> ReadS ProcessingConfiguration
$creadsPrec :: Int -> ReadS ProcessingConfiguration
Prelude.Read, Int -> ProcessingConfiguration -> ShowS
[ProcessingConfiguration] -> ShowS
ProcessingConfiguration -> String
(Int -> ProcessingConfiguration -> ShowS)
-> (ProcessingConfiguration -> String)
-> ([ProcessingConfiguration] -> ShowS)
-> Show ProcessingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessingConfiguration] -> ShowS
$cshowList :: [ProcessingConfiguration] -> ShowS
show :: ProcessingConfiguration -> String
$cshow :: ProcessingConfiguration -> String
showsPrec :: Int -> ProcessingConfiguration -> ShowS
$cshowsPrec :: Int -> ProcessingConfiguration -> ShowS
Prelude.Show, (forall x.
 ProcessingConfiguration -> Rep ProcessingConfiguration x)
-> (forall x.
    Rep ProcessingConfiguration x -> ProcessingConfiguration)
-> Generic ProcessingConfiguration
forall x. Rep ProcessingConfiguration x -> ProcessingConfiguration
forall x. ProcessingConfiguration -> Rep ProcessingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProcessingConfiguration x -> ProcessingConfiguration
$cfrom :: forall x. ProcessingConfiguration -> Rep ProcessingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ProcessingConfiguration' 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:
--
-- 'enabled', 'processingConfiguration_enabled' - Enables or disables data processing.
--
-- 'processors', 'processingConfiguration_processors' - The data processors.
newProcessingConfiguration ::
  ProcessingConfiguration
newProcessingConfiguration :: ProcessingConfiguration
newProcessingConfiguration =
  ProcessingConfiguration' :: Maybe Bool -> Maybe [Processor] -> ProcessingConfiguration
ProcessingConfiguration'
    { $sel:enabled:ProcessingConfiguration' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:processors:ProcessingConfiguration' :: Maybe [Processor]
processors = Maybe [Processor]
forall a. Maybe a
Prelude.Nothing
    }

-- | Enables or disables data processing.
processingConfiguration_enabled :: Lens.Lens' ProcessingConfiguration (Prelude.Maybe Prelude.Bool)
processingConfiguration_enabled :: (Maybe Bool -> f (Maybe Bool))
-> ProcessingConfiguration -> f ProcessingConfiguration
processingConfiguration_enabled = (ProcessingConfiguration -> Maybe Bool)
-> (ProcessingConfiguration
    -> Maybe Bool -> ProcessingConfiguration)
-> Lens
     ProcessingConfiguration
     ProcessingConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingConfiguration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: ProcessingConfiguration
s@ProcessingConfiguration' {} Maybe Bool
a -> ProcessingConfiguration
s {$sel:enabled:ProcessingConfiguration' :: Maybe Bool
enabled = Maybe Bool
a} :: ProcessingConfiguration)

-- | The data processors.
processingConfiguration_processors :: Lens.Lens' ProcessingConfiguration (Prelude.Maybe [Processor])
processingConfiguration_processors :: (Maybe [Processor] -> f (Maybe [Processor]))
-> ProcessingConfiguration -> f ProcessingConfiguration
processingConfiguration_processors = (ProcessingConfiguration -> Maybe [Processor])
-> (ProcessingConfiguration
    -> Maybe [Processor] -> ProcessingConfiguration)
-> Lens
     ProcessingConfiguration
     ProcessingConfiguration
     (Maybe [Processor])
     (Maybe [Processor])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingConfiguration' {Maybe [Processor]
processors :: Maybe [Processor]
$sel:processors:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe [Processor]
processors} -> Maybe [Processor]
processors) (\s :: ProcessingConfiguration
s@ProcessingConfiguration' {} Maybe [Processor]
a -> ProcessingConfiguration
s {$sel:processors:ProcessingConfiguration' :: Maybe [Processor]
processors = Maybe [Processor]
a} :: ProcessingConfiguration) ((Maybe [Processor] -> f (Maybe [Processor]))
 -> ProcessingConfiguration -> f ProcessingConfiguration)
-> ((Maybe [Processor] -> f (Maybe [Processor]))
    -> Maybe [Processor] -> f (Maybe [Processor]))
-> (Maybe [Processor] -> f (Maybe [Processor]))
-> ProcessingConfiguration
-> f ProcessingConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Processor] [Processor] [Processor] [Processor]
-> Iso
     (Maybe [Processor])
     (Maybe [Processor])
     (Maybe [Processor])
     (Maybe [Processor])
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 [Processor] [Processor] [Processor] [Processor]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ProcessingConfiguration where
  parseJSON :: Value -> Parser ProcessingConfiguration
parseJSON =
    String
-> (Object -> Parser ProcessingConfiguration)
-> Value
-> Parser ProcessingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessingConfiguration"
      ( \Object
x ->
          Maybe Bool -> Maybe [Processor] -> ProcessingConfiguration
ProcessingConfiguration'
            (Maybe Bool -> Maybe [Processor] -> ProcessingConfiguration)
-> Parser (Maybe Bool)
-> Parser (Maybe [Processor] -> ProcessingConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser (Maybe [Processor] -> ProcessingConfiguration)
-> Parser (Maybe [Processor]) -> Parser ProcessingConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Processor]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Processors" Parser (Maybe (Maybe [Processor]))
-> Maybe [Processor] -> Parser (Maybe [Processor])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Processor]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ProcessingConfiguration

instance Prelude.NFData ProcessingConfiguration

instance Core.ToJSON ProcessingConfiguration where
  toJSON :: ProcessingConfiguration -> Value
toJSON ProcessingConfiguration' {Maybe Bool
Maybe [Processor]
processors :: Maybe [Processor]
enabled :: Maybe Bool
$sel:processors:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe [Processor]
$sel:enabled:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"Processors" Text -> [Processor] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Processor] -> Pair) -> Maybe [Processor] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Processor]
processors
          ]
      )