{-# 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.IoTAnalytics.Types.FileFormatConfiguration
-- 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.IoTAnalytics.Types.FileFormatConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTAnalytics.Types.JsonConfiguration
import Amazonka.IoTAnalytics.Types.ParquetConfiguration
import qualified Amazonka.Prelude as Prelude

-- | Contains the configuration information of file formats. IoT Analytics
-- data stores support JSON and <https://parquet.apache.org/ Parquet>.
--
-- The default file format is JSON. You can specify only one format.
--
-- You can\'t change the file format after you create the data store.
--
-- /See:/ 'newFileFormatConfiguration' smart constructor.
data FileFormatConfiguration = FileFormatConfiguration'
  { -- | Contains the configuration information of the JSON format.
    FileFormatConfiguration -> Maybe JsonConfiguration
jsonConfiguration :: Prelude.Maybe JsonConfiguration,
    -- | Contains the configuration information of the Parquet format.
    FileFormatConfiguration -> Maybe ParquetConfiguration
parquetConfiguration :: Prelude.Maybe ParquetConfiguration
  }
  deriving (FileFormatConfiguration -> FileFormatConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileFormatConfiguration -> FileFormatConfiguration -> Bool
$c/= :: FileFormatConfiguration -> FileFormatConfiguration -> Bool
== :: FileFormatConfiguration -> FileFormatConfiguration -> Bool
$c== :: FileFormatConfiguration -> FileFormatConfiguration -> Bool
Prelude.Eq, ReadPrec [FileFormatConfiguration]
ReadPrec FileFormatConfiguration
Int -> ReadS FileFormatConfiguration
ReadS [FileFormatConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FileFormatConfiguration]
$creadListPrec :: ReadPrec [FileFormatConfiguration]
readPrec :: ReadPrec FileFormatConfiguration
$creadPrec :: ReadPrec FileFormatConfiguration
readList :: ReadS [FileFormatConfiguration]
$creadList :: ReadS [FileFormatConfiguration]
readsPrec :: Int -> ReadS FileFormatConfiguration
$creadsPrec :: Int -> ReadS FileFormatConfiguration
Prelude.Read, Int -> FileFormatConfiguration -> ShowS
[FileFormatConfiguration] -> ShowS
FileFormatConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FileFormatConfiguration] -> ShowS
$cshowList :: [FileFormatConfiguration] -> ShowS
show :: FileFormatConfiguration -> String
$cshow :: FileFormatConfiguration -> String
showsPrec :: Int -> FileFormatConfiguration -> ShowS
$cshowsPrec :: Int -> FileFormatConfiguration -> ShowS
Prelude.Show, forall x. Rep FileFormatConfiguration x -> FileFormatConfiguration
forall x. FileFormatConfiguration -> Rep FileFormatConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FileFormatConfiguration x -> FileFormatConfiguration
$cfrom :: forall x. FileFormatConfiguration -> Rep FileFormatConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'FileFormatConfiguration' 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:
--
-- 'jsonConfiguration', 'fileFormatConfiguration_jsonConfiguration' - Contains the configuration information of the JSON format.
--
-- 'parquetConfiguration', 'fileFormatConfiguration_parquetConfiguration' - Contains the configuration information of the Parquet format.
newFileFormatConfiguration ::
  FileFormatConfiguration
newFileFormatConfiguration :: FileFormatConfiguration
newFileFormatConfiguration =
  FileFormatConfiguration'
    { $sel:jsonConfiguration:FileFormatConfiguration' :: Maybe JsonConfiguration
jsonConfiguration =
        forall a. Maybe a
Prelude.Nothing,
      $sel:parquetConfiguration:FileFormatConfiguration' :: Maybe ParquetConfiguration
parquetConfiguration = forall a. Maybe a
Prelude.Nothing
    }

-- | Contains the configuration information of the JSON format.
fileFormatConfiguration_jsonConfiguration :: Lens.Lens' FileFormatConfiguration (Prelude.Maybe JsonConfiguration)
fileFormatConfiguration_jsonConfiguration :: Lens' FileFormatConfiguration (Maybe JsonConfiguration)
fileFormatConfiguration_jsonConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileFormatConfiguration' {Maybe JsonConfiguration
jsonConfiguration :: Maybe JsonConfiguration
$sel:jsonConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe JsonConfiguration
jsonConfiguration} -> Maybe JsonConfiguration
jsonConfiguration) (\s :: FileFormatConfiguration
s@FileFormatConfiguration' {} Maybe JsonConfiguration
a -> FileFormatConfiguration
s {$sel:jsonConfiguration:FileFormatConfiguration' :: Maybe JsonConfiguration
jsonConfiguration = Maybe JsonConfiguration
a} :: FileFormatConfiguration)

