{-# 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.HoneyCode.Types.DelimitedTextImportOptions
-- 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.HoneyCode.Types.DelimitedTextImportOptions where

import qualified Amazonka.Core as Core
import Amazonka.HoneyCode.Types.ImportDataCharacterEncoding
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that contains the options relating to parsing delimited text
-- as part of an import request.
--
-- /See:/ 'newDelimitedTextImportOptions' smart constructor.
data DelimitedTextImportOptions = DelimitedTextImportOptions'
  { -- | A parameter to indicate whether empty rows should be ignored or be
    -- included in the import.
    DelimitedTextImportOptions -> Maybe Bool
ignoreEmptyRows :: Prelude.Maybe Prelude.Bool,
    -- | Indicates whether the input file has a header row at the top containing
    -- the column names.
    DelimitedTextImportOptions -> Maybe Bool
hasHeaderRow :: Prelude.Maybe Prelude.Bool,
    -- | The encoding of the data in the input file.
    DelimitedTextImportOptions -> Maybe ImportDataCharacterEncoding
dataCharacterEncoding :: Prelude.Maybe ImportDataCharacterEncoding,
    -- | The delimiter to use for separating columns in a single row of the
    -- input.
    DelimitedTextImportOptions -> Text
delimiter :: Prelude.Text
  }
  deriving (DelimitedTextImportOptions -> DelimitedTextImportOptions -> Bool
(DelimitedTextImportOptions -> DelimitedTextImportOptions -> Bool)
-> (DelimitedTextImportOptions
    -> DelimitedTextImportOptions -> Bool)
-> Eq DelimitedTextImportOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DelimitedTextImportOptions -> DelimitedTextImportOptions -> Bool
$c/= :: DelimitedTextImportOptions -> DelimitedTextImportOptions -> Bool
== :: DelimitedTextImportOptions -> DelimitedTextImportOptions -> Bool
$c== :: DelimitedTextImportOptions -> DelimitedTextImportOptions -> Bool
Prelude.Eq, ReadPrec [DelimitedTextImportOptions]
ReadPrec DelimitedTextImportOptions
Int -> ReadS DelimitedTextImportOptions
ReadS [DelimitedTextImportOptions]
(Int -> ReadS DelimitedTextImportOptions)
-> ReadS [DelimitedTextImportOptions]
-> ReadPrec DelimitedTextImportOptions
-> ReadPrec [DelimitedTextImportOptions]
-> Read DelimitedTextImportOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DelimitedTextImportOptions]
$creadListPrec :: ReadPrec [DelimitedTextImportOptions]
readPrec :: ReadPrec DelimitedTextImportOptions
$creadPrec :: ReadPrec DelimitedTextImportOptions
readList :: ReadS [DelimitedTextImportOptions]
$creadList :: ReadS [DelimitedTextImportOptions]
readsPrec :: Int -> ReadS DelimitedTextImportOptions
$creadsPrec :: Int -> ReadS DelimitedTextImportOptions
Prelude.Read, Int -> DelimitedTextImportOptions -> ShowS
[DelimitedTextImportOptions] -> ShowS
DelimitedTextImportOptions -> String
(Int -> DelimitedTextImportOptions -> ShowS)
-> (DelimitedTextImportOptions -> String)
-> ([DelimitedTextImportOptions] -> ShowS)
-> Show DelimitedTextImportOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DelimitedTextImportOptions] -> ShowS
$cshowList :: [DelimitedTextImportOptions] -> ShowS
show :: DelimitedTextImportOptions -> String
$cshow :: DelimitedTextImportOptions -> String
showsPrec :: Int -> DelimitedTextImportOptions -> ShowS
$cshowsPrec :: Int -> DelimitedTextImportOptions -> ShowS
Prelude.Show, (forall x.
 DelimitedTextImportOptions -> Rep DelimitedTextImportOptions x)
-> (forall x.
    Rep DelimitedTextImportOptions x -> DelimitedTextImportOptions)
-> Generic DelimitedTextImportOptions
forall x.
Rep DelimitedTextImportOptions x -> DelimitedTextImportOptions
forall x.
DelimitedTextImportOptions -> Rep DelimitedTextImportOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DelimitedTextImportOptions x -> DelimitedTextImportOptions
$cfrom :: forall x.
DelimitedTextImportOptions -> Rep DelimitedTextImportOptions x
Prelude.Generic)

