{-# 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.InputFormatConfiguration
-- 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.InputFormatConfiguration 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.Deserializer
import qualified Amazonka.Prelude as Prelude

-- | Specifies the deserializer you want to use to convert the format of the
-- input data. This parameter is required if @Enabled@ is set to true.
--
-- /See:/ 'newInputFormatConfiguration' smart constructor.
data InputFormatConfiguration = InputFormatConfiguration'
  { -- | Specifies which deserializer to use. You can choose either the Apache
    -- Hive JSON SerDe or the OpenX JSON SerDe. If both are non-null, the
    -- server rejects the request.
    InputFormatConfiguration -> Maybe Deserializer
deserializer :: Prelude.Maybe Deserializer
  }
  deriving (InputFormatConfiguration -> InputFormatConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputFormatConfiguration -> InputFormatConfiguration -> Bool
$c/= :: InputFormatConfiguration -> InputFormatConfiguration -> Bool
== :: InputFormatConfiguration -> InputFormatConfiguration -> Bool
$c== :: InputFormatConfiguration -> InputFormatConfiguration -> Bool
Prelude.Eq, ReadPrec [InputFormatConfiguration]
ReadPrec InputFormatConfiguration
Int -> ReadS InputFormatConfiguration
ReadS [InputFormatConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputFormatConfiguration]
$creadListPrec :: ReadPrec [InputFormatConfiguration]
readPrec :: ReadPrec InputFormatConfiguration
$creadPrec :: ReadPrec InputFormatConfiguration
readList :: ReadS [InputFormatConfiguration]
$creadList :: ReadS [InputFormatConfiguration]
readsPrec :: Int -> ReadS InputFormatConfiguration
$creadsPrec :: Int -> ReadS InputFormatConfiguration
Prelude.Read, Int -> InputFormatConfiguration -> ShowS
[InputFormatConfiguration] -> ShowS
InputFormatConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputFormatConfiguration] -> ShowS
$cshowList :: [InputFormatConfiguration] -> ShowS
show :: InputFormatConfiguration -> String
$cshow :: InputFormatConfiguration -> String
showsPrec :: Int -> InputFormatConfiguration -> ShowS
$cshowsPrec :: Int -> InputFormatConfiguration -> ShowS
Prelude.Show, forall x.
Rep InputFormatConfiguration x -> InputFormatConfiguration
forall x.
InputFormatConfiguration -> Rep InputFormatConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InputFormatConfiguration x -> InputFormatConfiguration
$cfrom :: forall x.
InputFormatConfiguration -> Rep InputFormatConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'InputFormatConfiguration' 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:
--
-- 'deserializer', 'inputFormatConfiguration_deserializer' - Specifies which deserializer to use. You can choose either the Apache
-- Hive JSON SerDe or the OpenX JSON SerDe. If both are non-null, the
-- server rejects the request.
newInputFormatConfiguration ::
  InputFormatConfiguration
newInputFormatConfiguration :: InputFormatConfiguration
newInputFormatConfiguration =
  InputFormatConfiguration'
    { $sel:deserializer:InputFormatConfiguration' :: Maybe Deserializer
deserializer =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies which deserializer to use. You can choose either the Apache
-- Hive JSON SerDe or the OpenX JSON SerDe. If both are non-null, the
-- server rejects the request.
inputFormatConfiguration_deserializer :: Lens.Lens' InputFormatConfiguration (Prelude.Maybe Deserializer)
inputFormatConfiguration_deserializer :: Lens' InputFormatConfiguration (Maybe Deserializer)
inputFormatConfiguration_deserializer = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputFormatConfiguration' {Maybe Deserializer
deserializer :: Maybe Deserializer
$sel:deserializer:InputFormatConfiguration' :: InputFormatConfiguration -> Maybe Deserializer
deserializer} -> Maybe Deserializer
deserializer) (\s :: InputFormatConfiguration
s@InputFormatConfiguration' {} Maybe Deserializer
a -> InputFormatConfiguration
s {$sel:deserializer:InputFormatConfiguration' :: Maybe Deserializer
deserializer = Maybe Deserializer
a} :: InputFormatConfiguration)

instance Data.FromJSON InputFormatConfiguration where
  parseJSON :: Value -> Parser InputFormatConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputFormatConfiguration"
      ( \Object
x ->
          Maybe Deserializer -> InputFormatConfiguration
InputFormatConfiguration'
            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
"Deserializer")
      )

instance Prelude.Hashable InputFormatConfiguration where
  hashWithSalt :: Int -> InputFormatConfiguration -> Int
hashWithSalt Int
_salt InputFormatConfiguration' {Maybe Deserializer
deserializer :: Maybe Deserializer
$sel:deserializer:InputFormatConfiguration' :: InputFormatConfiguration -> Maybe Deserializer
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Deserializer
deserializer

instance Prelude.NFData InputFormatConfiguration where
  rnf :: InputFormatConfiguration -> ()
rnf InputFormatConfiguration' {Maybe Deserializer
deserializer :: Maybe Deserializer
$sel:deserializer:InputFormatConfiguration' :: InputFormatConfiguration -> Maybe Deserializer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Deserializer
deserializer

instance Data.ToJSON InputFormatConfiguration where
  toJSON :: InputFormatConfiguration -> Value
toJSON InputFormatConfiguration' {Maybe Deserializer
deserializer :: Maybe Deserializer
$sel:deserializer:InputFormatConfiguration' :: InputFormatConfiguration -> Maybe Deserializer
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Deserializer" 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 Deserializer
deserializer]
      )