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

import qualified Amazonka.Core as Core
import Amazonka.Firehose.Types.InputFormatConfiguration
import Amazonka.Firehose.Types.OutputFormatConfiguration
import Amazonka.Firehose.Types.SchemaConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies that you want Kinesis Data Firehose to convert data from the
-- JSON format to the Parquet or ORC format before writing it to Amazon S3.
-- Kinesis Data Firehose uses the serializer and deserializer that you
-- specify, in addition to the column information from the AWS Glue table,
-- to deserialize your input data from JSON and then serialize it to the
-- Parquet or ORC format. For more information, see
-- <https://docs.aws.amazon.com/firehose/latest/dev/record-format-conversion.html Kinesis Data Firehose Record Format Conversion>.
--
-- /See:/ 'newDataFormatConversionConfiguration' smart constructor.
data DataFormatConversionConfiguration = DataFormatConversionConfiguration'
  { -- | Specifies the serializer that you want Kinesis Data Firehose to use to
    -- convert the format of your data to the Parquet or ORC format. This
    -- parameter is required if @Enabled@ is set to true.
    DataFormatConversionConfiguration
-> Maybe OutputFormatConfiguration
outputFormatConfiguration :: Prelude.Maybe OutputFormatConfiguration,
    -- | Defaults to @true@. Set it to @false@ if you want to disable format
    -- conversion while preserving the configuration details.
    DataFormatConversionConfiguration -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the AWS Glue Data Catalog table that contains the column
    -- information. This parameter is required if @Enabled@ is set to true.
    DataFormatConversionConfiguration -> Maybe SchemaConfiguration
schemaConfiguration :: Prelude.Maybe SchemaConfiguration,
    -- | Specifies the deserializer that you want Kinesis Data Firehose to use to
    -- convert the format of your data from JSON. This parameter is required if
    -- @Enabled@ is set to true.
    DataFormatConversionConfiguration -> Maybe InputFormatConfiguration
inputFormatConfiguration :: Prelude.Maybe InputFormatConfiguration
  }
  deriving (DataFormatConversionConfiguration
-> DataFormatConversionConfiguration -> Bool
(DataFormatConversionConfiguration
 -> DataFormatConversionConfiguration -> Bool)
-> (DataFormatConversionConfiguration
    -> DataFormatConversionConfiguration -> Bool)
-> Eq DataFormatConversionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataFormatConversionConfiguration
-> DataFormatConversionConfiguration -> Bool
$c/= :: DataFormatConversionConfiguration
-> DataFormatConversionConfiguration -> Bool
== :: DataFormatConversionConfiguration
-> DataFormatConversionConfiguration -> Bool
$c== :: DataFormatConversionConfiguration
-> DataFormatConversionConfiguration -> Bool
Prelude.Eq, ReadPrec [DataFormatConversionConfiguration]
ReadPrec DataFormatConversionConfiguration
Int -> ReadS DataFormatConversionConfiguration
ReadS [DataFormatConversionConfiguration]
(Int -> ReadS DataFormatConversionConfiguration)
-> ReadS [DataFormatConversionConfiguration]
-> ReadPrec DataFormatConversionConfiguration
-> ReadPrec [DataFormatConversionConfiguration]
-> Read DataFormatConversionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataFormatConversionConfiguration]
$creadListPrec :: ReadPrec [DataFormatConversionConfiguration]
readPrec :: ReadPrec DataFormatConversionConfiguration
$creadPrec :: ReadPrec DataFormatConversionConfiguration
readList :: ReadS [DataFormatConversionConfiguration]
$creadList :: ReadS [DataFormatConversionConfiguration]
readsPrec :: Int -> ReadS DataFormatConversionConfiguration
$creadsPrec :: Int -> ReadS DataFormatConversionConfiguration
Prelude.Read, Int -> DataFormatConversionConfiguration -> ShowS
[DataFormatConversionConfiguration] -> ShowS
DataFormatConversionConfiguration -> String
(Int -> DataFormatConversionConfiguration -> ShowS)
-> (DataFormatConversionConfiguration -> String)
-> ([DataFormatConversionConfiguration] -> ShowS)
-> Show DataFormatConversionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataFormatConversionConfiguration] -> ShowS
$cshowList :: [DataFormatConversionConfiguration] -> ShowS
show :: DataFormatConversionConfiguration -> String
$cshow :: DataFormatConversionConfiguration -> String
showsPrec :: Int -> DataFormatConversionConfiguration -> ShowS
$cshowsPrec :: Int -> DataFormatConversionConfiguration -> ShowS
Prelude.Show, (forall x.
 DataFormatConversionConfiguration
 -> Rep DataFormatConversionConfiguration x)
-> (forall x.
    Rep DataFormatConversionConfiguration x
    -> DataFormatConversionConfiguration)
