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

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.CsvOutputOptions
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents a set of options that define the structure of comma-separated
-- (CSV) job output.
--
-- /See:/ 'newOutputFormatOptions' smart constructor.
data OutputFormatOptions = OutputFormatOptions'
  { -- | Represents a set of options that define the structure of comma-separated
    -- value (CSV) job output.
    OutputFormatOptions -> Maybe CsvOutputOptions
csv :: Prelude.Maybe CsvOutputOptions
  }
  deriving (OutputFormatOptions -> OutputFormatOptions -> Bool
(OutputFormatOptions -> OutputFormatOptions -> Bool)
-> (OutputFormatOptions -> OutputFormatOptions -> Bool)
-> Eq OutputFormatOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputFormatOptions -> OutputFormatOptions -> Bool
$c/= :: OutputFormatOptions -> OutputFormatOptions -> Bool
== :: OutputFormatOptions -> OutputFormatOptions -> Bool
$c== :: OutputFormatOptions -> OutputFormatOptions -> Bool
Prelude.Eq, ReadPrec [OutputFormatOptions]
ReadPrec OutputFormatOptions
Int -> ReadS OutputFormatOptions
ReadS [OutputFormatOptions]
(Int -> ReadS OutputFormatOptions)
-> ReadS [OutputFormatOptions]
-> ReadPrec OutputFormatOptions
-> ReadPrec [OutputFormatOptions]
-> Read OutputFormatOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OutputFormatOptions]
$creadListPrec :: ReadPrec [OutputFormatOptions]
readPrec :: ReadPrec OutputFormatOptions
$creadPrec :: ReadPrec OutputFormatOptions
readList :: ReadS [OutputFormatOptions]
$creadList :: ReadS [OutputFormatOptions]
readsPrec :: Int -> ReadS OutputFormatOptions
$creadsPrec :: Int -> ReadS OutputFormatOptions
Prelude.Read, Int -> OutputFormatOptions -> ShowS
[OutputFormatOptions] -> ShowS
OutputFormatOptions -> String
(Int -> OutputFormatOptions -> ShowS)
-> (OutputFormatOptions -> String)
-> ([OutputFormatOptions] -> ShowS)
-> Show OutputFormatOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OutputFormatOptions] -> ShowS
$cshowList :: [OutputFormatOptions] -> ShowS
show :: OutputFormatOptions -> String
$cshow :: OutputFormatOptions -> String
showsPrec :: Int -> OutputFormatOptions -> ShowS
$cshowsPrec :: Int -> OutputFormatOptions -> ShowS
Prelude.Show, (forall x. OutputFormatOptions -> Rep OutputFormatOptions x)
-> (forall x. Rep OutputFormatOptions x -> OutputFormatOptions)
-> Generic OutputFormatOptions
forall x. Rep OutputFormatOptions x -> OutputFormatOptions
forall x. OutputFormatOptions -> Rep OutputFormatOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OutputFormatOptions x -> OutputFormatOptions
$cfrom :: forall x. OutputFormatOptions -> Rep OutputFormatOptions x
Prelude.Generic)

-- |
-- Create a value of 'OutputFormatOptions' 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:
--
-- 'csv', 'outputFormatOptions_csv' - Represents a set of options that define the structure of comma-separated
-- value (CSV) job output.
newOutputFormatOptions ::
  OutputFormatOptions
newOutputFormatOptions :: OutputFormatOptions
newOutputFormatOptions =
  OutputFormatOptions' :: Maybe CsvOutputOptions -> OutputFormatOptions
OutputFormatOptions' {$sel:csv:OutputFormatOptions' :: Maybe CsvOutputOptions
csv = Maybe CsvOutputOptions
forall a. Maybe a
Prelude.Nothing}

-- | Represents a set of options that define the structure of comma-separated
-- value (CSV) job output.
outputFormatOptions_csv :: Lens.Lens' OutputFormatOptions (Prelude.Maybe CsvOutputOptions)
outputFormatOptions_csv :: (Maybe CsvOutputOptions -> f (Maybe CsvOutputOptions))
-> OutputFormatOptions -> f OutputFormatOptions
outputFormatOptions_csv = (OutputFormatOptions -> Maybe CsvOutputOptions)
-> (OutputFormatOptions
    -> Maybe CsvOutputOptions -> OutputFormatOptions)
-> Lens
     OutputFormatOptions
     OutputFormatOptions
     (Maybe CsvOutputOptions)
     (Maybe CsvOutputOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OutputFormatOptions' {Maybe CsvOutputOptions
csv :: Maybe CsvOutputOptions
$sel:csv:OutputFormatOptions' :: OutputFormatOptions -> Maybe CsvOutputOptions
csv} -> Maybe CsvOutputOptions
csv) (\s :: OutputFormatOptions
s@OutputFormatOptions' {} Maybe CsvOutputOptions
a -> OutputFormatOptions
s {$sel:csv:OutputFormatOptions' :: Maybe CsvOutputOptions
csv = Maybe CsvOutputOptions
a} :: OutputFormatOptions)

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

instance Prelude.Hashable OutputFormatOptions

instance Prelude.NFData OutputFormatOptions

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