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

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.Serializer
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the serializer that you want Kinesis Data Firehose to use to
-- convert the format of your data before it writes it to Amazon S3. This
-- parameter is required if @Enabled@ is set to true.
--
-- /See:/ 'newOutputFormatConfiguration' smart constructor.
data OutputFormatConfiguration = OutputFormatConfiguration'
  { -- | Specifies which serializer to use. You can choose either the ORC SerDe
    -- or the Parquet SerDe. If both are non-null, the server rejects the
    -- request.
    OutputFormatConfiguration -> Maybe Serializer
serializer :: Prelude.Maybe Serializer
  }
  deriving (OutputFormatConfiguration -> OutputFormatConfiguration -> Bool
(OutputFormatConfiguration -> OutputFormatConfiguration -> Bool)
-> (OutputFormatConfiguration -> OutputFormatConfiguration -> Bool)
-> Eq OutputFormatConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputFormatConfiguration -> OutputFormatConfiguration -> Bool
$c/= :: OutputFormatConfiguration -> OutputFormatConfiguration -> Bool
== :: OutputFormatConfiguration -> OutputFormatConfiguration -> Bool
$c== :: OutputFormatConfiguration -> OutputFormatConfiguration -> Bool
Prelude.Eq, ReadPrec [OutputFormatConfiguration]
ReadPrec OutputFormatConfiguration
Int -> ReadS OutputFormatConfiguration
ReadS [OutputFormatConfiguration]
(Int -> ReadS OutputFormatConfiguration)
-> ReadS [OutputFormatConfiguration]
-> ReadPrec OutputFormatConfiguration
-> ReadPrec [OutputFormatConfiguration]
-> Read OutputFormatConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputFormatConfiguration]
$creadListPrec :: ReadPrec [OutputFormatConfiguration]
readPrec :: ReadPrec OutputFormatConfiguration
$creadPrec :: ReadPrec OutputFormatConfiguration
readList :: ReadS [OutputFormatConfiguration]
$creadList :: ReadS [OutputFormatConfiguration]
readsPrec :: Int -> ReadS OutputFormatConfiguration
$creadsPrec :: Int -> ReadS OutputFormatConfiguration
Prelude.Read, Int -> OutputFormatConfiguration -> ShowS
[OutputFormatConfiguration] -> ShowS
OutputFormatConfiguration -> String
(Int -> OutputFormatConfiguration -> ShowS)
-> (OutputFormatConfiguration -> String)
-> ([OutputFormatConfiguration] -> ShowS)
-> Show OutputFormatConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputFormatConfiguration] -> ShowS
$cshowList :: [OutputFormatConfiguration] -> ShowS
show :: OutputFormatConfiguration -> String
$cshow :: OutputFormatConfiguration -> String
showsPrec :: Int -> OutputFormatConfiguration -> ShowS
$cshowsPrec :: Int -> OutputFormatConfiguration -> ShowS
Prelude.Show, (forall x.
 OutputFormatConfiguration -> Rep OutputFormatConfiguration x)
-> (forall x.
    Rep OutputFormatConfiguration x -> OutputFormatConfiguration)
-> Generic OutputFormatConfiguration
forall x.
Rep OutputFormatConfiguration x -> OutputFormatConfiguration
forall x.
OutputFormatConfiguration -> Rep OutputFormatConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OutputFormatConfiguration x -> OutputFormatConfiguration
$cfrom :: forall x.
OutputFormatConfiguration -> Rep OutputFormatConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'OutputFormatConfiguration' 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:
--
-- 'serializer', 'outputFormatConfiguration_serializer' - Specifies which serializer to use. You can choose either the ORC SerDe
-- or the Parquet SerDe. If both are non-null, the server rejects the
-- request.
newOutputFormatConfiguration ::
  OutputFormatConfiguration
newOutputFormatConfiguration :: OutputFormatConfiguration
newOutputFormatConfiguration =
  OutputFormatConfiguration' :: Maybe Serializer -> OutputFormatConfiguration
OutputFormatConfiguration'
    { $sel:serializer:OutputFormatConfiguration' :: Maybe Serializer
serializer =
        Maybe Serializer
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies which serializer to use. You can choose either the ORC SerDe
-- or the Parquet SerDe. If both are non-null, the server rejects the
-- request.
outputFormatConfiguration_serializer :: Lens.Lens' OutputFormatConfiguration (Prelude.Maybe Serializer)
outputFormatConfiguration_serializer :: (Maybe Serializer -> f (Maybe Serializer))
-> OutputFormatConfiguration -> f OutputFormatConfiguration
outputFormatConfiguration_serializer = (OutputFormatConfiguration -> Maybe Serializer)
-> (OutputFormatConfiguration
    -> Maybe Serializer -> OutputFormatConfiguration)
-> Lens
     OutputFormatConfiguration
     OutputFormatConfiguration
     (Maybe Serializer)
     (Maybe Serializer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputFormatConfiguration' {Maybe Serializer
serializer :: Maybe Serializer
$sel:serializer:OutputFormatConfiguration' :: OutputFormatConfiguration -> Maybe Serializer
serializer} -> Maybe Serializer
serializer) (\s :: OutputFormatConfiguration
s@OutputFormatConfiguration' {} Maybe Serializer
a -> OutputFormatConfiguration
s {$sel:serializer:OutputFormatConfiguration' :: Maybe Serializer
serializer = Maybe Serializer
a} :: OutputFormatConfiguration)

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

instance Prelude.Hashable OutputFormatConfiguration

instance Prelude.NFData OutputFormatConfiguration

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