{-# 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.QuickSight.Types.UploadSettings
-- 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.QuickSight.Types.UploadSettings 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.QuickSight.Types.FileFormat
import Amazonka.QuickSight.Types.TextQualifier

-- | Information about the format for a source file or files.
--
-- /See:/ 'newUploadSettings' smart constructor.
data UploadSettings = UploadSettings'
  { -- | Whether the file has a header row, or the files each have a header row.
    UploadSettings -> Maybe Bool
containsHeader :: Prelude.Maybe Prelude.Bool,
    -- | The delimiter between values in the file.
    UploadSettings -> Maybe Text
delimiter :: Prelude.Maybe Prelude.Text,
    -- | File format.
    UploadSettings -> Maybe FileFormat
format :: Prelude.Maybe FileFormat,
    -- | A row number to start reading data from.
    UploadSettings -> Maybe Natural
startFromRow :: Prelude.Maybe Prelude.Natural,
    -- | Text qualifier.
    UploadSettings -> Maybe TextQualifier
textQualifier :: Prelude.Maybe TextQualifier
  }
  deriving (UploadSettings -> UploadSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UploadSettings -> UploadSettings -> Bool
$c/= :: UploadSettings -> UploadSettings -> Bool
== :: UploadSettings -> UploadSettings -> Bool
$c== :: UploadSettings -> UploadSettings -> Bool
Prelude.Eq, ReadPrec [UploadSettings]
ReadPrec UploadSettings
Int -> ReadS UploadSettings
ReadS [UploadSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UploadSettings]
$creadListPrec :: ReadPrec [UploadSettings]
readPrec :: ReadPrec UploadSettings
$creadPrec :: ReadPrec UploadSettings
readList :: ReadS [UploadSettings]
$creadList :: ReadS [UploadSettings]
readsPrec :: Int -> ReadS UploadSettings
$creadsPrec :: Int -> ReadS UploadSettings
Prelude.Read, Int -> UploadSettings -> ShowS
[UploadSettings] -> ShowS
UploadSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadSettings] -> ShowS
$cshowList :: [UploadSettings] -> ShowS
show :: UploadSettings -> String
$cshow :: UploadSettings -> String
showsPrec :: Int -> UploadSettings -> ShowS
$cshowsPrec :: Int -> UploadSettings -> ShowS
Prelude.Show, forall x. Rep UploadSettings x -> UploadSettings
forall x. UploadSettings -> Rep UploadSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UploadSettings x -> UploadSettings
$cfrom :: forall x. UploadSettings -> Rep UploadSettings x
Prelude.Generic)

-- |
-- Create a value of 'UploadSettings' 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:
--
-- 'containsHeader', 'uploadSettings_containsHeader' - Whether the file has a header row, or the files each have a header row.
--
-- 'delimiter', 'uploadSettings_delimiter' - The delimiter between values in the file.
--
-- 'format', 'uploadSettings_format' - File format.
--
-- 'startFromRow', 'uploadSettings_startFromRow' - A row number to start reading data from.
--
-- 'textQualifier', 'uploadSettings_textQualifier' - Text qualifier.
newUploadSettings ::
  UploadSettings
newUploadSettings :: UploadSettings
newUploadSettings =
  UploadSettings'
    { $sel:containsHeader:UploadSettings' :: Maybe Bool
containsHeader = forall a. Maybe a
Prelude.Nothing,
      $sel:delimiter:UploadSettings' :: Maybe Text
delimiter = forall a. Maybe a
Prelude.Nothing,
      $sel:format:UploadSettings' :: Maybe FileFormat
format = forall a. Maybe a
Prelude.Nothing,
      $sel:startFromRow:UploadSettings' :: Maybe Natural
startFromRow = forall a. Maybe a
Prelude.Nothing,
      $sel:textQualifier:UploadSettings' :: Maybe TextQualifier
textQualifier = forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the file has a header row, or the files each have a header row.
uploadSettings_containsHeader :: Lens.Lens' UploadSettings (Prelude.Maybe Prelude.Bool)
uploadSettings_containsHeader :: Lens' UploadSettings (Maybe Bool)
uploadSettings_containsHeader = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadSettings' {Maybe Bool
containsHeader :: Maybe Bool
$sel:containsHeader:UploadSettings' :: UploadSettings -> Maybe Bool
containsHeader} -> Maybe Bool
containsHeader) (\s :: UploadSettings
s@UploadSettings' {} Maybe Bool
a -> UploadSettings
s {$sel:containsHeader:UploadSettings' :: Maybe Bool
containsHeader = Maybe Bool
a} :: UploadSettings)

-- | The delimiter between values in the file.
uploadSettings_delimiter :: Lens.Lens' UploadSettings (Prelude.Maybe Prelude.Text)
uploadSettings_delimiter :: Lens' UploadSettings (Maybe Text)
uploadSettings_delimiter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadSettings' {Maybe Text
delimiter :: Maybe Text
$sel:delimiter:UploadSettings' :: UploadSettings -> Maybe Text
delimiter} -> Maybe Text
delimiter) (\s :: UploadSettings
s@UploadSettings' {} Maybe Text
a -> UploadSettings
s {$sel:delimiter:UploadSettings' :: Maybe Text
delimiter = Maybe Text
a} :: UploadSettings)

