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