-- | Contains the configuration information of the Parquet format.
fileFormatConfiguration_parquetConfiguration :: Lens.Lens' FileFormatConfiguration (Prelude.Maybe ParquetConfiguration)
fileFormatConfiguration_parquetConfiguration :: Lens' FileFormatConfiguration (Maybe ParquetConfiguration)
fileFormatConfiguration_parquetConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FileFormatConfiguration' {Maybe ParquetConfiguration
parquetConfiguration :: Maybe ParquetConfiguration
$sel:parquetConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe ParquetConfiguration
parquetConfiguration} -> Maybe ParquetConfiguration
parquetConfiguration) (\s :: FileFormatConfiguration
s@FileFormatConfiguration' {} Maybe ParquetConfiguration
a -> FileFormatConfiguration
s {$sel:parquetConfiguration:FileFormatConfiguration' :: Maybe ParquetConfiguration
parquetConfiguration = Maybe ParquetConfiguration
a} :: FileFormatConfiguration)

instance Data.FromJSON FileFormatConfiguration where
  parseJSON :: Value -> Parser FileFormatConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FileFormatConfiguration"
      ( \Object
x ->
          Maybe JsonConfiguration
-> Maybe ParquetConfiguration -> FileFormatConfiguration
FileFormatConfiguration'
            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
"jsonConfiguration")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"parquetConfiguration")
      )

instance Prelude.Hashable FileFormatConfiguration where
  hashWithSalt :: Int -> FileFormatConfiguration -> Int
hashWithSalt Int
_salt FileFormatConfiguration' {Maybe JsonConfiguration
Maybe ParquetConfiguration
parquetConfiguration :: Maybe ParquetConfiguration
jsonConfiguration :: Maybe JsonConfiguration
$sel:parquetConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe ParquetConfiguration
$sel:jsonConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe JsonConfiguration
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JsonConfiguration
jsonConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ParquetConfiguration
parquetConfiguration

instance Prelude.NFData FileFormatConfiguration where
  rnf :: FileFormatConfiguration -> ()
rnf FileFormatConfiguration' {Maybe JsonConfiguration
Maybe ParquetConfiguration
parquetConfiguration :: Maybe ParquetConfiguration
jsonConfiguration :: Maybe JsonConfiguration
$sel:parquetConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe ParquetConfiguration
$sel:jsonConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe JsonConfiguration
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe JsonConfiguration
jsonConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ParquetConfiguration
parquetConfiguration

instance Data.ToJSON FileFormatConfiguration where
  toJSON :: FileFormatConfiguration -> Value
toJSON FileFormatConfiguration' {Maybe JsonConfiguration
Maybe ParquetConfiguration
parquetConfiguration :: Maybe ParquetConfiguration
jsonConfiguration :: Maybe JsonConfiguration
$sel:parquetConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe ParquetConfiguration
$sel:jsonConfiguration:FileFormatConfiguration' :: FileFormatConfiguration -> Maybe JsonConfiguration
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"jsonConfiguration" 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 JsonConfiguration
jsonConfiguration,
            (Key
"parquetConfiguration" 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 ParquetConfiguration
parquetConfiguration
          ]
      )