{-# 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.S3Source
-- 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.S3Source where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.InputColumn
import Amazonka.QuickSight.Types.UploadSettings

-- | A physical table type for an S3 data source.
--
-- /See:/ 'newS3Source' smart constructor.
data S3Source = S3Source'
  { -- | Information about the format for the S3 source file or files.
    S3Source -> Maybe UploadSettings
uploadSettings :: Prelude.Maybe UploadSettings,
    -- | The Amazon Resource Name (ARN) for the data source.
    S3Source -> Text
dataSourceArn :: Prelude.Text,
    -- | A physical table type for an S3 data source.
    --
    -- For files that aren\'t JSON, only @STRING@ data types are supported in
    -- input columns.
    S3Source -> NonEmpty InputColumn
inputColumns :: Prelude.NonEmpty InputColumn
  }
  deriving (S3Source -> S3Source -> Bool
(S3Source -> S3Source -> Bool)
-> (S3Source -> S3Source -> Bool) -> Eq S3Source
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Source -> S3Source -> Bool
$c/= :: S3Source -> S3Source -> Bool
== :: S3Source -> S3Source -> Bool
$c== :: S3Source -> S3Source -> Bool
Prelude.Eq, ReadPrec [S3Source]
ReadPrec S3Source
Int -> ReadS S3Source
ReadS [S3Source]
(Int -> ReadS S3Source)
-> ReadS [S3Source]
-> ReadPrec S3Source
-> ReadPrec [S3Source]
-> Read S3Source
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Source]
$creadListPrec :: ReadPrec [S3Source]
readPrec :: ReadPrec S3Source
$creadPrec :: ReadPrec S3Source
readList :: ReadS [S3Source]
$creadList :: ReadS [S3Source]
readsPrec :: Int -> ReadS S3Source
$creadsPrec :: Int -> ReadS S3Source
Prelude.Read, Int -> S3Source -> ShowS
[S3Source] -> ShowS
S3Source -> String
(Int -> S3Source -> ShowS)
-> (S3Source -> String) -> ([S3Source] -> ShowS) -> Show S3Source
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Source] -> ShowS
$cshowList :: [S3Source] -> ShowS
show :: S3Source -> String
$cshow :: S3Source -> String
showsPrec :: Int -> S3Source -> ShowS
$cshowsPrec :: Int -> S3Source -> ShowS
Prelude.Show, (forall x. S3Source -> Rep S3Source x)
-> (forall x. Rep S3Source x -> S3Source) -> Generic S3Source
forall x. Rep S3Source x -> S3Source
forall x. S3Source -> Rep S3Source x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Source x -> S3Source
$cfrom :: forall x. S3Source -> Rep S3Source x
Prelude.Generic)

-- |
-- Create a value of 'S3Source' 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:
--
-- 'uploadSettings', 's3Source_uploadSettings' - Information about the format for the S3 source file or files.
--
-- 'dataSourceArn', 's3Source_dataSourceArn' - The Amazon Resource Name (ARN) for the data source.
--
-- 'inputColumns', 's3Source_inputColumns' - A physical table type for an S3 data source.
--
-- For files that aren\'t JSON, only @STRING@ data types are supported in
-- input columns.
newS3Source ::
  -- | 'dataSourceArn'
  Prelude.Text ->
  -- | 'inputColumns'
  Prelude.NonEmpty InputColumn ->
  S3Source
newS3Source :: Text -> NonEmpty InputColumn -> S3Source
newS3Source Text
pDataSourceArn_ NonEmpty InputColumn
pInputColumns_ =
  S3Source' :: Maybe UploadSettings -> Text -> NonEmpty InputColumn -> S3Source
S3Source'
    { $sel:uploadSettings:S3Source' :: Maybe UploadSettings
uploadSettings = Maybe UploadSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:dataSourceArn:S3Source' :: Text
dataSourceArn = Text
pDataSourceArn_,
      $sel:inputColumns:S3Source' :: NonEmpty InputColumn
inputColumns = Tagged (NonEmpty InputColumn) (Identity (NonEmpty InputColumn))
-> Tagged (NonEmpty InputColumn) (Identity (NonEmpty InputColumn))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty InputColumn) (Identity (NonEmpty InputColumn))
 -> Tagged (NonEmpty InputColumn) (Identity (NonEmpty InputColumn)))
-> NonEmpty InputColumn -> NonEmpty InputColumn
forall t b. AReview t b -> b -> t
Lens.# NonEmpty InputColumn
pInputColumns_
    }

