{-# 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.S3.Types.CSVInput
-- 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.S3.Types.CSVInput 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
import Amazonka.S3.Internal
import Amazonka.S3.Types.FileHeaderInfo

-- | Describes how an uncompressed comma-separated values (CSV)-formatted
-- input object is formatted.
--
-- /See:/ 'newCSVInput' smart constructor.
data CSVInput = CSVInput'
  { -- | Specifies that CSV field values may contain quoted record delimiters and
    -- such records should be allowed. Default value is FALSE. Setting this
    -- value to TRUE may lower performance.
    CSVInput -> Maybe Bool
allowQuotedRecordDelimiter :: Prelude.Maybe Prelude.Bool,
    -- | A single character used to indicate that a row should be ignored when
    -- the character is present at the start of that row. You can specify any
    -- character to indicate a comment line.
    CSVInput -> Maybe Text
comments :: Prelude.Maybe Prelude.Text,
    -- | A single character used to separate individual fields in a record. You
    -- can specify an arbitrary delimiter.
    CSVInput -> Maybe Text
fieldDelimiter :: Prelude.Maybe Prelude.Text,
    -- | Describes the first line of input. Valid values are:
    --
    -- -   @NONE@: First line is not a header.
    --
    -- -   @IGNORE@: First line is a header, but you can\'t use the header
    --     values to indicate the column in an expression. You can use column
    --     position (such as _1, _2, …) to indicate the column
    --     (@SELECT s._1 FROM OBJECT s@).
    --
    -- -   @Use@: First line is a header, and you can use the header value to
    --     identify a column in an expression (@SELECT \"name\" FROM OBJECT@).
    CSVInput -> Maybe FileHeaderInfo
fileHeaderInfo :: Prelude.Maybe FileHeaderInfo,
    -- | A single character used for escaping when the field delimiter is part of
    -- the value. For example, if the value is @a, b@, Amazon S3 wraps this
    -- field value in quotation marks, as follows: @\" a , b \"@.
    --
    -- Type: String
    --
    -- Default: @\"@
    --
    -- Ancestors: @CSV@
    CSVInput -> Maybe Text
quoteCharacter :: Prelude.Maybe Prelude.Text,
    -- | A single character used for escaping the quotation mark character inside
    -- an already escaped value. For example, the value @\"\"\" a , b \"\"\"@
    -- is parsed as @\" a , b \"@.
    CSVInput -> Maybe Text
quoteEscapeCharacter :: Prelude.Maybe Prelude.Text,
    -- | A single character used to separate individual records in the input.
    -- Instead of the default value, you can specify an arbitrary delimiter.
    CSVInput -> Maybe Text
recordDelimiter :: Prelude.Maybe Prelude.Text
  }
  deriving (CSVInput -> CSVInput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CSVInput -> CSVInput -> Bool
$c/= :: CSVInput -> CSVInput -> Bool
== :: CSVInput -> CSVInput -> Bool
$c== :: CSVInput -> CSVInput -> Bool
Prelude.Eq, ReadPrec [CSVInput]
ReadPrec CSVInput
Int -> ReadS CSVInput
ReadS [CSVInput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CSVInput]
$creadListPrec :: ReadPrec [CSVInput]
readPrec :: ReadPrec CSVInput
$creadPrec :: ReadPrec CSVInput
readList :: ReadS [CSVInput]
$creadList :: ReadS [CSVInput]
readsPrec :: Int -> ReadS CSVInput
$creadsPrec :: Int -> ReadS CSVInput
Prelude.Read, Int -> CSVInput -> ShowS
[CSVInput] -> ShowS
CSVInput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CSVInput] -> ShowS
$cshowList :: [CSVInput] -> ShowS
show :: CSVInput -> String
$cshow :: CSVInput -> String
showsPrec :: Int -> CSVInput -> ShowS
$cshowsPrec :: Int -> CSVInput -> ShowS
Prelude.Show, forall x. Rep CSVInput x -> CSVInput
forall x. CSVInput -> Rep CSVInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CSVInput x -> CSVInput
$cfrom :: forall x. CSVInput -> Rep CSVInput x
Prelude.Generic)

-- |
-- Create a value of 'CSVInput' 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:
--
-- 'allowQuotedRecordDelimiter', 'cSVInput_allowQuotedRecordDelimiter' - Specifies that CSV field values may contain quoted record delimiters and
-- such records should be allowed. Default value is FALSE. Setting this
-- value to TRUE may lower performance.
--
-- 'comments', 'cSVInput_comments' - A single character used to indicate that a row should be ignored when
-- the character is present at the start of that row. You can specify any
-- character to indicate a comment line.
--
-- 'fieldDelimiter', 'cSVInput_fieldDelimiter' - A single character used to separate individual fields in a record. You
-- can specify an arbitrary delimiter.
--
-- 'fileHeaderInfo', 'cSVInput_fileHeaderInfo' - Describes the first line of input. Valid values are:
--
-- -   @NONE@: First line is not a header.
--
-- -   @IGNORE@: First line is a header, but you can\'t use the header
--     values to indicate the column in an expression. You can use column
--     position (such as _1, _2, …) to indicate the column
--     (@SELECT s._1 FROM OBJECT s@).
--
-- -   @Use@: First line is a header, and you can use the header value to
--     identify a column in an expression (@SELECT \"name\" FROM OBJECT@).
--
-- 'quoteCharacter', 'cSVInput_quoteCharacter' - A single character used for escaping when the field delimiter is part of
-- the value. For example, if the value is @a, b@, Amazon S3 wraps this
-- field value in quotation marks, as follows: @\" a , b \"@.
--
-- Type: String
--
-- Default: @\"@
--
-- Ancestors: @CSV@
--
-- 'quoteEscapeCharacter', 'cSVInput_quoteEscapeCharacter' - A single character used for escaping the quotation mark character inside
-- an already escaped value. For example, the value @\"\"\" a , b \"\"\"@
-- is parsed as @\" a , b \"@.
--
-- 'recordDelimiter', 'cSVInput_recordDelimiter' - A single character used to separate individual records in the input.
-- Instead of the default value, you can specify an arbitrary delimiter.
newCSVInput ::
  CSVInput
newCSVInput :: CSVInput
newCSVInput =
  CSVInput'
    { $sel:allowQuotedRecordDelimiter:CSVInput' :: Maybe Bool
allowQuotedRecordDelimiter =
        forall a. Maybe a
Prelude.Nothing,
      $sel:comments:CSVInput' :: Maybe Text
comments = forall a. Maybe a
Prelude.Nothing,
      $sel:fieldDelimiter:CSVInput' :: Maybe Text
fieldDelimiter = forall a. Maybe a
Prelude.Nothing,
      $sel:fileHeaderInfo:CSVInput' :: Maybe FileHeaderInfo
fileHeaderInfo = forall a. Maybe a
Prelude.Nothing,
      $sel:quoteCharacter:CSVInput' :: Maybe Text
quoteCharacter = forall a. Maybe a
Prelude.Nothing,
      $sel:quoteEscapeCharacter:CSVInput' :: Maybe Text
quoteEscapeCharacter = forall a. Maybe a
Prelude.Nothing,
      $sel:recordDelimiter:CSVInput' :: Maybe Text
recordDelimiter = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies that CSV field values may contain quoted record delimiters and
-- such records should be allowed. Default value is FALSE. Setting this
-- value to TRUE may lower performance.
cSVInput_allowQuotedRecordDelimiter :: Lens.Lens' CSVInput (Prelude.Maybe Prelude.Bool)
cSVInput_allowQuotedRecordDelimiter :: Lens' CSVInput (Maybe Bool)
cSVInput_allowQuotedRecordDelimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe Bool
allowQuotedRecordDelimiter :: Maybe Bool
$sel:allowQuotedRecordDelimiter:CSVInput' :: CSVInput -> Maybe Bool
allowQuotedRecordDelimiter} -> Maybe Bool
allowQuotedRecordDelimiter) (\s :: CSVInput
s@CSVInput' {} Maybe Bool
a -> CSVInput
s {$sel:allowQuotedRecordDelimiter:CSVInput' :: Maybe Bool
allowQuotedRecordDelimiter = Maybe Bool
a} :: CSVInput)

-- | A single character used to indicate that a row should be ignored when
-- the character is present at the start of that row. You can specify any
-- character to indicate a comment line.
cSVInput_comments :: Lens.Lens' CSVInput (Prelude.Maybe Prelude.Text)
cSVInput_comments :: Lens' CSVInput (Maybe Text)
cSVInput_comments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe Text
comments :: Maybe Text
$sel:comments:CSVInput' :: CSVInput -> Maybe Text
comments} -> Maybe Text
comments) (\s :: CSVInput
s@CSVInput' {} Maybe Text
a -> CSVInput
s {$sel:comments:CSVInput' :: Maybe Text
comments = Maybe Text
a} :: CSVInput)

