{-# 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-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.S3.Types.CSVInput where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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 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,
    -- | 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,
    -- | 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 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 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
  }
  deriving (CSVInput -> CSVInput -> Bool
(CSVInput -> CSVInput -> Bool)
-> (CSVInput -> CSVInput -> Bool) -> Eq CSVInput
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]
(Int -> ReadS CSVInput)
-> ReadS [CSVInput]
-> ReadPrec CSVInput
-> ReadPrec [CSVInput]
-> Read 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
(Int -> CSVInput -> ShowS)
-> (CSVInput -> String) -> ([CSVInput] -> ShowS) -> Show CSVInput
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. CSVInput -> Rep CSVInput x)
-> (forall x. Rep CSVInput x -> CSVInput) -> Generic CSVInput
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:
--
-- '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@
--
-- '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.
--
-- '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.
--
-- '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@).
--
-- '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 \".
--
-- '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.
newCSVInput ::
  CSVInput
newCSVInput :: CSVInput
newCSVInput =
  CSVInput' :: Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe FileHeaderInfo
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CSVInput
CSVInput'
    { $sel:quoteCharacter:CSVInput' :: Maybe Text
quoteCharacter = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recordDelimiter:CSVInput' :: Maybe Text
recordDelimiter = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:allowQuotedRecordDelimiter:CSVInput' :: Maybe Bool
allowQuotedRecordDelimiter = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:fileHeaderInfo:CSVInput' :: Maybe FileHeaderInfo
fileHeaderInfo = Maybe FileHeaderInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:quoteEscapeCharacter:CSVInput' :: Maybe Text
quoteEscapeCharacter = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:comments:CSVInput' :: Maybe Text
comments = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fieldDelimiter:CSVInput' :: Maybe Text
fieldDelimiter = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> CSVInput -> f CSVInput
cSVInput_quoteCharacter = (CSVInput -> Maybe Text)
-> (CSVInput -> Maybe Text -> CSVInput)
-> Lens CSVInput CSVInput (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> CSVInput -> f CSVInput
cSVInput_recordDelimiter = (CSVInput -> Maybe Text)
-> (CSVInput -> Maybe Text -> CSVInput)
-> Lens CSVInput CSVInput (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> CSVInput -> f CSVInput
cSVInput_allowQuotedRecordDelimiter = (CSVInput -> Maybe Bool)
-> (CSVInput -> Maybe Bool -> CSVInput)
-> Lens CSVInput CSVInput (Maybe Bool) (Maybe Bool)
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)

-- | 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 :: (Maybe FileHeaderInfo -> f (Maybe FileHeaderInfo))
-> CSVInput -> f CSVInput
cSVInput_fileHeaderInfo = (CSVInput -> Maybe FileHeaderInfo)
-> (CSVInput -> Maybe FileHeaderInfo -> CSVInput)
-> Lens
     CSVInput CSVInput (Maybe FileHeaderInfo) (Maybe 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 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 :: (Maybe Text -> f (Maybe Text)) -> CSVInput -> f CSVInput
cSVInput_quoteEscapeCharacter = (CSVInput -> Maybe Text)
-> (CSVInput -> Maybe Text -> CSVInput)
-> Lens CSVInput CSVInput (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> CSVInput -> f CSVInput
cSVInput_comments = (CSVInput -> Maybe Text)
-> (CSVInput -> Maybe Text -> CSVInput)
-> Lens CSVInput CSVInput (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> CSVInput -> f CSVInput
cSVInput_fieldDelimiter = (CSVInput -> Maybe Text)
-> (CSVInput -> Maybe Text -> CSVInput)
-> Lens CSVInput CSVInput (Maybe Text) (Maybe Text)
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)

instance Prelude.Hashable CSVInput

instance Prelude.NFData CSVInput

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