-- |
-- Create a value of 'DelimitedTextImportOptions' 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:
--
-- 'ignoreEmptyRows', 'delimitedTextImportOptions_ignoreEmptyRows' - A parameter to indicate whether empty rows should be ignored or be
-- included in the import.
--
-- 'hasHeaderRow', 'delimitedTextImportOptions_hasHeaderRow' - Indicates whether the input file has a header row at the top containing
-- the column names.
--
-- 'dataCharacterEncoding', 'delimitedTextImportOptions_dataCharacterEncoding' - The encoding of the data in the input file.
--
-- 'delimiter', 'delimitedTextImportOptions_delimiter' - The delimiter to use for separating columns in a single row of the
-- input.
newDelimitedTextImportOptions ::
  -- | 'delimiter'
  Prelude.Text ->
  DelimitedTextImportOptions
newDelimitedTextImportOptions :: Text -> DelimitedTextImportOptions
newDelimitedTextImportOptions Text
pDelimiter_ =
  DelimitedTextImportOptions' :: Maybe Bool
-> Maybe Bool
-> Maybe ImportDataCharacterEncoding
-> Text
-> DelimitedTextImportOptions
DelimitedTextImportOptions'
    { $sel:ignoreEmptyRows:DelimitedTextImportOptions' :: Maybe Bool
ignoreEmptyRows =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:hasHeaderRow:DelimitedTextImportOptions' :: Maybe Bool
hasHeaderRow = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:dataCharacterEncoding:DelimitedTextImportOptions' :: Maybe ImportDataCharacterEncoding
dataCharacterEncoding = Maybe ImportDataCharacterEncoding
forall a. Maybe a
Prelude.Nothing,
      $sel:delimiter:DelimitedTextImportOptions' :: Text
delimiter = Text
pDelimiter_
    }

-- | A parameter to indicate whether empty rows should be ignored or be
-- included in the import.
delimitedTextImportOptions_ignoreEmptyRows :: Lens.Lens' DelimitedTextImportOptions (Prelude.Maybe Prelude.Bool)
delimitedTextImportOptions_ignoreEmptyRows :: (Maybe Bool -> f (Maybe Bool))
-> DelimitedTextImportOptions -> f DelimitedTextImportOptions
delimitedTextImportOptions_ignoreEmptyRows = (DelimitedTextImportOptions -> Maybe Bool)
-> (DelimitedTextImportOptions
    -> Maybe Bool -> DelimitedTextImportOptions)
-> Lens
     DelimitedTextImportOptions
     DelimitedTextImportOptions
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelimitedTextImportOptions' {Maybe Bool
ignoreEmptyRows :: Maybe Bool
$sel:ignoreEmptyRows:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Maybe Bool
ignoreEmptyRows} -> Maybe Bool
ignoreEmptyRows) (\s :: DelimitedTextImportOptions
s@DelimitedTextImportOptions' {} Maybe Bool
a -> DelimitedTextImportOptions
s {$sel:ignoreEmptyRows:DelimitedTextImportOptions' :: Maybe Bool
ignoreEmptyRows = Maybe Bool
a} :: DelimitedTextImportOptions)

-- | Indicates whether the input file has a header row at the top containing
-- the column names.
delimitedTextImportOptions_hasHeaderRow :: Lens.Lens' DelimitedTextImportOptions (Prelude.Maybe Prelude.Bool)
delimitedTextImportOptions_hasHeaderRow :: (Maybe Bool -> f (Maybe Bool))
-> DelimitedTextImportOptions -> f DelimitedTextImportOptions
delimitedTextImportOptions_hasHeaderRow = (DelimitedTextImportOptions -> Maybe Bool)
-> (DelimitedTextImportOptions
    -> Maybe Bool -> DelimitedTextImportOptions)
-> Lens
     DelimitedTextImportOptions
     DelimitedTextImportOptions
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelimitedTextImportOptions' {Maybe Bool
hasHeaderRow :: Maybe Bool
$sel:hasHeaderRow:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Maybe Bool
hasHeaderRow} -> Maybe Bool
hasHeaderRow) (\s :: DelimitedTextImportOptions
s@DelimitedTextImportOptions' {} Maybe Bool
a -> DelimitedTextImportOptions
s {$sel:hasHeaderRow:DelimitedTextImportOptions' :: Maybe Bool
hasHeaderRow = Maybe Bool
a} :: DelimitedTextImportOptions)

-- | The encoding of the data in the input file.
delimitedTextImportOptions_dataCharacterEncoding :: Lens.Lens' DelimitedTextImportOptions (Prelude.Maybe ImportDataCharacterEncoding)
delimitedTextImportOptions_dataCharacterEncoding :: (Maybe ImportDataCharacterEncoding
 -> f (Maybe ImportDataCharacterEncoding))
-> DelimitedTextImportOptions -> f DelimitedTextImportOptions
delimitedTextImportOptions_dataCharacterEncoding = (DelimitedTextImportOptions -> Maybe ImportDataCharacterEncoding)
-> (DelimitedTextImportOptions
    -> Maybe ImportDataCharacterEncoding -> DelimitedTextImportOptions)