-- | File format.
uploadSettings_format :: Lens.Lens' UploadSettings (Prelude.Maybe FileFormat)
uploadSettings_format :: Lens' UploadSettings (Maybe FileFormat)
uploadSettings_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadSettings' {Maybe FileFormat
format :: Maybe FileFormat
$sel:format:UploadSettings' :: UploadSettings -> Maybe FileFormat
format} -> Maybe FileFormat
format) (\s :: UploadSettings
s@UploadSettings' {} Maybe FileFormat
a -> UploadSettings
s {$sel:format:UploadSettings' :: Maybe FileFormat
format = Maybe FileFormat
a} :: UploadSettings)

-- | A row number to start reading data from.
uploadSettings_startFromRow :: Lens.Lens' UploadSettings (Prelude.Maybe Prelude.Natural)
uploadSettings_startFromRow :: Lens' UploadSettings (Maybe Natural)
uploadSettings_startFromRow = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadSettings' {Maybe Natural
startFromRow :: Maybe Natural
$sel:startFromRow:UploadSettings' :: UploadSettings -> Maybe Natural
startFromRow} -> Maybe Natural
startFromRow) (\s :: UploadSettings
s@UploadSettings' {} Maybe Natural
a -> UploadSettings
s {$sel:startFromRow:UploadSettings' :: Maybe Natural
startFromRow = Maybe Natural
a} :: UploadSettings)

-- | Text qualifier.
uploadSettings_textQualifier :: Lens.Lens' UploadSettings (Prelude.Maybe TextQualifier)
uploadSettings_textQualifier :: Lens' UploadSettings (Maybe TextQualifier)
uploadSettings_textQualifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadSettings' {Maybe TextQualifier
textQualifier :: Maybe TextQualifier
$sel:textQualifier:UploadSettings' :: UploadSettings -> Maybe TextQualifier
textQualifier} -> Maybe TextQualifier
textQualifier) (\s :: UploadSettings
s@UploadSettings' {} Maybe TextQualifier
a -> UploadSettings
s {$sel:textQualifier:UploadSettings' :: Maybe TextQualifier
textQualifier = Maybe TextQualifier
a} :: UploadSettings)

instance Data.FromJSON UploadSettings where
  parseJSON :: Value -> Parser UploadSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UploadSettings"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe FileFormat
-> Maybe Natural
-> Maybe TextQualifier
-> UploadSettings
UploadSettings'
            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
"ContainsHeader")
            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
"Delimiter")
            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
"Format")
            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
"StartFromRow")
            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
"TextQualifier")
      )

instance Prelude.Hashable UploadSettings where
  hashWithSalt :: Int -> UploadSettings -> Int
hashWithSalt Int
_salt UploadSettings' {Maybe Bool
Maybe Natural
Maybe Text
Maybe FileFormat
Maybe TextQualifier
textQualifier :: Maybe TextQualifier
startFromRow :: Maybe Natural
format :: Maybe FileFormat
delimiter :: Maybe Text
containsHeader :: Maybe Bool
$sel:textQualifier:UploadSettings' :: UploadSettings -> Maybe TextQualifier
$sel:startFromRow:UploadSettings' :: UploadSettings -> Maybe Natural
$sel:format:UploadSettings' :: UploadSettings -> Maybe FileFormat
$sel:delimiter:UploadSettings' :: UploadSettings -> Maybe Text
$sel:containsHeader:UploadSettings' :: UploadSettings -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
containsHeader
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
delimiter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FileFormat
format
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
startFromRow
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TextQualifier
textQualifier

instance Prelude.NFData UploadSettings where
  rnf :: UploadSettings -> ()
rnf UploadSettings' {Maybe Bool
Maybe Natural
Maybe Text
Maybe FileFormat
Maybe TextQualifier
textQualifier :: Maybe TextQualifier
startFromRow :: Maybe Natural
format :: Maybe FileFormat
delimiter :: Maybe Text
containsHeader :: Maybe Bool
$sel:textQualifier:UploadSettings' :: UploadSettings -> Maybe TextQualifier
$sel:startFromRow:UploadSettings' :: UploadSettings -> Maybe Natural
$sel:format:UploadSettings' :: UploadSettings -> Maybe FileFormat
$sel:delimiter:UploadSettings' :: UploadSettings -> Maybe Text
$sel:containsHeader:UploadSettings' :: UploadSettings -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
containsHeader
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
delimiter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FileFormat
format
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
startFromRow
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TextQualifier
textQualifier

instance Data.ToJSON UploadSettings where
  toJSON :: UploadSettings -> Value
toJSON UploadSettings' {Maybe Bool
Maybe Natural
Maybe Text
Maybe FileFormat
Maybe TextQualifier
textQualifier :: Maybe TextQualifier
startFromRow :: Maybe Natural
format :: Maybe FileFormat
delimiter :: Maybe Text
containsHeader :: Maybe Bool
$sel:textQualifier:UploadSettings' :: UploadSettings -> Maybe TextQualifier
$sel:startFromRow:UploadSettings' :: UploadSettings -> Maybe Natural
$sel:format:UploadSettings' :: UploadSettings -> Maybe FileFormat
$sel:delimiter:UploadSettings' :: UploadSettings -> Maybe Text
$sel:containsHeader:UploadSettings' :: UploadSettings -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ContainsHeader" 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 Bool
containsHeader,
            (Key
"Delimiter" 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
delimiter,
            (Key
"Format" 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 FileFormat
format,
            (Key
"StartFromRow" 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 Natural
startFromRow,
            (Key
"TextQualifier" 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 TextQualifier
textQualifier
          ]
      )