{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Firehose.Types.ProcessingConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Firehose.Types.Processor
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
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]
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
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. 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'
    { $sel:enabled:ProcessingConfiguration' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
      $sel:processors:ProcessingConfiguration' :: Maybe [Processor]
processors = forall a. Maybe a
Prelude.Nothing
    }

-- | Enables or disables data processing.
processingConfiguration_enabled :: Lens.Lens' ProcessingConfiguration (Prelude.Maybe Prelude.Bool)
processingConfiguration_enabled :: Lens' ProcessingConfiguration (Maybe Bool)
processingConfiguration_enabled = 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 :: Lens' ProcessingConfiguration (Maybe [Processor])
processingConfiguration_processors = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ProcessingConfiguration where
  hashWithSalt :: Int -> ProcessingConfiguration -> Int
hashWithSalt Int
_salt ProcessingConfiguration' {Maybe Bool
Maybe [Processor]
processors :: Maybe [Processor]
enabled :: Maybe Bool
$sel:processors:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe [Processor]
$sel:enabled:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Processor]
processors

instance Prelude.NFData ProcessingConfiguration where
  rnf :: ProcessingConfiguration -> ()
rnf ProcessingConfiguration' {Maybe Bool
Maybe [Processor]
processors :: Maybe [Processor]
enabled :: Maybe Bool
$sel:processors:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe [Processor]
$sel:enabled:ProcessingConfiguration' :: ProcessingConfiguration -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Processor]
processors

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Key
"Processors" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Processor]
processors
          ]
      )