{-# 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.DataBrew.Types.CsvOutputOptions
-- 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.DataBrew.Types.CsvOutputOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Represents a set of options that define how DataBrew will write a
-- comma-separated value (CSV) file.
--
-- /See:/ 'newCsvOutputOptions' smart constructor.
data CsvOutputOptions = CsvOutputOptions'
  { -- | A single character that specifies the delimiter used to create CSV job
    -- output.
    CsvOutputOptions -> Maybe Text
delimiter :: Prelude.Maybe Prelude.Text
  }
  deriving (CsvOutputOptions -> CsvOutputOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CsvOutputOptions -> CsvOutputOptions -> Bool
$c/= :: CsvOutputOptions -> CsvOutputOptions -> Bool
== :: CsvOutputOptions -> CsvOutputOptions -> Bool
$c== :: CsvOutputOptions -> CsvOutputOptions -> Bool
Prelude.Eq, ReadPrec [CsvOutputOptions]
ReadPrec CsvOutputOptions
Int -> ReadS CsvOutputOptions
ReadS [CsvOutputOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CsvOutputOptions]
$creadListPrec :: ReadPrec [CsvOutputOptions]
readPrec :: ReadPrec CsvOutputOptions
$creadPrec :: ReadPrec CsvOutputOptions
readList :: ReadS [CsvOutputOptions]
$creadList :: ReadS [CsvOutputOptions]
readsPrec :: Int -> ReadS CsvOutputOptions
$creadsPrec :: Int -> ReadS CsvOutputOptions
Prelude.Read, Int -> CsvOutputOptions -> ShowS
[CsvOutputOptions] -> ShowS
CsvOutputOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CsvOutputOptions] -> ShowS
$cshowList :: [CsvOutputOptions] -> ShowS
show :: CsvOutputOptions -> String
$cshow :: CsvOutputOptions -> String
showsPrec :: Int -> CsvOutputOptions -> ShowS
$cshowsPrec :: Int -> CsvOutputOptions -> ShowS
Prelude.Show, forall x. Rep CsvOutputOptions x -> CsvOutputOptions
forall x. CsvOutputOptions -> Rep CsvOutputOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CsvOutputOptions x -> CsvOutputOptions
$cfrom :: forall x. CsvOutputOptions -> Rep CsvOutputOptions x
Prelude.Generic)

-- |
-- Create a value of 'CsvOutputOptions' 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:
--
-- 'delimiter', 'csvOutputOptions_delimiter' - A single character that specifies the delimiter used to create CSV job
-- output.
newCsvOutputOptions ::
  CsvOutputOptions
newCsvOutputOptions :: CsvOutputOptions
newCsvOutputOptions =
  CsvOutputOptions' {$sel:delimiter:CsvOutputOptions' :: Maybe Text
delimiter = forall a. Maybe a
Prelude.Nothing}

-- | A single character that specifies the delimiter used to create CSV job
-- output.
csvOutputOptions_delimiter :: Lens.Lens' CsvOutputOptions (Prelude.Maybe Prelude.Text)
csvOutputOptions_delimiter :: Lens' CsvOutputOptions (Maybe Text)
csvOutputOptions_delimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CsvOutputOptions' {Maybe Text
delimiter :: Maybe Text
$sel:delimiter:CsvOutputOptions' :: CsvOutputOptions -> Maybe Text
delimiter} -> Maybe Text
delimiter) (\s :: CsvOutputOptions
s@CsvOutputOptions' {} Maybe Text
a -> CsvOutputOptions
s {$sel:delimiter:CsvOutputOptions' :: Maybe Text
delimiter = Maybe Text
a} :: CsvOutputOptions)

instance Data.FromJSON CsvOutputOptions where
  parseJSON :: Value -> Parser CsvOutputOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CsvOutputOptions"
      ( \Object
x ->
          Maybe Text -> CsvOutputOptions
CsvOutputOptions'
            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
"Delimiter")
      )

instance Prelude.Hashable CsvOutputOptions where
  hashWithSalt :: Int -> CsvOutputOptions -> Int
hashWithSalt Int
_salt CsvOutputOptions' {Maybe Text
delimiter :: Maybe Text
$sel:delimiter:CsvOutputOptions' :: CsvOutputOptions -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
delimiter

instance Prelude.NFData CsvOutputOptions where
  rnf :: CsvOutputOptions -> ()
rnf CsvOutputOptions' {Maybe Text
delimiter :: Maybe Text
$sel:delimiter:CsvOutputOptions' :: CsvOutputOptions -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
delimiter

instance Data.ToJSON CsvOutputOptions where
  toJSON :: CsvOutputOptions -> Value
toJSON CsvOutputOptions' {Maybe Text
delimiter :: Maybe Text
$sel:delimiter:CsvOutputOptions' :: CsvOutputOptions -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Delimiter" 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 Text
delimiter]
      )