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

import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types.FileHeaderInfo
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the comma-separated value (CSV) file to
-- select from.
--
-- /See:/ 'newCSVInput' smart constructor.
data CSVInput = CSVInput'
  { -- | A value used as an escape character where the field delimiter is part of
    -- the value.
    CSVInput -> Maybe Text
quoteCharacter :: Prelude.Maybe Prelude.Text,
    -- | A value used to separate individual records from each other.
    CSVInput -> Maybe Text
recordDelimiter :: Prelude.Maybe Prelude.Text,
    -- | Describes the first line of input. Valid values are @None@, @Ignore@,
    -- and @Use@.
    CSVInput -> Maybe FileHeaderInfo
fileHeaderInfo :: Prelude.Maybe FileHeaderInfo,
    -- | A single character used for escaping the quotation-mark character inside
    -- an already escaped value.
    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.
    CSVInput -> Maybe Text
comments :: Prelude.Maybe Prelude.Text,
    -- | A value used to separate individual fields from each other within a
    -- record.
    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 value used as an escape character where the field delimiter is part of
-- the value.
--
-- 'recordDelimiter', 'cSVInput_recordDelimiter' - A value used to separate individual records from each other.
--
-- 'fileHeaderInfo', 'cSVInput_fileHeaderInfo' - Describes the first line of input. Valid values are @None@, @Ignore@,
-- and @Use@.
--
-- 'quoteEscapeCharacter', 'cSVInput_quoteEscapeCharacter' - A single character used for escaping the quotation-mark character inside
-- an already escaped value.
--
-- '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.
--
-- 'fieldDelimiter', 'cSVInput_fieldDelimiter' - A value used to separate individual fields from each other within a
-- record.
newCSVInput ::
  CSVInput
newCSVInput :: CSVInput
newCSVInput =
  CSVInput' :: Maybe Text
-> Maybe Text
-> 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: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 value used as an escape character where the field delimiter is part of
-- the value.
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 value used to separate individual records from each other.
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)

-- | Describes the first line of input. Valid values are @None@, @Ignore@,
-- and @Use@.
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.
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.
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 value used to separate individual fields from each other within a
-- record.
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 Core.FromJSON CSVInput where
  parseJSON :: Value -> Parser CSVInput
parseJSON =
    String -> (Object -> Parser CSVInput) -> Value -> Parser CSVInput
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CSVInput"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe FileHeaderInfo
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> CSVInput
CSVInput'
            (Maybe Text
 -> Maybe Text
 -> Maybe FileHeaderInfo
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> CSVInput)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe FileHeaderInfo
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> CSVInput)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QuoteCharacter")
            Parser
  (Maybe Text
   -> Maybe FileHeaderInfo
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> CSVInput)
-> Parser (Maybe Text)
-> Parser
     (Maybe FileHeaderInfo
      -> Maybe Text -> Maybe Text -> Maybe Text -> CSVInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RecordDelimiter")
            Parser
  (Maybe FileHeaderInfo
   -> Maybe Text -> Maybe Text -> Maybe Text -> CSVInput)
-> Parser (Maybe FileHeaderInfo)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> CSVInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FileHeaderInfo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FileHeaderInfo")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> CSVInput)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> CSVInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"QuoteEscapeCharacter")
            Parser (Maybe Text -> Maybe Text -> CSVInput)
-> Parser (Maybe Text) -> Parser (Maybe Text -> CSVInput)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Comments")
            Parser (Maybe Text -> CSVInput)
-> Parser (Maybe Text) -> Parser CSVInput
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FieldDelimiter")
      )

instance Prelude.Hashable CSVInput

instance Prelude.NFData CSVInput

instance Core.ToJSON CSVInput where
  toJSON :: CSVInput -> Value
toJSON CSVInput' {Maybe Text
Maybe FileHeaderInfo
fieldDelimiter :: Maybe Text
comments :: Maybe Text
quoteEscapeCharacter :: Maybe Text
fileHeaderInfo :: Maybe FileHeaderInfo
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:recordDelimiter:CSVInput' :: CSVInput -> Maybe Text
$sel:quoteCharacter:CSVInput' :: CSVInput -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"QuoteCharacter" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
quoteCharacter,
            (Text
"RecordDelimiter" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
recordDelimiter,
            (Text
"FileHeaderInfo" Text -> FileHeaderInfo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FileHeaderInfo -> Pair) -> Maybe FileHeaderInfo -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileHeaderInfo
fileHeaderInfo,
            (Text
"QuoteEscapeCharacter" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
quoteEscapeCharacter,
            (Text
"Comments" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
comments,
            (Text
"FieldDelimiter" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
fieldDelimiter
          ]
      )