{-# 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.KinesisAnalyticsV2.Types.S3Configuration
-- 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.KinesisAnalyticsV2.Types.S3Configuration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | For a SQL-based Kinesis Data Analytics application, provides a
-- description of an Amazon S3 data source, including the Amazon Resource
-- Name (ARN) of the S3 bucket and the name of the Amazon S3 object that
-- contains the data.
--
-- /See:/ 'newS3Configuration' smart constructor.
data S3Configuration = S3Configuration'
  { -- | The ARN of the S3 bucket that contains the data.
    S3Configuration -> Text
bucketARN :: Prelude.Text,
    -- | The name of the object that contains the data.
    S3Configuration -> Text
fileKey :: Prelude.Text
  }
  deriving (S3Configuration -> S3Configuration -> Bool
(S3Configuration -> S3Configuration -> Bool)
-> (S3Configuration -> S3Configuration -> Bool)
-> Eq S3Configuration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Configuration -> S3Configuration -> Bool
$c/= :: S3Configuration -> S3Configuration -> Bool
== :: S3Configuration -> S3Configuration -> Bool
$c== :: S3Configuration -> S3Configuration -> Bool
Prelude.Eq, ReadPrec [S3Configuration]
ReadPrec S3Configuration
Int -> ReadS S3Configuration
ReadS [S3Configuration]
(Int -> ReadS S3Configuration)
-> ReadS [S3Configuration]
-> ReadPrec S3Configuration
-> ReadPrec [S3Configuration]
-> Read S3Configuration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Configuration]
$creadListPrec :: ReadPrec [S3Configuration]
readPrec :: ReadPrec S3Configuration
$creadPrec :: ReadPrec S3Configuration
readList :: ReadS [S3Configuration]
$creadList :: ReadS [S3Configuration]
readsPrec :: Int -> ReadS S3Configuration
$creadsPrec :: Int -> ReadS S3Configuration
Prelude.Read, Int -> S3Configuration -> ShowS
[S3Configuration] -> ShowS
S3Configuration -> String
(Int -> S3Configuration -> ShowS)
-> (S3Configuration -> String)
-> ([S3Configuration] -> ShowS)
-> Show S3Configuration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Configuration] -> ShowS
$cshowList :: [S3Configuration] -> ShowS
show :: S3Configuration -> String
$cshow :: S3Configuration -> String
showsPrec :: Int -> S3Configuration -> ShowS
$cshowsPrec :: Int -> S3Configuration -> ShowS
Prelude.Show, (forall x. S3Configuration -> Rep S3Configuration x)
-> (forall x. Rep S3Configuration x -> S3Configuration)
-> Generic S3Configuration
forall x. Rep S3Configuration x -> S3Configuration
forall x. S3Configuration -> Rep S3Configuration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Configuration x -> S3Configuration
$cfrom :: forall x. S3Configuration -> Rep S3Configuration x
Prelude.Generic)

-- |
-- Create a value of 'S3Configuration' 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:
--
-- 'bucketARN', 's3Configuration_bucketARN' - The ARN of the S3 bucket that contains the data.
--
-- 'fileKey', 's3Configuration_fileKey' - The name of the object that contains the data.
newS3Configuration ::
  -- | 'bucketARN'
  Prelude.Text ->
  -- | 'fileKey'
  Prelude.Text ->
  S3Configuration
newS3Configuration :: Text -> Text -> S3Configuration
newS3Configuration Text
pBucketARN_ Text
pFileKey_ =
  S3Configuration' :: Text -> Text -> S3Configuration
S3Configuration'
    { $sel:bucketARN:S3Configuration' :: Text
bucketARN = Text
pBucketARN_,
      $sel:fileKey:S3Configuration' :: Text
fileKey = Text
pFileKey_
    }

-- | The ARN of the S3 bucket that contains the data.
s3Configuration_bucketARN :: Lens.Lens' S3Configuration Prelude.Text
s3Configuration_bucketARN :: (Text -> f Text) -> S3Configuration -> f S3Configuration
s3Configuration_bucketARN = (S3Configuration -> Text)
-> (S3Configuration -> Text -> S3Configuration)
-> Lens S3Configuration S3Configuration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Text
bucketARN :: Text
$sel:bucketARN:S3Configuration' :: S3Configuration -> Text
bucketARN} -> Text
bucketARN) (\s :: S3Configuration
s@S3Configuration' {} Text
a -> S3Configuration
s {$sel:bucketARN:S3Configuration' :: Text
bucketARN = Text
a} :: S3Configuration)

-- | The name of the object that contains the data.
s3Configuration_fileKey :: Lens.Lens' S3Configuration Prelude.Text
s3Configuration_fileKey :: (Text -> f Text) -> S3Configuration -> f S3Configuration
s3Configuration_fileKey = (S3Configuration -> Text)
-> (S3Configuration -> Text -> S3Configuration)
-> Lens S3Configuration S3Configuration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Configuration' {Text
fileKey :: Text
$sel:fileKey:S3Configuration' :: S3Configuration -> Text
fileKey} -> Text
fileKey) (\s :: S3Configuration
s@S3Configuration' {} Text
a -> S3Configuration
s {$sel:fileKey:S3Configuration' :: Text
fileKey = Text
a} :: S3Configuration)

instance Prelude.Hashable S3Configuration

instance Prelude.NFData S3Configuration

instance Core.ToJSON S3Configuration where
  toJSON :: S3Configuration -> Value
toJSON S3Configuration' {Text
fileKey :: Text
bucketARN :: Text
$sel:fileKey:S3Configuration' :: S3Configuration -> Text
$sel:bucketARN:S3Configuration' :: S3Configuration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BucketARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucketARN),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FileKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fileKey)
          ]
      )