-> Generic DataFormatConversionConfiguration
forall x.
Rep DataFormatConversionConfiguration x
-> DataFormatConversionConfiguration
forall x.
DataFormatConversionConfiguration
-> Rep DataFormatConversionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DataFormatConversionConfiguration x
-> DataFormatConversionConfiguration
$cfrom :: forall x.
DataFormatConversionConfiguration
-> Rep DataFormatConversionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DataFormatConversionConfiguration' 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:
--
-- 'outputFormatConfiguration', 'dataFormatConversionConfiguration_outputFormatConfiguration' - Specifies the serializer that you want Kinesis Data Firehose to use to
-- convert the format of your data to the Parquet or ORC format. This
-- parameter is required if @Enabled@ is set to true.
--
-- 'enabled', 'dataFormatConversionConfiguration_enabled' - Defaults to @true@. Set it to @false@ if you want to disable format
-- conversion while preserving the configuration details.
--
-- 'schemaConfiguration', 'dataFormatConversionConfiguration_schemaConfiguration' - Specifies the AWS Glue Data Catalog table that contains the column
-- information. This parameter is required if @Enabled@ is set to true.
--
-- 'inputFormatConfiguration', 'dataFormatConversionConfiguration_inputFormatConfiguration' - Specifies the deserializer that you want Kinesis Data Firehose to use to
-- convert the format of your data from JSON. This parameter is required if
-- @Enabled@ is set to true.
newDataFormatConversionConfiguration ::
  DataFormatConversionConfiguration
newDataFormatConversionConfiguration :: DataFormatConversionConfiguration
newDataFormatConversionConfiguration =
  DataFormatConversionConfiguration' :: Maybe OutputFormatConfiguration
-> Maybe Bool
-> Maybe SchemaConfiguration
-> Maybe InputFormatConfiguration
-> DataFormatConversionConfiguration
DataFormatConversionConfiguration'
    { $sel:outputFormatConfiguration:DataFormatConversionConfiguration' :: Maybe OutputFormatConfiguration
outputFormatConfiguration =
        Maybe OutputFormatConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:enabled:DataFormatConversionConfiguration' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:schemaConfiguration:DataFormatConversionConfiguration' :: Maybe SchemaConfiguration
schemaConfiguration = Maybe SchemaConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:inputFormatConfiguration:DataFormatConversionConfiguration' :: Maybe InputFormatConfiguration
inputFormatConfiguration =
        Maybe InputFormatConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the serializer that you want Kinesis Data Firehose to use to
-- convert the format of your data to the Parquet or ORC format. This
-- parameter is required if @Enabled@ is set to true.
dataFormatConversionConfiguration_outputFormatConfiguration :: Lens.Lens' DataFormatConversionConfiguration (Prelude.Maybe OutputFormatConfiguration)
dataFormatConversionConfiguration_outputFormatConfiguration :: (Maybe OutputFormatConfiguration
 -> f (Maybe OutputFormatConfiguration))
-> DataFormatConversionConfiguration
-> f DataFormatConversionConfiguration
dataFormatConversionConfiguration_outputFormatConfiguration = (DataFormatConversionConfiguration
 -> Maybe OutputFormatConfiguration)
-> (DataFormatConversionConfiguration
    -> Maybe OutputFormatConfiguration
    -> DataFormatConversionConfiguration)
-> Lens
     DataFormatConversionConfiguration
     DataFormatConversionConfiguration
     (Maybe OutputFormatConfiguration)
     (Maybe OutputFormatConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataFormatConversionConfiguration' {Maybe OutputFormatConfiguration
outputFormatConfiguration :: Maybe OutputFormatConfiguration
$sel:outputFormatConfiguration:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration
-> Maybe OutputFormatConfiguration
outputFormatConfiguration} -> Maybe OutputFormatConfiguration
outputFormatConfiguration) (\s :: DataFormatConversionConfiguration
s@DataFormatConversionConfiguration' {} Maybe OutputFormatConfiguration
a -> DataFormatConversionConfiguration
s {$sel:outputFormatConfiguration:DataFormatConversionConfiguration' :: Maybe OutputFormatConfiguration
outputFormatConfiguration = Maybe OutputFormatConfiguration
a} :: DataFormatConversionConfiguration)

-- | Defaults to @true@. Set it to @false@ if you want to disable format
-- conversion while preserving the configuration details.
dataFormatConversionConfiguration_enabled :: Lens.Lens' DataFormatConversionConfiguration (Prelude.Maybe Prelude.Bool)
dataFormatConversionConfiguration_enabled :: (Maybe Bool -> f (Maybe Bool))
-> DataFormatConversionConfiguration
-> f DataFormatConversionConfiguration
dataFormatConversionConfiguration_enabled = (DataFormatConversionConfiguration -> Maybe Bool)
-> (DataFormatConversionConfiguration
    -> Maybe Bool -> DataFormatConversionConfiguration)
-> Lens
     DataFormatConversionConfiguration
     DataFormatConversionConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataFormatConversionConfiguration' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: DataFormatConversionConfiguration
s@DataFormatConversionConfiguration' {} Maybe Bool
a -> DataFormatConversionConfiguration
s {$sel:enabled:DataFormatConversionConfiguration' :: Maybe Bool
enabled = Maybe Bool
a} :: DataFormatConversionConfiguration)

