{-# 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.Glacier.Types.CSVOutput
-- 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.Glacier.Types.CSVOutput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glacier.Types.QuoteFields
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the comma-separated value (CSV) file that the
-- job results are stored in.
--
-- /See:/ 'newCSVOutput' smart constructor.
data CSVOutput = CSVOutput'
  { -- | A value used to separate individual fields from each other within a
    -- record.
    CSVOutput -> Maybe Text
fieldDelimiter :: Prelude.Maybe Prelude.Text,
    -- | A value used as an escape character where the field delimiter is part of
    -- the value.
    CSVOutput -> Maybe Text
quoteCharacter :: Prelude.Maybe Prelude.Text,
    -- | A single character used for escaping the quotation-mark character inside
    -- an already escaped value.
    CSVOutput -> Maybe Text
quoteEscapeCharacter :: Prelude.Maybe Prelude.Text,
    -- | A value that indicates whether all output fields should be contained
    -- within quotation marks.
    CSVOutput -> Maybe QuoteFields
quoteFields :: Prelude.Maybe QuoteFields,
    -- | A value used to separate individual records from each other.
    CSVOutput -> Maybe Text
recordDelimiter :: Prelude.Maybe Prelude.Text
  }
  deriving (CSVOutput -> CSVOutput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CSVOutput -> CSVOutput -> Bool
$c/= :: CSVOutput -> CSVOutput -> Bool
== :: CSVOutput -> CSVOutput -> Bool
$c== :: CSVOutput -> CSVOutput -> Bool
Prelude.Eq, ReadPrec [CSVOutput]
ReadPrec CSVOutput
Int -> ReadS CSVOutput
ReadS [CSVOutput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CSVOutput]
$creadListPrec :: ReadPrec [CSVOutput]
readPrec :: ReadPrec CSVOutput
$creadPrec :: ReadPrec CSVOutput
readList :: ReadS [CSVOutput]
$creadList :: ReadS [CSVOutput]
readsPrec :: Int -> ReadS CSVOutput
$creadsPrec :: Int -> ReadS CSVOutput
Prelude.Read, Int -> CSVOutput -> ShowS
[CSVOutput] -> ShowS
CSVOutput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CSVOutput] -> ShowS
$cshowList :: [CSVOutput] -> ShowS
show :: CSVOutput -> String
$cshow :: CSVOutput -> String
showsPrec :: Int -> CSVOutput -> ShowS
$cshowsPrec :: Int -> CSVOutput -> ShowS
Prelude.Show, forall x. Rep CSVOutput x -> CSVOutput
forall x. CSVOutput -> Rep CSVOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CSVOutput x -> CSVOutput
$cfrom :: forall x. CSVOutput -> Rep CSVOutput x
Prelude.Generic)

-- |
-- Create a value of 'CSVOutput' 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:
--
-- 'fieldDelimiter', 'cSVOutput_fieldDelimiter' - A value used to separate individual fields from each other within a
-- record.
--
-- 'quoteCharacter', 'cSVOutput_quoteCharacter' - A value used as an escape character where the field delimiter is part of
-- the value.
--
-- 'quoteEscapeCharacter', 'cSVOutput_quoteEscapeCharacter' - A single character used for escaping the quotation-mark character inside
-- an already escaped value.
--
-- 'quoteFields', 'cSVOutput_quoteFields' - A value that indicates whether all output fields should be contained
-- within quotation marks.
--
-- 'recordDelimiter', 'cSVOutput_recordDelimiter' - A value used to separate individual records from each other.
newCSVOutput ::
  CSVOutput
newCSVOutput :: CSVOutput
newCSVOutput =
  CSVOutput'
    { $sel:fieldDelimiter:CSVOutput' :: Maybe Text
fieldDelimiter = forall a. Maybe a
Prelude.Nothing,
      $sel:quoteCharacter:CSVOutput' :: Maybe Text
quoteCharacter = forall a. Maybe a
Prelude.Nothing,
      $sel:quoteEscapeCharacter:CSVOutput' :: Maybe Text
quoteEscapeCharacter = forall a. Maybe a
Prelude.Nothing,
      $sel:quoteFields:CSVOutput' :: Maybe QuoteFields
quoteFields = forall a. Maybe a
Prelude.Nothing,
      $sel:recordDelimiter:CSVOutput' :: Maybe Text
recordDelimiter = forall a. Maybe a
Prelude.Nothing
    }

-- | A value used to separate individual fields from each other within a
-- record.
cSVOutput_fieldDelimiter :: Lens.Lens' CSVOutput (Prelude.Maybe Prelude.Text)
cSVOutput_fieldDelimiter :: Lens' CSVOutput (Maybe Text)
cSVOutput_fieldDelimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVOutput' {Maybe Text
fieldDelimiter :: Maybe Text
$sel:fieldDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
fieldDelimiter} -> Maybe Text
fieldDelimiter) (\s :: CSVOutput
s@CSVOutput' {} Maybe Text
a -> CSVOutput
s {$sel:fieldDelimiter:CSVOutput' :: Maybe Text
fieldDelimiter = Maybe Text
a} :: CSVOutput)

-- | A value used as an escape character where the field delimiter is part of
-- the value.
cSVOutput_quoteCharacter :: Lens.Lens' CSVOutput (Prelude.Maybe Prelude.Text)
cSVOutput_quoteCharacter :: Lens' CSVOutput (Maybe Text)
cSVOutput_quoteCharacter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVOutput' {Maybe Text
quoteCharacter :: Maybe Text
$sel:quoteCharacter:CSVOutput' :: CSVOutput -> Maybe Text
quoteCharacter} -> Maybe Text
quoteCharacter) (\s :: CSVOutput
s@CSVOutput' {} Maybe Text
a -> CSVOutput
s {$sel:quoteCharacter:CSVOutput' :: Maybe Text
quoteCharacter = Maybe Text
a} :: CSVOutput)

