{-# 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.KinesisAnalytics.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.KinesisAnalytics.Types.S3ReferenceDataSource where

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

-- | Identifies the S3 bucket and object that contains the reference data.
-- Also identifies the IAM role Amazon Kinesis Analytics can assume to read
-- this object on your behalf.
--
-- An Amazon Kinesis Analytics application loads reference data only once.
-- If the data changes, you call the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_UpdateApplication.html UpdateApplication>
-- operation to trigger reloading of data into your application.
--
-- /See:/ 'newS3ReferenceDataSource' smart constructor.
data S3ReferenceDataSource = S3ReferenceDataSource'
  { -- | Amazon Resource Name (ARN) of the S3 bucket.
    S3ReferenceDataSource -> Text
bucketARN :: Prelude.Text,
    -- | Object key name containing reference data.
    S3ReferenceDataSource -> Text
fileKey :: Prelude.Text,
    -- | ARN of the IAM role that the service can assume to read data on your
    -- behalf. This role must have permission for the @s3:GetObject@ action on
    -- the object and trust policy that allows Amazon Kinesis Analytics service
    -- principal to assume this role.
    S3ReferenceDataSource -> Text
referenceRoleARN :: 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' - Amazon Resource Name (ARN) of the S3 bucket.
--
-- 'fileKey', 's3ReferenceDataSource_fileKey' - Object key name containing reference data.
--
-- 'referenceRoleARN', 's3ReferenceDataSource_referenceRoleARN' - ARN of the IAM role that the service can assume to read data on your
-- behalf. This role must have permission for the @s3:GetObject@ action on
-- the object and trust policy that allows Amazon Kinesis Analytics service
-- principal to assume this role.
newS3ReferenceDataSource ::
  -- | 'bucketARN'
  Prelude.Text ->
  -- | 'fileKey'
  Prelude.Text ->
  -- | 'referenceRoleARN'
  Prelude.Text ->
  S3ReferenceDataSource
newS3ReferenceDataSource :: Text -> Text -> Text -> S3ReferenceDataSource
newS3ReferenceDataSource
  Text
pBucketARN_
  Text
pFileKey_
  Text
pReferenceRoleARN_ =
    S3ReferenceDataSource' :: Text -> Text -> Text -> S3ReferenceDataSource
S3ReferenceDataSource'
      { $sel:bucketARN:S3ReferenceDataSource' :: Text
bucketARN = Text
pBucketARN_,
        $sel:fileKey:S3ReferenceDataSource' :: Text
fileKey = Text
pFileKey_,
        $sel:referenceRoleARN:S3ReferenceDataSource' :: Text
referenceRoleARN = Text
pReferenceRoleARN_
      }

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

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

-- | ARN of the IAM role that the service can assume to read data on your
-- behalf. This role must have permission for the @s3:GetObject@ action on
-- the object and trust policy that allows Amazon Kinesis Analytics service
-- principal to assume this role.
s3ReferenceDataSource_referenceRoleARN :: Lens.Lens' S3ReferenceDataSource Prelude.Text
s3ReferenceDataSource_referenceRoleARN :: (Text -> f Text)
-> S3ReferenceDataSource -> f S3ReferenceDataSource
s3ReferenceDataSource_referenceRoleARN = (S3ReferenceDataSource -> Text)
-> (S3ReferenceDataSource -> Text -> S3ReferenceDataSource)
-> Lens S3ReferenceDataSource S3ReferenceDataSource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3ReferenceDataSource' {Text
referenceRoleARN :: Text
$sel:referenceRoleARN:S3ReferenceDataSource' :: S3ReferenceDataSource -> Text
referenceRoleARN} -> Text
referenceRoleARN) (\s :: S3ReferenceDataSource
s@S3ReferenceDataSource' {} Text
a -> S3ReferenceDataSource
s {$sel:referenceRoleARN:S3ReferenceDataSource' :: Text
referenceRoleARN = Text
a} :: S3ReferenceDataSource)

instance Prelude.Hashable S3ReferenceDataSource

instance Prelude.NFData S3ReferenceDataSource

instance Core.ToJSON S3ReferenceDataSource where
  toJSON :: S3ReferenceDataSource -> Value
toJSON S3ReferenceDataSource' {Text
referenceRoleARN :: Text
fileKey :: Text
bucketARN :: Text
$sel:referenceRoleARN:S3ReferenceDataSource' :: S3ReferenceDataSource -> Text
$sel:fileKey:S3ReferenceDataSource' :: S3ReferenceDataSource -> Text
$sel:bucketARN:S3ReferenceDataSource' :: S3ReferenceDataSource -> 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),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ReferenceRoleARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
referenceRoleARN)
          ]
      )