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

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.JsonConfiguration
import Amazonka.IoTAnalytics.Types.ParquetConfiguration
import qualified Amazonka.Lens as Lens
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
(FileFormatConfiguration -> FileFormatConfiguration -> Bool)
-> (FileFormatConfiguration -> FileFormatConfiguration -> Bool)
-> Eq FileFormatConfiguration
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]
(Int -> ReadS FileFormatConfiguration)
-> ReadS [FileFormatConfiguration]
-> ReadPrec FileFormatConfiguration
-> ReadPrec [FileFormatConfiguration]
-> Read 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
(Int -> FileFormatConfiguration -> ShowS)
-> (FileFormatConfiguration -> String)
-> ([FileFormatConfiguration] -> ShowS)
-> Show FileFormatConfiguration
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.
 FileFormatConfiguration -> Rep FileFormatConfiguration x)
-> (forall x.
    Rep FileFormatConfiguration x -> FileFormatConfiguration)
-> Generic FileFormatConfiguration
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' :: Maybe JsonConfiguration
-> Maybe ParquetConfiguration -> FileFormatConfiguration
FileFormatConfiguration'
    { $sel:jsonConfiguration:FileFormatConfiguration' :: Maybe JsonConfiguration
jsonConfiguration =
        Maybe JsonConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:parquetConfiguration:FileFormatConfiguration' :: Maybe ParquetConfiguration
parquetConfiguration = Maybe 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 :: (Maybe JsonConfiguration -> f (Maybe JsonConfiguration))
-> FileFormatConfiguration -> f FileFormatConfiguration
fileFormatConfiguration_jsonConfiguration = (FileFormatConfiguration -> Maybe JsonConfiguration)
-> (FileFormatConfiguration
    -> Maybe JsonConfiguration -> FileFormatConfiguration)
-> Lens
     FileFormatConfiguration
     FileFormatConfiguration
     (Maybe JsonConfiguration)
     (Maybe 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 :: (Maybe ParquetConfiguration -> f (Maybe ParquetConfiguration))
-> FileFormatConfiguration -> f FileFormatConfiguration
fileFormatConfiguration_parquetConfiguration = (FileFormatConfiguration -> Maybe ParquetConfiguration)
-> (FileFormatConfiguration
    -> Maybe ParquetConfiguration -> FileFormatConfiguration)
-> Lens
     FileFormatConfiguration
     FileFormatConfiguration
     (Maybe ParquetConfiguration)
     (Maybe 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 Core.FromJSON FileFormatConfiguration where
  parseJSON :: Value -> Parser FileFormatConfiguration
parseJSON =
    String
-> (Object -> Parser FileFormatConfiguration)
-> Value
-> Parser FileFormatConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FileFormatConfiguration"
      ( \Object
x ->
          Maybe JsonConfiguration
-> Maybe ParquetConfiguration -> FileFormatConfiguration
FileFormatConfiguration'
            (Maybe JsonConfiguration
 -> Maybe ParquetConfiguration -> FileFormatConfiguration)
-> Parser (Maybe JsonConfiguration)
-> Parser (Maybe ParquetConfiguration -> FileFormatConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe JsonConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"jsonConfiguration")
            Parser (Maybe ParquetConfiguration -> FileFormatConfiguration)
-> Parser (Maybe ParquetConfiguration)
-> Parser FileFormatConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ParquetConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"parquetConfiguration")
      )

instance Prelude.Hashable FileFormatConfiguration

instance Prelude.NFData FileFormatConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"jsonConfiguration" Text -> JsonConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (JsonConfiguration -> Pair)
-> Maybe JsonConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JsonConfiguration
jsonConfiguration,
            (Text
"parquetConfiguration" Text -> ParquetConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ParquetConfiguration -> Pair)
-> Maybe ParquetConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ParquetConfiguration
parquetConfiguration
          ]
      )