-- | A single character used for escaping the quotation-mark character inside
-- an already escaped value.
cSVOutput_quoteEscapeCharacter :: Lens.Lens' CSVOutput (Prelude.Maybe Prelude.Text)
cSVOutput_quoteEscapeCharacter :: Lens' CSVOutput (Maybe Text)
cSVOutput_quoteEscapeCharacter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVOutput' {Maybe Text
quoteEscapeCharacter :: Maybe Text
$sel:quoteEscapeCharacter:CSVOutput' :: CSVOutput -> Maybe Text
quoteEscapeCharacter} -> Maybe Text
quoteEscapeCharacter) (\s :: CSVOutput
s@CSVOutput' {} Maybe Text
a -> CSVOutput
s {$sel:quoteEscapeCharacter:CSVOutput' :: Maybe Text
quoteEscapeCharacter = Maybe Text
a} :: CSVOutput)

-- | A value that indicates whether all output fields should be contained
-- within quotation marks.
cSVOutput_quoteFields :: Lens.Lens' CSVOutput (Prelude.Maybe QuoteFields)
cSVOutput_quoteFields :: Lens' CSVOutput (Maybe QuoteFields)
cSVOutput_quoteFields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVOutput' {Maybe QuoteFields
quoteFields :: Maybe QuoteFields
$sel:quoteFields:CSVOutput' :: CSVOutput -> Maybe QuoteFields
quoteFields} -> Maybe QuoteFields
quoteFields) (\s :: CSVOutput
s@CSVOutput' {} Maybe QuoteFields
a -> CSVOutput
s {$sel:quoteFields:CSVOutput' :: Maybe QuoteFields
quoteFields = Maybe QuoteFields
a} :: CSVOutput)

-- | A value used to separate individual records from each other.
cSVOutput_recordDelimiter :: Lens.Lens' CSVOutput (Prelude.Maybe Prelude.Text)
cSVOutput_recordDelimiter :: Lens' CSVOutput (Maybe Text)
cSVOutput_recordDelimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVOutput' {Maybe Text
recordDelimiter :: Maybe Text
$sel:recordDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
recordDelimiter} -> Maybe Text
recordDelimiter) (\s :: CSVOutput
s@CSVOutput' {} Maybe Text
a -> CSVOutput
s {$sel:recordDelimiter:CSVOutput' :: Maybe Text
recordDelimiter = Maybe Text
a} :: CSVOutput)

instance Data.FromJSON CSVOutput where
  parseJSON :: Value -> Parser CSVOutput
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CSVOutput"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe QuoteFields
-> Maybe Text
-> CSVOutput
CSVOutput'
            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
"FieldDelimiter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"QuoteCharacter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"QuoteEscapeCharacter")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"QuoteFields")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RecordDelimiter")
      )

instance Prelude.Hashable CSVOutput where
  hashWithSalt :: Int -> CSVOutput -> Int
hashWithSalt Int
_salt CSVOutput' {Maybe Text
Maybe QuoteFields
recordDelimiter :: Maybe Text
quoteFields :: Maybe QuoteFields
quoteEscapeCharacter :: Maybe Text
quoteCharacter :: Maybe Text
fieldDelimiter :: Maybe Text
$sel:recordDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:quoteFields:CSVOutput' :: CSVOutput -> Maybe QuoteFields
$sel:quoteEscapeCharacter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:quoteCharacter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:fieldDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fieldDelimiter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
quoteCharacter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
quoteEscapeCharacter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe QuoteFields
quoteFields
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recordDelimiter

instance Prelude.NFData CSVOutput where
  rnf :: CSVOutput -> ()
rnf CSVOutput' {Maybe Text
Maybe QuoteFields
recordDelimiter :: Maybe Text
quoteFields :: Maybe QuoteFields
quoteEscapeCharacter :: Maybe Text
quoteCharacter :: Maybe Text
fieldDelimiter :: Maybe Text
$sel:recordDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:quoteFields:CSVOutput' :: CSVOutput -> Maybe QuoteFields
$sel:quoteEscapeCharacter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:quoteCharacter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:fieldDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
fieldDelimiter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
quoteCharacter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
quoteEscapeCharacter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe QuoteFields
quoteFields
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recordDelimiter

instance Data.ToJSON CSVOutput where
  toJSON :: CSVOutput -> Value
toJSON CSVOutput' {Maybe Text
Maybe QuoteFields
recordDelimiter :: Maybe Text
quoteFields :: Maybe QuoteFields
quoteEscapeCharacter :: Maybe Text
quoteCharacter :: Maybe Text
fieldDelimiter :: Maybe Text
$sel:recordDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:quoteFields:CSVOutput' :: CSVOutput -> Maybe QuoteFields
$sel:quoteEscapeCharacter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:quoteCharacter:CSVOutput' :: CSVOutput -> Maybe Text
$sel:fieldDelimiter:CSVOutput' :: CSVOutput -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"FieldDelimiter" 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
fieldDelimiter,
            (Key
"QuoteCharacter" 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
quoteCharacter,
            (Key
"QuoteEscapeCharacter" 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
quoteEscapeCharacter,
            (Key
"QuoteFields" 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 QuoteFields
quoteFields,
            (Key
"RecordDelimiter" 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
recordDelimiter
          ]
      )