{-# 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-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.Processor 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.ProcessorParameter
import Amazonka.Firehose.Types.ProcessorType
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
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]
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
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. 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'
    { $sel:parameters:Processor' :: Maybe [ProcessorParameter]
parameters = 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 :: Lens' Processor (Maybe [ProcessorParameter])
processor_parameters = 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) 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

-- | The type of processor.
processor_type :: Lens.Lens' Processor ProcessorType
processor_type :: Lens' Processor ProcessorType
processor_type = 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 Data.FromJSON Processor where
  parseJSON :: Value -> Parser Processor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Processor"
      ( \Object
x ->
          Maybe [ProcessorParameter] -> ProcessorType -> Processor
Processor'
            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
"Parameters" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance Prelude.Hashable Processor where
  hashWithSalt :: Int -> Processor -> Int
hashWithSalt Int
_salt Processor' {Maybe [ProcessorParameter]
ProcessorType
type' :: ProcessorType
parameters :: Maybe [ProcessorParameter]
$sel:type':Processor' :: Processor -> ProcessorType
$sel:parameters:Processor' :: Processor -> Maybe [ProcessorParameter]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ProcessorParameter]
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ProcessorType
type'

instance Prelude.NFData Processor where
  rnf :: Processor -> ()
rnf Processor' {Maybe [ProcessorParameter]
ProcessorType
type' :: ProcessorType
parameters :: Maybe [ProcessorParameter]
$sel:type':Processor' :: Processor -> ProcessorType
$sel:parameters:Processor' :: Processor -> Maybe [ProcessorParameter]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ProcessorParameter]
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ProcessorType
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Parameters" 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 [ProcessorParameter]
parameters,
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ProcessorType
type')
          ]
      )