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

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.ProcessorParameter
import Amazonka.Firehose.Types.ProcessorType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a data processor.
--
-- /See:/ 'newProcessor' smart constructor.
data Processor = Processor'
  { -- | The processor parameters.
    Processor -> Maybe [ProcessorParameter]
parameters :: Prelude.Maybe [ProcessorParameter],
    -- | The type of processor.
    Processor -> ProcessorType
type' :: ProcessorType
  }
  deriving (Processor -> Processor -> Bool
(Processor -> Processor -> Bool)
-> (Processor -> Processor -> Bool) -> Eq Processor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Processor -> Processor -> Bool
$c/= :: Processor -> Processor -> Bool
== :: Processor -> Processor -> Bool
$c== :: Processor -> Processor -> Bool
Prelude.Eq, ReadPrec [Processor]
ReadPrec Processor
Int -> ReadS Processor
ReadS [Processor]
(Int -> ReadS Processor)
-> ReadS [Processor]
-> ReadPrec Processor
-> ReadPrec [Processor]
-> Read Processor
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Processor]
$creadListPrec :: ReadPrec [Processor]
readPrec :: ReadPrec Processor
$creadPrec :: ReadPrec Processor
readList :: ReadS [Processor]
$creadList :: ReadS [Processor]
readsPrec :: Int -> ReadS Processor
$creadsPrec :: Int -> ReadS Processor
Prelude.Read, Int -> Processor -> ShowS
[Processor] -> ShowS
Processor -> String
(Int -> Processor -> ShowS)
-> (Processor -> String)
-> ([Processor] -> ShowS)
-> Show Processor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Processor] -> ShowS
$cshowList :: [Processor] -> ShowS
show :: Processor -> String
$cshow :: Processor -> String
showsPrec :: Int -> Processor -> ShowS
$cshowsPrec :: Int -> Processor -> ShowS
Prelude.Show, (forall x. Processor -> Rep Processor x)
-> (forall x. Rep Processor x -> Processor) -> Generic Processor
forall x. Rep Processor x -> Processor
forall x. Processor -> Rep Processor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Processor x -> Processor
$cfrom :: forall x. Processor -> Rep Processor x
Prelude.Generic)

-- |
-- Create a value of 'Processor' 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:
--
-- 'parameters', 'processor_parameters' - The processor parameters.
--
-- 'type'', 'processor_type' - The type of processor.
newProcessor ::
  -- | 'type''
  ProcessorType ->
  Processor
newProcessor :: ProcessorType -> Processor
newProcessor ProcessorType
pType_ =
  Processor' :: Maybe [ProcessorParameter] -> ProcessorType -> Processor
Processor'
    { $sel:parameters:Processor' :: Maybe [ProcessorParameter]
parameters = Maybe [ProcessorParameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Processor' :: ProcessorType
type' = ProcessorType
pType_
    }

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

-- | The type of processor.
processor_type :: Lens.Lens' Processor ProcessorType
processor_type :: (ProcessorType -> f ProcessorType) -> Processor -> f Processor
processor_type = (Processor -> ProcessorType)
-> (Processor -> ProcessorType -> Processor)
-> Lens Processor Processor ProcessorType ProcessorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Processor' {ProcessorType
type' :: ProcessorType
$sel:type':Processor' :: Processor -> ProcessorType
type'} -> ProcessorType
type') (\s :: Processor
s@Processor' {} ProcessorType
a -> Processor
s {$sel:type':Processor' :: ProcessorType
type' = ProcessorType
a} :: Processor)

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

instance Prelude.Hashable Processor

instance Prelude.NFData Processor

instance Core.ToJSON Processor where
  toJSON :: Processor -> Value
toJSON Processor' {Maybe [ProcessorParameter]
ProcessorType
type' :: ProcessorType
parameters :: Maybe [ProcessorParameter]
$sel:type':Processor' :: Processor -> ProcessorType
$sel:parameters:Processor' :: Processor -> Maybe [ProcessorParameter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Parameters" Text -> [ProcessorParameter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ProcessorParameter] -> Pair)
-> Maybe [ProcessorParameter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ProcessorParameter]
parameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ProcessorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ProcessorType
type')
          ]
      )