{-# 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.S3ReferenceDataSource
-- 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.S3ReferenceDataSource 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, identifies the
-- Amazon S3 bucket and object that contains the reference data.
--
-- A Kinesis Data Analytics application loads reference data only once. If
-- the data changes, you call the UpdateApplication operation to trigger
-- reloading of data into your application.
--
-- /See:/ 'newS3ReferenceDataSource' smart constructor.
data S3ReferenceDataSource = S3ReferenceDataSource'
  { -- | The Amazon Resource Name (ARN) of the S3 bucket.
    S3ReferenceDataSource -> Maybe Text
bucketARN :: Prelude.Maybe Prelude.Text,
    -- | The object key name containing the reference data.
    S3ReferenceDataSource -> Maybe Text
fileKey :: Prelude.Maybe Prelude.Text
  }
  deriving (S3ReferenceDataSource -> S3ReferenceDataSource -> Bool
(S3ReferenceDataSource -> S3ReferenceDataSource -> Bool)
-> (S3ReferenceDataSource -> S3ReferenceDataSource -> Bool)
-> Eq S3ReferenceDataSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3ReferenceDataSource -> S3ReferenceDataSource -> Bool
$c/= :: S3ReferenceDataSource -> S3ReferenceDataSource -> Bool
== :: S3ReferenceDataSource -> S3ReferenceDataSource -> Bool
$c== :: S3ReferenceDataSource -> S3ReferenceDataSource -> Bool
Prelude.Eq, ReadPrec [S3ReferenceDataSource]
ReadPrec S3ReferenceDataSource
Int -> ReadS S3ReferenceDataSource
ReadS [S3ReferenceDataSource]
(Int -> ReadS S3ReferenceDataSource)
-> ReadS [S3ReferenceDataSource]
-> ReadPrec S3ReferenceDataSource
-> ReadPrec [S3ReferenceDataSource]
-> Read S3ReferenceDataSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3ReferenceDataSource]
$creadListPrec :: ReadPrec [S3ReferenceDataSource]
readPrec :: ReadPrec S3ReferenceDataSource
$creadPrec :: ReadPrec S3ReferenceDataSource
readList :: ReadS [S3ReferenceDataSource]
$creadList :: ReadS [S3ReferenceDataSource]
readsPrec :: Int -> ReadS S3ReferenceDataSource
$creadsPrec :: Int -> ReadS S3ReferenceDataSource
Prelude.Read, Int -> S3ReferenceDataSource -> ShowS
[S3ReferenceDataSource] -> ShowS
S3ReferenceDataSource -> String
(Int -> S3ReferenceDataSource -> ShowS)
-> (S3ReferenceDataSource -> String)
-> ([S3ReferenceDataSource] -> ShowS)
-> Show S3ReferenceDataSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3ReferenceDataSource] -> ShowS
$cshowList :: [S3ReferenceDataSource] -> ShowS
show :: S3ReferenceDataSource -> String
$cshow :: S3ReferenceDataSource -> String
showsPrec :: Int -> S3ReferenceDataSource -> ShowS
$cshowsPrec :: Int -> S3ReferenceDataSource -> ShowS
Prelude.Show, (forall x. S3ReferenceDataSource -> Rep S3ReferenceDataSource x)
-> (forall x. Rep S3ReferenceDataSource x -> S3ReferenceDataSource)
-> Generic S3ReferenceDataSource
forall x. Rep S3ReferenceDataSource x -> S3ReferenceDataSource
forall x. S3ReferenceDataSource -> Rep S3ReferenceDataSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3ReferenceDataSource x -> S3ReferenceDataSource
$cfrom :: forall x. S3ReferenceDataSource -> Rep S3ReferenceDataSource x
Prelude.Generic)

-- |
-- Create a value of 'S3ReferenceDataSource' 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', 's3ReferenceDataSource_bucketARN' - The Amazon Resource Name (ARN) of the S3 bucket.
--
-- 'fileKey', 's3ReferenceDataSource_fileKey' - The object key name containing the reference data.
newS3ReferenceDataSource ::
  S3ReferenceDataSource
newS3ReferenceDataSource :: S3ReferenceDataSource
newS3ReferenceDataSource =
  S3ReferenceDataSource' :: Maybe Text -> Maybe Text -> S3ReferenceDataSource
S3ReferenceDataSource'
    { $sel:bucketARN:S3ReferenceDataSource' :: Maybe Text
bucketARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fileKey:S3ReferenceDataSource' :: Maybe Text
fileKey = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the S3 bucket.
s3ReferenceDataSource_bucketARN :: Lens.Lens' S3ReferenceDataSource (Prelude.Maybe Prelude.Text)
s3ReferenceDataSource_bucketARN :: (Maybe Text -> f (Maybe Text))
-> S3ReferenceDataSource -> f S3ReferenceDataSource
s3ReferenceDataSource_bucketARN = (S3ReferenceDataSource -> Maybe Text)
-> (S3ReferenceDataSource -> Maybe Text -> S3ReferenceDataSource)
-> Lens
     S3ReferenceDataSource
     S3ReferenceDataSource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReferenceDataSource' {Maybe Text
bucketARN :: Maybe Text
$sel:bucketARN:S3ReferenceDataSource' :: S3ReferenceDataSource -> Maybe Text
bucketARN} -> Maybe Text
bucketARN) (\s :: S3ReferenceDataSource
s@S3ReferenceDataSource' {} Maybe Text
a -> S3ReferenceDataSource
s {$sel:bucketARN:S3ReferenceDataSource' :: Maybe Text
bucketARN = Maybe Text
a} :: S3ReferenceDataSource)

-- | The object key name containing the reference data.
s3ReferenceDataSource_fileKey :: Lens.Lens' S3ReferenceDataSource (Prelude.Maybe Prelude.Text)
s3ReferenceDataSource_fileKey :: (Maybe Text -> f (Maybe Text))
-> S3ReferenceDataSource -> f S3ReferenceDataSource
s3ReferenceDataSource_fileKey = (S3ReferenceDataSource -> Maybe Text)
-> (S3ReferenceDataSource -> Maybe Text -> S3ReferenceDataSource)
-> Lens
     S3ReferenceDataSource
     S3ReferenceDataSource
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReferenceDataSource' {Maybe Text
fileKey :: Maybe Text
$sel:fileKey:S3ReferenceDataSource' :: S3ReferenceDataSource -> Maybe Text
fileKey} -> Maybe Text
fileKey) (\s :: S3ReferenceDataSource
s@S3ReferenceDataSource' {} Maybe Text
a -> S3ReferenceDataSource
s {$sel:fileKey:S3ReferenceDataSource' :: Maybe Text
fileKey = Maybe Text
a} :: S3ReferenceDataSource)

instance Prelude.Hashable S3ReferenceDataSource

instance Prelude.NFData S3ReferenceDataSource

instance Core.ToJSON S3ReferenceDataSource where
  toJSON :: S3ReferenceDataSource -> Value
toJSON S3ReferenceDataSource' {Maybe Text
fileKey :: Maybe Text
bucketARN :: Maybe Text
$sel:fileKey:S3ReferenceDataSource' :: S3ReferenceDataSource -> Maybe Text
$sel:bucketARN:S3ReferenceDataSource' :: S3ReferenceDataSource -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BucketARN" 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
bucketARN,
            (Text
"FileKey" 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
fileKey
          ]
      )