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

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types.SchemaDefinition
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the configuration information of the Parquet format.
--
-- /See:/ 'newParquetConfiguration' smart constructor.
data ParquetConfiguration = ParquetConfiguration'
  { -- | Information needed to define a schema.
    ParquetConfiguration -> Maybe SchemaDefinition
schemaDefinition :: Prelude.Maybe SchemaDefinition
  }
  deriving (ParquetConfiguration -> ParquetConfiguration -> Bool
(ParquetConfiguration -> ParquetConfiguration -> Bool)
-> (ParquetConfiguration -> ParquetConfiguration -> Bool)
-> Eq ParquetConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParquetConfiguration -> ParquetConfiguration -> Bool
$c/= :: ParquetConfiguration -> ParquetConfiguration -> Bool
== :: ParquetConfiguration -> ParquetConfiguration -> Bool
$c== :: ParquetConfiguration -> ParquetConfiguration -> Bool
Prelude.Eq, ReadPrec [ParquetConfiguration]
ReadPrec ParquetConfiguration
Int -> ReadS ParquetConfiguration
ReadS [ParquetConfiguration]
(Int -> ReadS ParquetConfiguration)
-> ReadS [ParquetConfiguration]
-> ReadPrec ParquetConfiguration
-> ReadPrec [ParquetConfiguration]
-> Read ParquetConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParquetConfiguration]
$creadListPrec :: ReadPrec [ParquetConfiguration]
readPrec :: ReadPrec ParquetConfiguration
$creadPrec :: ReadPrec ParquetConfiguration
readList :: ReadS [ParquetConfiguration]
$creadList :: ReadS [ParquetConfiguration]
readsPrec :: Int -> ReadS ParquetConfiguration
$creadsPrec :: Int -> ReadS ParquetConfiguration
Prelude.Read, Int -> ParquetConfiguration -> ShowS
[ParquetConfiguration] -> ShowS
ParquetConfiguration -> String
(Int -> ParquetConfiguration -> ShowS)
-> (ParquetConfiguration -> String)
-> ([ParquetConfiguration] -> ShowS)
-> Show ParquetConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParquetConfiguration] -> ShowS
$cshowList :: [ParquetConfiguration] -> ShowS
show :: ParquetConfiguration -> String
$cshow :: ParquetConfiguration -> String
showsPrec :: Int -> ParquetConfiguration -> ShowS
$cshowsPrec :: Int -> ParquetConfiguration -> ShowS
Prelude.Show, (forall x. ParquetConfiguration -> Rep ParquetConfiguration x)
-> (forall x. Rep ParquetConfiguration x -> ParquetConfiguration)
-> Generic ParquetConfiguration
forall x. Rep ParquetConfiguration x -> ParquetConfiguration
forall x. ParquetConfiguration -> Rep ParquetConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParquetConfiguration x -> ParquetConfiguration
$cfrom :: forall x. ParquetConfiguration -> Rep ParquetConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ParquetConfiguration' 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:
--
-- 'schemaDefinition', 'parquetConfiguration_schemaDefinition' - Information needed to define a schema.
newParquetConfiguration ::
  ParquetConfiguration
newParquetConfiguration :: ParquetConfiguration
newParquetConfiguration =
  ParquetConfiguration' :: Maybe SchemaDefinition -> ParquetConfiguration
ParquetConfiguration'
    { $sel:schemaDefinition:ParquetConfiguration' :: Maybe SchemaDefinition
schemaDefinition =
        Maybe SchemaDefinition
forall a. Maybe a
Prelude.Nothing
    }

-- | Information needed to define a schema.
parquetConfiguration_schemaDefinition :: Lens.Lens' ParquetConfiguration (Prelude.Maybe SchemaDefinition)
parquetConfiguration_schemaDefinition :: (Maybe SchemaDefinition -> f (Maybe SchemaDefinition))
-> ParquetConfiguration -> f ParquetConfiguration
parquetConfiguration_schemaDefinition = (ParquetConfiguration -> Maybe SchemaDefinition)
-> (ParquetConfiguration
    -> Maybe SchemaDefinition -> ParquetConfiguration)
-> Lens
     ParquetConfiguration
     ParquetConfiguration
     (Maybe SchemaDefinition)
     (Maybe SchemaDefinition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParquetConfiguration' {Maybe SchemaDefinition
schemaDefinition :: Maybe SchemaDefinition
$sel:schemaDefinition:ParquetConfiguration' :: ParquetConfiguration -> Maybe SchemaDefinition
schemaDefinition} -> Maybe SchemaDefinition
schemaDefinition) (\s :: ParquetConfiguration
s@ParquetConfiguration' {} Maybe SchemaDefinition
a -> ParquetConfiguration
s {$sel:schemaDefinition:ParquetConfiguration' :: Maybe SchemaDefinition
schemaDefinition = Maybe SchemaDefinition
a} :: ParquetConfiguration)

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

instance Prelude.Hashable ParquetConfiguration

instance Prelude.NFData ParquetConfiguration

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