{-# 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 #-}
module Amazonka.DataBrew.Types.FormatOptions where
import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.CsvOptions
import Amazonka.DataBrew.Types.ExcelOptions
import Amazonka.DataBrew.Types.JsonOptions
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data FormatOptions = FormatOptions'
{
FormatOptions -> Maybe JsonOptions
json :: Prelude.Maybe JsonOptions,
FormatOptions -> Maybe CsvOptions
csv :: Prelude.Maybe CsvOptions,
FormatOptions -> Maybe ExcelOptions
excel :: Prelude.Maybe ExcelOptions
}
deriving (FormatOptions -> FormatOptions -> Bool
(FormatOptions -> FormatOptions -> Bool)
-> (FormatOptions -> FormatOptions -> Bool) -> Eq FormatOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormatOptions -> FormatOptions -> Bool
$c/= :: FormatOptions -> FormatOptions -> Bool
== :: FormatOptions -> FormatOptions -> Bool
$c== :: FormatOptions -> FormatOptions -> Bool
Prelude.Eq, ReadPrec [FormatOptions]
ReadPrec FormatOptions
Int -> ReadS FormatOptions
ReadS [FormatOptions]
(Int -> ReadS FormatOptions)
-> ReadS [FormatOptions]
-> ReadPrec FormatOptions
-> ReadPrec [FormatOptions]
-> Read FormatOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormatOptions]
$creadListPrec :: ReadPrec [FormatOptions]
readPrec :: ReadPrec FormatOptions
$creadPrec :: ReadPrec FormatOptions
readList :: ReadS [FormatOptions]
$creadList :: ReadS [FormatOptions]
readsPrec :: Int -> ReadS FormatOptions
$creadsPrec :: Int -> ReadS FormatOptions
Prelude.Read, Int -> FormatOptions -> ShowS
[FormatOptions] -> ShowS
FormatOptions -> String
(Int -> FormatOptions -> ShowS)
-> (FormatOptions -> String)
-> ([FormatOptions] -> ShowS)
-> Show FormatOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormatOptions] -> ShowS
$cshowList :: [FormatOptions] -> ShowS
show :: FormatOptions -> String
$cshow :: FormatOptions -> String
showsPrec :: Int -> FormatOptions -> ShowS
$cshowsPrec :: Int -> FormatOptions -> ShowS
Prelude.Show, (forall x. FormatOptions -> Rep FormatOptions x)
-> (forall x. Rep FormatOptions x -> FormatOptions)
-> Generic FormatOptions
forall x. Rep FormatOptions x -> FormatOptions
forall x. FormatOptions -> Rep FormatOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FormatOptions x -> FormatOptions
$cfrom :: forall x. FormatOptions -> Rep FormatOptions x
Prelude.Generic)
newFormatOptions ::
FormatOptions
newFormatOptions :: FormatOptions
newFormatOptions =
FormatOptions' :: Maybe JsonOptions
-> Maybe CsvOptions -> Maybe ExcelOptions -> FormatOptions
FormatOptions'
{ $sel:json:FormatOptions' :: Maybe JsonOptions
json = Maybe JsonOptions
forall a. Maybe a
Prelude.Nothing,
$sel:csv:FormatOptions' :: Maybe CsvOptions
csv = Maybe CsvOptions
forall a. Maybe a
Prelude.Nothing,
$sel:excel:FormatOptions' :: Maybe ExcelOptions
excel = Maybe ExcelOptions
forall a. Maybe a
Prelude.Nothing
}
formatOptions_json :: Lens.Lens' FormatOptions (Prelude.Maybe JsonOptions)
formatOptions_json :: (Maybe JsonOptions -> f (Maybe JsonOptions))
-> FormatOptions -> f FormatOptions
formatOptions_json = (FormatOptions -> Maybe JsonOptions)
-> (FormatOptions -> Maybe JsonOptions -> FormatOptions)
-> Lens
FormatOptions FormatOptions (Maybe JsonOptions) (Maybe JsonOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormatOptions' {Maybe JsonOptions
json :: Maybe JsonOptions
$sel:json:FormatOptions' :: FormatOptions -> Maybe JsonOptions
json} -> Maybe JsonOptions
json) (\s :: FormatOptions
s@FormatOptions' {} Maybe JsonOptions
a -> FormatOptions
s {$sel:json:FormatOptions' :: Maybe JsonOptions
json = Maybe JsonOptions
a} :: FormatOptions)
formatOptions_csv :: Lens.Lens' FormatOptions (Prelude.Maybe CsvOptions)
formatOptions_csv :: (Maybe CsvOptions -> f (Maybe CsvOptions))
-> FormatOptions -> f FormatOptions
formatOptions_csv = (FormatOptions -> Maybe CsvOptions)
-> (FormatOptions -> Maybe CsvOptions -> FormatOptions)
-> Lens
FormatOptions FormatOptions (Maybe CsvOptions) (Maybe CsvOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormatOptions' {Maybe CsvOptions
csv :: Maybe CsvOptions
$sel:csv:FormatOptions' :: FormatOptions -> Maybe CsvOptions
csv} -> Maybe CsvOptions
csv) (\s :: FormatOptions
s@FormatOptions' {} Maybe CsvOptions
a -> FormatOptions
s {$sel:csv:FormatOptions' :: Maybe CsvOptions
csv = Maybe CsvOptions
a} :: FormatOptions)
formatOptions_excel :: Lens.Lens' FormatOptions (Prelude.Maybe ExcelOptions)
formatOptions_excel :: (Maybe ExcelOptions -> f (Maybe ExcelOptions))
-> FormatOptions -> f FormatOptions
formatOptions_excel = (FormatOptions -> Maybe ExcelOptions)
-> (FormatOptions -> Maybe ExcelOptions -> FormatOptions)
-> Lens
FormatOptions
FormatOptions
(Maybe ExcelOptions)
(Maybe ExcelOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormatOptions' {Maybe ExcelOptions
excel :: Maybe ExcelOptions
$sel:excel:FormatOptions' :: FormatOptions -> Maybe ExcelOptions
excel} -> Maybe ExcelOptions
excel) (\s :: FormatOptions
s@FormatOptions' {} Maybe ExcelOptions
a -> FormatOptions
s {$sel:excel:FormatOptions' :: Maybe ExcelOptions
excel = Maybe ExcelOptions
a} :: FormatOptions)
instance Core.FromJSON FormatOptions where
parseJSON :: Value -> Parser FormatOptions
parseJSON =
String
-> (Object -> Parser FormatOptions)
-> Value
-> Parser FormatOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"FormatOptions"
( \Object
x ->
Maybe JsonOptions
-> Maybe CsvOptions -> Maybe ExcelOptions -> FormatOptions
FormatOptions'
(Maybe JsonOptions
-> Maybe CsvOptions -> Maybe ExcelOptions -> FormatOptions)
-> Parser (Maybe JsonOptions)
-> Parser (Maybe CsvOptions -> Maybe ExcelOptions -> FormatOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe JsonOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Json")
Parser (Maybe CsvOptions -> Maybe ExcelOptions -> FormatOptions)
-> Parser (Maybe CsvOptions)
-> Parser (Maybe ExcelOptions -> FormatOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CsvOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Csv")
Parser (Maybe ExcelOptions -> FormatOptions)
-> Parser (Maybe ExcelOptions) -> Parser FormatOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExcelOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Excel")
)
instance Prelude.Hashable FormatOptions
instance Prelude.NFData FormatOptions
instance Core.ToJSON FormatOptions where
toJSON :: FormatOptions -> Value
toJSON FormatOptions' {Maybe CsvOptions
Maybe ExcelOptions
Maybe JsonOptions
excel :: Maybe ExcelOptions
csv :: Maybe CsvOptions
json :: Maybe JsonOptions
$sel:excel:FormatOptions' :: FormatOptions -> Maybe ExcelOptions
$sel:csv:FormatOptions' :: FormatOptions -> Maybe CsvOptions
$sel:json:FormatOptions' :: FormatOptions -> Maybe JsonOptions
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Json" Text -> JsonOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (JsonOptions -> Pair) -> Maybe JsonOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JsonOptions
json,
(Text
"Csv" Text -> CsvOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CsvOptions -> Pair) -> Maybe CsvOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CsvOptions
csv,
(Text
"Excel" Text -> ExcelOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ExcelOptions -> Pair) -> Maybe ExcelOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExcelOptions
excel
]
)