-- | Specifies the AWS Glue Data Catalog table that contains the column
-- information. This parameter is required if @Enabled@ is set to true.
dataFormatConversionConfiguration_schemaConfiguration :: Lens.Lens' DataFormatConversionConfiguration (Prelude.Maybe SchemaConfiguration)
dataFormatConversionConfiguration_schemaConfiguration :: (Maybe SchemaConfiguration -> f (Maybe SchemaConfiguration))
-> DataFormatConversionConfiguration
-> f DataFormatConversionConfiguration
dataFormatConversionConfiguration_schemaConfiguration = (DataFormatConversionConfiguration -> Maybe SchemaConfiguration)
-> (DataFormatConversionConfiguration
    -> Maybe SchemaConfiguration -> DataFormatConversionConfiguration)
-> Lens
     DataFormatConversionConfiguration
     DataFormatConversionConfiguration
     (Maybe SchemaConfiguration)
     (Maybe SchemaConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataFormatConversionConfiguration' {Maybe SchemaConfiguration
schemaConfiguration :: Maybe SchemaConfiguration
$sel:schemaConfiguration:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration -> Maybe SchemaConfiguration
schemaConfiguration} -> Maybe SchemaConfiguration
schemaConfiguration) (\s :: DataFormatConversionConfiguration
s@DataFormatConversionConfiguration' {} Maybe SchemaConfiguration
a -> DataFormatConversionConfiguration
s {$sel:schemaConfiguration:DataFormatConversionConfiguration' :: Maybe SchemaConfiguration
schemaConfiguration = Maybe SchemaConfiguration
a} :: DataFormatConversionConfiguration)

-- | Specifies the deserializer that you want Kinesis Data Firehose to use to
-- convert the format of your data from JSON. This parameter is required if
-- @Enabled@ is set to true.
dataFormatConversionConfiguration_inputFormatConfiguration :: Lens.Lens' DataFormatConversionConfiguration (Prelude.Maybe InputFormatConfiguration)
dataFormatConversionConfiguration_inputFormatConfiguration :: (Maybe InputFormatConfiguration
 -> f (Maybe InputFormatConfiguration))
-> DataFormatConversionConfiguration
-> f DataFormatConversionConfiguration
dataFormatConversionConfiguration_inputFormatConfiguration = (DataFormatConversionConfiguration
 -> Maybe InputFormatConfiguration)
-> (DataFormatConversionConfiguration
    -> Maybe InputFormatConfiguration
    -> DataFormatConversionConfiguration)
-> Lens
     DataFormatConversionConfiguration
     DataFormatConversionConfiguration
     (Maybe InputFormatConfiguration)
     (Maybe InputFormatConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataFormatConversionConfiguration' {Maybe InputFormatConfiguration
inputFormatConfiguration :: Maybe InputFormatConfiguration
$sel:inputFormatConfiguration:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration -> Maybe InputFormatConfiguration
inputFormatConfiguration} -> Maybe InputFormatConfiguration
inputFormatConfiguration) (\s :: DataFormatConversionConfiguration
s@DataFormatConversionConfiguration' {} Maybe InputFormatConfiguration
a -> DataFormatConversionConfiguration
s {$sel:inputFormatConfiguration:DataFormatConversionConfiguration' :: Maybe InputFormatConfiguration
inputFormatConfiguration = Maybe InputFormatConfiguration
a} :: DataFormatConversionConfiguration)

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

instance
  Prelude.Hashable
    DataFormatConversionConfiguration

instance
  Prelude.NFData
    DataFormatConversionConfiguration

instance
  Core.ToJSON
    DataFormatConversionConfiguration
  where
  toJSON :: DataFormatConversionConfiguration -> Value
toJSON DataFormatConversionConfiguration' {Maybe Bool
Maybe InputFormatConfiguration
Maybe SchemaConfiguration
Maybe OutputFormatConfiguration
inputFormatConfiguration :: Maybe InputFormatConfiguration
schemaConfiguration :: Maybe SchemaConfiguration
enabled :: Maybe Bool
outputFormatConfiguration :: Maybe OutputFormatConfiguration
$sel:inputFormatConfiguration:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration -> Maybe InputFormatConfiguration
$sel:schemaConfiguration:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration -> Maybe SchemaConfiguration
$sel:enabled:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration -> Maybe Bool
$sel:outputFormatConfiguration:DataFormatConversionConfiguration' :: DataFormatConversionConfiguration
-> Maybe OutputFormatConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OutputFormatConfiguration" Text -> OutputFormatConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OutputFormatConfiguration -> Pair)
-> Maybe OutputFormatConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OutputFormatConfiguration
outputFormatConfiguration,
            (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"SchemaConfiguration" Text -> SchemaConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SchemaConfiguration -> Pair)
-> Maybe SchemaConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SchemaConfiguration
schemaConfiguration,
            (Text
"InputFormatConfiguration" Text -> InputFormatConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InputFormatConfiguration -> Pair)
-> Maybe InputFormatConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputFormatConfiguration
inputFormatConfiguration
          ]
      )