-- | A single character used to separate individual fields in a record. You
-- can specify an arbitrary delimiter.
cSVInput_fieldDelimiter :: Lens.Lens' CSVInput (Prelude.Maybe Prelude.Text)
cSVInput_fieldDelimiter :: Lens' CSVInput (Maybe Text)
cSVInput_fieldDelimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe Text
fieldDelimiter :: Maybe Text
$sel:fieldDelimiter:CSVInput' :: CSVInput -> Maybe Text
fieldDelimiter} -> Maybe Text
fieldDelimiter) (\s :: CSVInput
s@CSVInput' {} Maybe Text
a -> CSVInput
s {$sel:fieldDelimiter:CSVInput' :: Maybe Text
fieldDelimiter = Maybe Text
a} :: CSVInput)

-- | Describes the first line of input. Valid values are:
--
-- -   @NONE@: First line is not a header.
--
-- -   @IGNORE@: First line is a header, but you can\'t use the header
--     values to indicate the column in an expression. You can use column
--     position (such as _1, _2, …) to indicate the column
--     (@SELECT s._1 FROM OBJECT s@).
--
-- -   @Use@: First line is a header, and you can use the header value to
--     identify a column in an expression (@SELECT \"name\" FROM OBJECT@).
cSVInput_fileHeaderInfo :: Lens.Lens' CSVInput (Prelude.Maybe FileHeaderInfo)
cSVInput_fileHeaderInfo :: Lens' CSVInput (Maybe FileHeaderInfo)
cSVInput_fileHeaderInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe FileHeaderInfo
fileHeaderInfo :: Maybe FileHeaderInfo
$sel:fileHeaderInfo:CSVInput' :: CSVInput -> Maybe FileHeaderInfo
fileHeaderInfo} -> Maybe FileHeaderInfo
fileHeaderInfo) (\s :: CSVInput
s@CSVInput' {} Maybe FileHeaderInfo
a -> CSVInput
s {$sel:fileHeaderInfo:CSVInput' :: Maybe FileHeaderInfo
fileHeaderInfo = Maybe FileHeaderInfo
a} :: CSVInput)

