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

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.OrcSerDe
import Amazonka.Firehose.Types.ParquetSerDe
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The serializer that you want Kinesis Data Firehose to use to convert
-- data to the target format before writing it to Amazon S3. Kinesis Data
-- Firehose supports two types of serializers: the
-- <https://hive.apache.org/javadocs/r1.2.2/api/org/apache/hadoop/hive/ql/io/orc/OrcSerde.html ORC SerDe>
-- and the
-- <https://hive.apache.org/javadocs/r1.2.2/api/org/apache/hadoop/hive/ql/io/parquet/serde/ParquetHiveSerDe.html Parquet SerDe>.
--
-- /See:/ 'newSerializer' smart constructor.
data Serializer = Serializer'
  { -- | A serializer to use for converting data to the ORC format before storing
    -- it in Amazon S3. For more information, see
    -- <https://orc.apache.org/docs/ Apache ORC>.
    Serializer -> Maybe OrcSerDe
orcSerDe :: Prelude.Maybe OrcSerDe,
    -- | A serializer to use for converting data to the Parquet format before
    -- storing it in Amazon S3. For more information, see
    -- <https://parquet.apache.org/documentation/latest/ Apache Parquet>.
    Serializer -> Maybe ParquetSerDe
parquetSerDe :: Prelude.Maybe ParquetSerDe
  }
  deriving (Serializer -> Serializer -> Bool
(Serializer -> Serializer -> Bool)
-> (Serializer -> Serializer -> Bool) -> Eq Serializer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Serializer -> Serializer -> Bool
$c/= :: Serializer -> Serializer -> Bool
== :: Serializer -> Serializer -> Bool
$c== :: Serializer -> Serializer -> Bool
Prelude.Eq, ReadPrec [Serializer]
ReadPrec Serializer
Int -> ReadS Serializer
ReadS [Serializer]
(Int -> ReadS Serializer)
-> ReadS [Serializer]
-> ReadPrec Serializer
-> ReadPrec [Serializer]
-> Read Serializer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Serializer]
$creadListPrec :: ReadPrec [Serializer]
readPrec :: ReadPrec Serializer
$creadPrec :: ReadPrec Serializer
readList :: ReadS [Serializer]
$creadList :: ReadS [Serializer]
readsPrec :: Int -> ReadS Serializer
$creadsPrec :: Int -> ReadS Serializer
Prelude.Read, Int -> Serializer -> ShowS
[Serializer] -> ShowS
Serializer -> String
(Int -> Serializer -> ShowS)
-> (Serializer -> String)
-> ([Serializer] -> ShowS)
-> Show Serializer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Serializer] -> ShowS
$cshowList :: [Serializer] -> ShowS
show :: Serializer -> String
$cshow :: Serializer -> String
showsPrec :: Int -> Serializer -> ShowS
$cshowsPrec :: Int -> Serializer -> ShowS
Prelude.Show, (forall x. Serializer -> Rep Serializer x)
-> (forall x. Rep Serializer x -> Serializer) -> Generic Serializer
forall x. Rep Serializer x -> Serializer
forall x. Serializer -> Rep Serializer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Serializer x -> Serializer
$cfrom :: forall x. Serializer -> Rep Serializer x
Prelude.Generic)

-- |
-- Create a value of 'Serializer' 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:
--
-- 'orcSerDe', 'serializer_orcSerDe' - A serializer to use for converting data to the ORC format before storing
-- it in Amazon S3. For more information, see
-- <https://orc.apache.org/docs/ Apache ORC>.
--
-- 'parquetSerDe', 'serializer_parquetSerDe' - A serializer to use for converting data to the Parquet format before
-- storing it in Amazon S3. For more information, see
-- <https://parquet.apache.org/documentation/latest/ Apache Parquet>.
newSerializer ::
  Serializer
newSerializer :: Serializer
newSerializer =
  Serializer' :: Maybe OrcSerDe -> Maybe ParquetSerDe -> Serializer
Serializer'
    { $sel:orcSerDe:Serializer' :: Maybe OrcSerDe
orcSerDe = Maybe OrcSerDe
forall a. Maybe a
Prelude.Nothing,
      $sel:parquetSerDe:Serializer' :: Maybe ParquetSerDe
parquetSerDe = Maybe ParquetSerDe
forall a. Maybe a
Prelude.Nothing
    }

-- | A serializer to use for converting data to the ORC format before storing
-- it in Amazon S3. For more information, see
-- <https://orc.apache.org/docs/ Apache ORC>.
serializer_orcSerDe :: Lens.Lens' Serializer (Prelude.Maybe OrcSerDe)
serializer_orcSerDe :: (Maybe OrcSerDe -> f (Maybe OrcSerDe))
-> Serializer -> f Serializer
serializer_orcSerDe = (Serializer -> Maybe OrcSerDe)
-> (Serializer -> Maybe OrcSerDe -> Serializer)
-> Lens Serializer Serializer (Maybe OrcSerDe) (Maybe OrcSerDe)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Serializer' {Maybe OrcSerDe
orcSerDe :: Maybe OrcSerDe
$sel:orcSerDe:Serializer' :: Serializer -> Maybe OrcSerDe
orcSerDe} -> Maybe OrcSerDe
orcSerDe) (\s :: Serializer
s@Serializer' {} Maybe OrcSerDe
a -> Serializer
s {$sel:orcSerDe:Serializer' :: Maybe OrcSerDe
orcSerDe = Maybe OrcSerDe
a} :: Serializer)

-- | A serializer to use for converting data to the Parquet format before
-- storing it in Amazon S3. For more information, see
-- <https://parquet.apache.org/documentation/latest/ Apache Parquet>.
serializer_parquetSerDe :: Lens.Lens' Serializer (Prelude.Maybe ParquetSerDe)
serializer_parquetSerDe :: (Maybe ParquetSerDe -> f (Maybe ParquetSerDe))
-> Serializer -> f Serializer
serializer_parquetSerDe = (Serializer -> Maybe ParquetSerDe)
-> (Serializer -> Maybe ParquetSerDe -> Serializer)
-> Lens
     Serializer Serializer (Maybe ParquetSerDe) (Maybe ParquetSerDe)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Serializer' {Maybe ParquetSerDe
parquetSerDe :: Maybe ParquetSerDe
$sel:parquetSerDe:Serializer' :: Serializer -> Maybe ParquetSerDe
parquetSerDe} -> Maybe ParquetSerDe
parquetSerDe) (\s :: Serializer
s@Serializer' {} Maybe ParquetSerDe
a -> Serializer
s {$sel:parquetSerDe:Serializer' :: Maybe ParquetSerDe
parquetSerDe = Maybe ParquetSerDe
a} :: Serializer)

instance Core.FromJSON Serializer where
  parseJSON :: Value -> Parser Serializer
parseJSON =
    String
-> (Object -> Parser Serializer) -> Value -> Parser Serializer
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Serializer"
      ( \Object
x ->
          Maybe OrcSerDe -> Maybe ParquetSerDe -> Serializer
Serializer'
            (Maybe OrcSerDe -> Maybe ParquetSerDe -> Serializer)
-> Parser (Maybe OrcSerDe)
-> Parser (Maybe ParquetSerDe -> Serializer)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe OrcSerDe)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OrcSerDe")
            Parser (Maybe ParquetSerDe -> Serializer)
-> Parser (Maybe ParquetSerDe) -> Parser Serializer
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ParquetSerDe)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParquetSerDe")
      )

instance Prelude.Hashable Serializer

instance Prelude.NFData Serializer

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