-> Lens
     DelimitedTextImportOptions
     DelimitedTextImportOptions
     (Maybe ImportDataCharacterEncoding)
     (Maybe ImportDataCharacterEncoding)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelimitedTextImportOptions' {Maybe ImportDataCharacterEncoding
dataCharacterEncoding :: Maybe ImportDataCharacterEncoding
$sel:dataCharacterEncoding:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Maybe ImportDataCharacterEncoding
dataCharacterEncoding} -> Maybe ImportDataCharacterEncoding
dataCharacterEncoding) (\s :: DelimitedTextImportOptions
s@DelimitedTextImportOptions' {} Maybe ImportDataCharacterEncoding
a -> DelimitedTextImportOptions
s {$sel:dataCharacterEncoding:DelimitedTextImportOptions' :: Maybe ImportDataCharacterEncoding
dataCharacterEncoding = Maybe ImportDataCharacterEncoding
a} :: DelimitedTextImportOptions)

-- | The delimiter to use for separating columns in a single row of the
-- input.
delimitedTextImportOptions_delimiter :: Lens.Lens' DelimitedTextImportOptions Prelude.Text
delimitedTextImportOptions_delimiter :: (Text -> f Text)
-> DelimitedTextImportOptions -> f DelimitedTextImportOptions
delimitedTextImportOptions_delimiter = (DelimitedTextImportOptions -> Text)
-> (DelimitedTextImportOptions
    -> Text -> DelimitedTextImportOptions)
-> Lens
     DelimitedTextImportOptions DelimitedTextImportOptions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DelimitedTextImportOptions' {Text
delimiter :: Text
$sel:delimiter:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Text
delimiter} -> Text
delimiter) (\s :: DelimitedTextImportOptions
s@DelimitedTextImportOptions' {} Text
a -> DelimitedTextImportOptions
s {$sel:delimiter:DelimitedTextImportOptions' :: Text
delimiter = Text
a} :: DelimitedTextImportOptions)

instance Core.FromJSON DelimitedTextImportOptions where
  parseJSON :: Value -> Parser DelimitedTextImportOptions
parseJSON =
    String
-> (Object -> Parser DelimitedTextImportOptions)
-> Value
-> Parser DelimitedTextImportOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DelimitedTextImportOptions"
      ( \Object
x ->
          Maybe Bool
-> Maybe Bool
-> Maybe ImportDataCharacterEncoding
-> Text
-> DelimitedTextImportOptions
DelimitedTextImportOptions'
            (Maybe Bool
 -> Maybe Bool
 -> Maybe ImportDataCharacterEncoding
 -> Text
 -> DelimitedTextImportOptions)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe ImportDataCharacterEncoding
      -> Text
      -> DelimitedTextImportOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ignoreEmptyRows")
            Parser
  (Maybe Bool
   -> Maybe ImportDataCharacterEncoding
   -> Text
   -> DelimitedTextImportOptions)
-> Parser (Maybe Bool)
-> Parser
     (Maybe ImportDataCharacterEncoding
      -> Text -> DelimitedTextImportOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"hasHeaderRow")
            Parser
  (Maybe ImportDataCharacterEncoding
   -> Text -> DelimitedTextImportOptions)
-> Parser (Maybe ImportDataCharacterEncoding)
-> Parser (Text -> DelimitedTextImportOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ImportDataCharacterEncoding)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dataCharacterEncoding")
            Parser (Text -> DelimitedTextImportOptions)
-> Parser Text -> Parser DelimitedTextImportOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"delimiter")
      )

instance Prelude.Hashable DelimitedTextImportOptions

instance Prelude.NFData DelimitedTextImportOptions

instance Core.ToJSON DelimitedTextImportOptions where
  toJSON :: DelimitedTextImportOptions -> Value
toJSON DelimitedTextImportOptions' {Maybe Bool
Maybe ImportDataCharacterEncoding
Text
delimiter :: Text
dataCharacterEncoding :: Maybe ImportDataCharacterEncoding
hasHeaderRow :: Maybe Bool
ignoreEmptyRows :: Maybe Bool
$sel:delimiter:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Text
$sel:dataCharacterEncoding:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Maybe ImportDataCharacterEncoding
$sel:hasHeaderRow:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Maybe Bool
$sel:ignoreEmptyRows:DelimitedTextImportOptions' :: DelimitedTextImportOptions -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ignoreEmptyRows" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
ignoreEmptyRows,
            (Text
"hasHeaderRow" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
hasHeaderRow,
            (Text
"dataCharacterEncoding" Text -> ImportDataCharacterEncoding -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ImportDataCharacterEncoding -> Pair)
-> Maybe ImportDataCharacterEncoding -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ImportDataCharacterEncoding
dataCharacterEncoding,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"delimiter" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
delimiter)
          ]
      )