-- | A single character used for escaping when the field delimiter is part of
-- the value. For example, if the value is @a, b@, Amazon S3 wraps this
-- field value in quotation marks, as follows: @\" a , b \"@.
--
-- Type: String
--
-- Default: @\"@
--
-- Ancestors: @CSV@
cSVInput_quoteCharacter :: Lens.Lens' CSVInput (Prelude.Maybe Prelude.Text)
cSVInput_quoteCharacter :: Lens' CSVInput (Maybe Text)
cSVInput_quoteCharacter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe Text
quoteCharacter :: Maybe Text
$sel:quoteCharacter:CSVInput' :: CSVInput -> Maybe Text
quoteCharacter} -> Maybe Text
quoteCharacter) (\s :: CSVInput
s@CSVInput' {} Maybe Text
a -> CSVInput
s {$sel:quoteCharacter:CSVInput' :: Maybe Text
quoteCharacter = Maybe Text
a} :: CSVInput)

-- | A single character used for escaping the quotation mark character inside
-- an already escaped value. For example, the value @\"\"\" a , b \"\"\"@
-- is parsed as @\" a , b \"@.
cSVInput_quoteEscapeCharacter :: Lens.Lens' CSVInput (Prelude.Maybe Prelude.Text)
cSVInput_quoteEscapeCharacter :: Lens' CSVInput (Maybe Text)
cSVInput_quoteEscapeCharacter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe Text
quoteEscapeCharacter :: Maybe Text
$sel:quoteEscapeCharacter:CSVInput' :: CSVInput -> Maybe Text
quoteEscapeCharacter} -> Maybe Text
quoteEscapeCharacter) (\s :: CSVInput
s@CSVInput' {} Maybe Text
a -> CSVInput
s {$sel:quoteEscapeCharacter:CSVInput' :: Maybe Text
quoteEscapeCharacter = Maybe Text
a} :: CSVInput)

