{-# 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-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.QuickSight.Types.UploadSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | A row number to start reading data from.
    UploadSettings -> Maybe Natural
startFromRow :: Prelude.Maybe Prelude.Natural,
    -- | Whether the file has a header row, or the files each have a header row.
    UploadSettings -> Maybe Bool
containsHeader :: Prelude.Maybe Prelude.Bool,
    -- | Text qualifier.
    UploadSettings -> Maybe TextQualifier
textQualifier :: Prelude.Maybe TextQualifier,
    -- | File format.
    UploadSettings -> Maybe FileFormat
format :: Prelude.Maybe FileFormat,
    -- | The delimiter between values in the file.
    UploadSettings -> Maybe Text
delimiter :: Prelude.Maybe Prelude.Text
  }
  deriving (UploadSettings -> UploadSettings -> Bool
(UploadSettings -> UploadSettings -> Bool)
-> (UploadSettings -> UploadSettings -> Bool) -> Eq UploadSettings
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]
(Int -> ReadS UploadSettings)
-> ReadS [UploadSettings]
-> ReadPrec UploadSettings
-> ReadPrec [UploadSettings]
-> Read 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
(Int -> UploadSettings -> ShowS)
-> (UploadSettings -> String)
-> ([UploadSettings] -> ShowS)
-> Show UploadSettings
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. UploadSettings -> Rep UploadSettings x)
-> (forall x. Rep UploadSettings x -> UploadSettings)
-> Generic UploadSettings
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:
--
-- 'startFromRow', 'uploadSettings_startFromRow' - A row number to start reading data from.
--
-- 'containsHeader', 'uploadSettings_containsHeader' - Whether the file has a header row, or the files each have a header row.
--
-- 'textQualifier', 'uploadSettings_textQualifier' - Text qualifier.
--
-- 'format', 'uploadSettings_format' - File format.
--
-- 'delimiter', 'uploadSettings_delimiter' - The delimiter between values in the file.
newUploadSettings ::
  UploadSettings
newUploadSettings :: UploadSettings
newUploadSettings =
  UploadSettings' :: Maybe Natural
-> Maybe Bool
-> Maybe TextQualifier
-> Maybe FileFormat
-> Maybe Text
-> UploadSettings
UploadSettings'
    { $sel:startFromRow:UploadSettings' :: Maybe Natural
startFromRow = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:containsHeader:UploadSettings' :: Maybe Bool
containsHeader = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:textQualifier:UploadSettings' :: Maybe TextQualifier
textQualifier = Maybe TextQualifier
forall a. Maybe a
Prelude.Nothing,
      $sel:format:UploadSettings' :: Maybe FileFormat
format = Maybe FileFormat
forall a. Maybe a
Prelude.Nothing,
      $sel:delimiter:UploadSettings' :: Maybe Text
delimiter = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A row number to start reading data from.
uploadSettings_startFromRow :: Lens.Lens' UploadSettings (Prelude.Maybe Prelude.Natural)
uploadSettings_startFromRow :: (Maybe Natural -> f (Maybe Natural))
-> UploadSettings -> f UploadSettings
uploadSettings_startFromRow = (UploadSettings -> Maybe Natural)
-> (UploadSettings -> Maybe Natural -> UploadSettings)
-> Lens
     UploadSettings UploadSettings (Maybe Natural) (Maybe Natural)
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)

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

-- | Text qualifier.
uploadSettings_textQualifier :: Lens.Lens' UploadSettings (Prelude.Maybe TextQualifier)
uploadSettings_textQualifier :: (Maybe TextQualifier -> f (Maybe TextQualifier))
-> UploadSettings -> f UploadSettings
uploadSettings_textQualifier = (UploadSettings -> Maybe TextQualifier)
-> (UploadSettings -> Maybe TextQualifier -> UploadSettings)
-> Lens
     UploadSettings
     UploadSettings
     (Maybe TextQualifier)
     (Maybe 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)

-- | File format.
uploadSettings_format :: Lens.Lens' UploadSettings (Prelude.Maybe FileFormat)
uploadSettings_format :: (Maybe FileFormat -> f (Maybe FileFormat))
-> UploadSettings -> f UploadSettings
uploadSettings_format = (UploadSettings -> Maybe FileFormat)
-> (UploadSettings -> Maybe FileFormat -> UploadSettings)
-> Lens
     UploadSettings UploadSettings (Maybe FileFormat) (Maybe FileFormat)
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)

-- | The delimiter between values in the file.
uploadSettings_delimiter :: Lens.Lens' UploadSettings (Prelude.Maybe Prelude.Text)
uploadSettings_delimiter :: (Maybe Text -> f (Maybe Text))
-> UploadSettings -> f UploadSettings
uploadSettings_delimiter = (UploadSettings -> Maybe Text)
-> (UploadSettings -> Maybe Text -> UploadSettings)
-> Lens UploadSettings UploadSettings (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON UploadSettings where
  parseJSON :: Value -> Parser UploadSettings
parseJSON =
    String
-> (Object -> Parser UploadSettings)
-> Value
-> Parser UploadSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UploadSettings"
      ( \Object
x ->
          Maybe Natural
-> Maybe Bool
-> Maybe TextQualifier
-> Maybe FileFormat
-> Maybe Text
-> UploadSettings
UploadSettings'
            (Maybe Natural
 -> Maybe Bool
 -> Maybe TextQualifier
 -> Maybe FileFormat
 -> Maybe Text
 -> UploadSettings)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Bool
      -> Maybe TextQualifier
      -> Maybe FileFormat
      -> Maybe Text
      -> UploadSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartFromRow")
            Parser
  (Maybe Bool
   -> Maybe TextQualifier
   -> Maybe FileFormat
   -> Maybe Text
   -> UploadSettings)
-> Parser (Maybe Bool)
-> Parser
     (Maybe TextQualifier
      -> Maybe FileFormat -> Maybe Text -> UploadSettings)
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
"ContainsHeader")
            Parser
  (Maybe TextQualifier
   -> Maybe FileFormat -> Maybe Text -> UploadSettings)
-> Parser (Maybe TextQualifier)
-> Parser (Maybe FileFormat -> Maybe Text -> UploadSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TextQualifier)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TextQualifier")
            Parser (Maybe FileFormat -> Maybe Text -> UploadSettings)
-> Parser (Maybe FileFormat)
-> Parser (Maybe Text -> UploadSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FileFormat)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Format")
            Parser (Maybe Text -> UploadSettings)
-> Parser (Maybe Text) -> Parser UploadSettings
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
"Delimiter")
      )

instance Prelude.Hashable UploadSettings

instance Prelude.NFData UploadSettings

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