-- | Information about the format for the S3 source file or files.
s3Source_uploadSettings :: Lens.Lens' S3Source (Prelude.Maybe UploadSettings)
s3Source_uploadSettings :: (Maybe UploadSettings -> f (Maybe UploadSettings))
-> S3Source -> f S3Source
s3Source_uploadSettings = (S3Source -> Maybe UploadSettings)
-> (S3Source -> Maybe UploadSettings -> S3Source)
-> Lens
     S3Source S3Source (Maybe UploadSettings) (Maybe UploadSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Source' {Maybe UploadSettings
uploadSettings :: Maybe UploadSettings
$sel:uploadSettings:S3Source' :: S3Source -> Maybe UploadSettings
uploadSettings} -> Maybe UploadSettings
uploadSettings) (\s :: S3Source
s@S3Source' {} Maybe UploadSettings
a -> S3Source
s {$sel:uploadSettings:S3Source' :: Maybe UploadSettings
uploadSettings = Maybe UploadSettings
a} :: S3Source)

-- | The Amazon Resource Name (ARN) for the data source.
s3Source_dataSourceArn :: Lens.Lens' S3Source Prelude.Text
s3Source_dataSourceArn :: (Text -> f Text) -> S3Source -> f S3Source
s3Source_dataSourceArn = (S3Source -> Text)
-> (S3Source -> Text -> S3Source)
-> Lens S3Source S3Source Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Source' {Text
dataSourceArn :: Text
$sel:dataSourceArn:S3Source' :: S3Source -> Text
dataSourceArn} -> Text
dataSourceArn) (\s :: S3Source
s@S3Source' {} Text
a -> S3Source
s {$sel:dataSourceArn:S3Source' :: Text
dataSourceArn = Text
a} :: S3Source)

-- | A physical table type for an S3 data source.
--
-- For files that aren\'t JSON, only @STRING@ data types are supported in
-- input columns.
s3Source_inputColumns :: Lens.Lens' S3Source (Prelude.NonEmpty InputColumn)
s3Source_inputColumns :: (NonEmpty InputColumn -> f (NonEmpty InputColumn))
-> S3Source -> f S3Source
s3Source_inputColumns = (S3Source -> NonEmpty InputColumn)
-> (S3Source -> NonEmpty InputColumn -> S3Source)
-> Lens
     S3Source S3Source (NonEmpty InputColumn) (NonEmpty InputColumn)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Source' {NonEmpty InputColumn
inputColumns :: NonEmpty InputColumn
$sel:inputColumns:S3Source' :: S3Source -> NonEmpty InputColumn
inputColumns} -> NonEmpty InputColumn
inputColumns) (\s :: S3Source
s@S3Source' {} NonEmpty InputColumn
a -> S3Source
s {$sel:inputColumns:S3Source' :: NonEmpty InputColumn
inputColumns = NonEmpty InputColumn
a} :: S3Source) ((NonEmpty InputColumn -> f (NonEmpty InputColumn))
 -> S3Source -> f S3Source)
-> ((NonEmpty InputColumn -> f (NonEmpty InputColumn))
    -> NonEmpty InputColumn -> f (NonEmpty InputColumn))
-> (NonEmpty InputColumn -> f (NonEmpty InputColumn))
-> S3Source
-> f S3Source
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty InputColumn -> f (NonEmpty InputColumn))
-> NonEmpty InputColumn -> f (NonEmpty InputColumn)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON S3Source where
  parseJSON :: Value -> Parser S3Source
parseJSON =
    String -> (Object -> Parser S3Source) -> Value -> Parser S3Source
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3Source"
      ( \Object
x ->
          Maybe UploadSettings -> Text -> NonEmpty InputColumn -> S3Source
S3Source'
            (Maybe UploadSettings -> Text -> NonEmpty InputColumn -> S3Source)
-> Parser (Maybe UploadSettings)
-> Parser (Text -> NonEmpty InputColumn -> S3Source)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe UploadSettings)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UploadSettings")
            Parser (Text -> NonEmpty InputColumn -> S3Source)
-> Parser Text -> Parser (NonEmpty InputColumn -> S3Source)
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
"DataSourceArn")
            Parser (NonEmpty InputColumn -> S3Source)
-> Parser (NonEmpty InputColumn) -> Parser S3Source
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty InputColumn)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"InputColumns")
      )

instance Prelude.Hashable S3Source

instance Prelude.NFData S3Source

instance Core.ToJSON S3Source where
  toJSON :: S3Source -> Value
toJSON S3Source' {Maybe UploadSettings
NonEmpty InputColumn
Text
inputColumns :: NonEmpty InputColumn
dataSourceArn :: Text
uploadSettings :: Maybe UploadSettings
$sel:inputColumns:S3Source' :: S3Source -> NonEmpty InputColumn
$sel:dataSourceArn:S3Source' :: S3Source -> Text
$sel:uploadSettings:S3Source' :: S3Source -> Maybe UploadSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UploadSettings" Text -> UploadSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UploadSettings -> Pair) -> Maybe UploadSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UploadSettings
uploadSettings,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DataSourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
dataSourceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InputColumns" Text -> NonEmpty InputColumn -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty InputColumn
inputColumns)
          ]
      )