-- | A single character used to separate individual records in the input.
-- Instead of the default value, you can specify an arbitrary delimiter.
cSVInput_recordDelimiter :: Lens.Lens' CSVInput (Prelude.Maybe Prelude.Text)
cSVInput_recordDelimiter :: Lens' CSVInput (Maybe Text)
cSVInput_recordDelimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CSVInput' {Maybe Text
recordDelimiter :: Maybe Text
$sel:recordDelimiter:CSVInput' :: CSVInput -> Maybe Text
recordDelimiter} -> Maybe Text
recordDelimiter) (\s :: CSVInput
s@CSVInput' {} Maybe Text
a -> CSVInput
s {$sel:recordDelimiter:CSVInput' :: Maybe Text
recordDelimiter = Maybe Text
a} :: CSVInput)

instance Prelude.Hashable CSVInput where
  hashWithSalt :: Int -> CSVInput -> Int
hashWithSalt Int
_salt CSVInput' {Maybe Bool
Maybe Text
Maybe FileHeaderInfo
recordDelimiter :: Maybe Text
quoteEscapeCharacter :: Maybe Text
quoteCharacter :: Maybe Text
fileHeaderInfo :: Maybe FileHeaderInfo
fieldDelimiter :: Maybe Text
comments :: Maybe Text
allowQuotedRecordDelimiter :: Maybe Bool
$sel:recordDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteEscapeCharacter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteCharacter:CSVInput' :: CSVInput -> Maybe Text
$sel:fileHeaderInfo:CSVInput' :: CSVInput -> Maybe FileHeaderInfo
$sel:fieldDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:comments:CSVInput' :: CSVInput -> Maybe Text
$sel:allowQuotedRecordDelimiter:CSVInput' :: CSVInput -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowQuotedRecordDelimiter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
comments
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
fieldDelimiter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FileHeaderInfo
fileHeaderInfo
      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 Text
recordDelimiter

instance Prelude.NFData CSVInput where
  rnf :: CSVInput -> ()
rnf CSVInput' {Maybe Bool
Maybe Text
Maybe FileHeaderInfo
recordDelimiter :: Maybe Text
quoteEscapeCharacter :: Maybe Text
quoteCharacter :: Maybe Text
fileHeaderInfo :: Maybe FileHeaderInfo
fieldDelimiter :: Maybe Text
comments :: Maybe Text
allowQuotedRecordDelimiter :: Maybe Bool
$sel:recordDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteEscapeCharacter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteCharacter:CSVInput' :: CSVInput -> Maybe Text
$sel:fileHeaderInfo:CSVInput' :: CSVInput -> Maybe FileHeaderInfo
$sel:fieldDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:comments:CSVInput' :: CSVInput -> Maybe Text
$sel:allowQuotedRecordDelimiter:CSVInput' :: CSVInput -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowQuotedRecordDelimiter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
comments
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 FileHeaderInfo
fileHeaderInfo
      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 Text
recordDelimiter

instance Data.ToXML CSVInput where
  toXML :: CSVInput -> XML
toXML CSVInput' {Maybe Bool
Maybe Text
Maybe FileHeaderInfo
recordDelimiter :: Maybe Text
quoteEscapeCharacter :: Maybe Text
quoteCharacter :: Maybe Text
fileHeaderInfo :: Maybe FileHeaderInfo
fieldDelimiter :: Maybe Text
comments :: Maybe Text
allowQuotedRecordDelimiter :: Maybe Bool
$sel:recordDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteEscapeCharacter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteCharacter:CSVInput' :: CSVInput -> Maybe Text
$sel:fileHeaderInfo:CSVInput' :: CSVInput -> Maybe FileHeaderInfo
$sel:fieldDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:comments:CSVInput' :: CSVInput -> Maybe Text
$sel:allowQuotedRecordDelimiter:CSVInput' :: CSVInput -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"AllowQuotedRecordDelimiter"
          forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Bool
allowQuotedRecordDelimiter,
        Name
"Comments" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
comments,
        Name
"FieldDelimiter" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
fieldDelimiter,
        Name
"FileHeaderInfo" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe FileHeaderInfo
fileHeaderInfo,
        Name
"QuoteCharacter" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
quoteCharacter,
        Name
"QuoteEscapeCharacter" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
quoteEscapeCharacter,
        Name
"RecordDelimiter" forall a. ToXML a => Name -> a -> XML
Data.@= Maybe Text
recordDelimiter
      ]