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

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.Deserializer
import qualified Amazonka.Lens as Lens
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
(InputFormatConfiguration -> InputFormatConfiguration -> Bool)
-> (InputFormatConfiguration -> InputFormatConfiguration -> Bool)
-> Eq InputFormatConfiguration
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]
(Int -> ReadS InputFormatConfiguration)
-> ReadS [InputFormatConfiguration]
-> ReadPrec InputFormatConfiguration
-> ReadPrec [InputFormatConfiguration]
-> Read 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
(Int -> InputFormatConfiguration -> ShowS)
-> (InputFormatConfiguration -> String)
-> ([InputFormatConfiguration] -> ShowS)
-> Show InputFormatConfiguration
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.
 InputFormatConfiguration -> Rep InputFormatConfiguration x)
-> (forall x.
    Rep InputFormatConfiguration x -> InputFormatConfiguration)
-> Generic InputFormatConfiguration
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' :: Maybe Deserializer -> InputFormatConfiguration
InputFormatConfiguration'
    { $sel:deserializer:InputFormatConfiguration' :: Maybe Deserializer
deserializer =
        Maybe 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 :: (Maybe Deserializer -> f (Maybe Deserializer))
-> InputFormatConfiguration -> f InputFormatConfiguration
inputFormatConfiguration_deserializer = (InputFormatConfiguration -> Maybe Deserializer)
-> (InputFormatConfiguration
    -> Maybe Deserializer -> InputFormatConfiguration)
-> Lens
     InputFormatConfiguration
     InputFormatConfiguration
     (Maybe Deserializer)
     (Maybe 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 Core.FromJSON InputFormatConfiguration where
  parseJSON :: Value -> Parser InputFormatConfiguration
parseJSON =
    String
-> (Object -> Parser InputFormatConfiguration)
-> Value
-> Parser InputFormatConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputFormatConfiguration"
      ( \Object
x ->
          Maybe Deserializer -> InputFormatConfiguration
InputFormatConfiguration'
            (Maybe Deserializer -> InputFormatConfiguration)
-> Parser (Maybe Deserializer) -> Parser InputFormatConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Deserializer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Deserializer")
      )

instance Prelude.Hashable InputFormatConfiguration

instance Prelude.NFData InputFormatConfiguration

instance Core.ToJSON InputFormatConfiguration where
  toJSON :: InputFormatConfiguration -> Value
toJSON InputFormatConfiguration' {Maybe Deserializer
deserializer :: Maybe Deserializer
$sel:deserializer:InputFormatConfiguration' :: InputFormatConfiguration -> Maybe Deserializer
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Deserializer" Text -> Deserializer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Deserializer -> Pair) -> Maybe Deserializer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Deserializer
deserializer]
      )