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

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalytics.Types.S3ReferenceDataSourceDescription
import Amazonka.KinesisAnalytics.Types.SourceSchema
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the reference data source configured for an application.
--
-- /See:/ 'newReferenceDataSourceDescription' smart constructor.
data ReferenceDataSourceDescription = ReferenceDataSourceDescription'
  { -- | Describes the format of the data in the streaming source, and how each
    -- data element maps to corresponding columns created in the in-application
    -- stream.
    ReferenceDataSourceDescription -> Maybe SourceSchema
referenceSchema :: Prelude.Maybe SourceSchema,
    -- | ID of the reference data source. This is the ID that Amazon Kinesis
    -- Analytics assigns when you add the reference data source to your
    -- application using the
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_AddApplicationReferenceDataSource.html AddApplicationReferenceDataSource>
    -- operation.
    ReferenceDataSourceDescription -> Text
referenceId :: Prelude.Text,
    -- | The in-application table name created by the specific reference data
    -- source configuration.
    ReferenceDataSourceDescription -> Text
tableName :: Prelude.Text,
    -- | Provides the S3 bucket name, the object key name that contains the
    -- reference data. It also provides the Amazon Resource Name (ARN) of the
    -- IAM role that Amazon Kinesis Analytics can assume to read the Amazon S3
    -- object and populate the in-application reference table.
    ReferenceDataSourceDescription -> S3ReferenceDataSourceDescription
s3ReferenceDataSourceDescription :: S3ReferenceDataSourceDescription
  }
  deriving (ReferenceDataSourceDescription
-> ReferenceDataSourceDescription -> Bool
(ReferenceDataSourceDescription
 -> ReferenceDataSourceDescription -> Bool)
-> (ReferenceDataSourceDescription
    -> ReferenceDataSourceDescription -> Bool)
-> Eq ReferenceDataSourceDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReferenceDataSourceDescription
-> ReferenceDataSourceDescription -> Bool
$c/= :: ReferenceDataSourceDescription
-> ReferenceDataSourceDescription -> Bool
== :: ReferenceDataSourceDescription
-> ReferenceDataSourceDescription -> Bool
$c== :: ReferenceDataSourceDescription
-> ReferenceDataSourceDescription -> Bool
Prelude.Eq, ReadPrec [ReferenceDataSourceDescription]
ReadPrec ReferenceDataSourceDescription
Int -> ReadS ReferenceDataSourceDescription
ReadS [ReferenceDataSourceDescription]
(Int -> ReadS ReferenceDataSourceDescription)
-> ReadS [ReferenceDataSourceDescription]
-> ReadPrec ReferenceDataSourceDescription
-> ReadPrec [ReferenceDataSourceDescription]
-> Read ReferenceDataSourceDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReferenceDataSourceDescription]
$creadListPrec :: ReadPrec [ReferenceDataSourceDescription]
readPrec :: ReadPrec ReferenceDataSourceDescription
$creadPrec :: ReadPrec ReferenceDataSourceDescription
readList :: ReadS [ReferenceDataSourceDescription]
$creadList :: ReadS [ReferenceDataSourceDescription]
readsPrec :: Int -> ReadS ReferenceDataSourceDescription
$creadsPrec :: Int -> ReadS ReferenceDataSourceDescription
Prelude.Read, Int -> ReferenceDataSourceDescription -> ShowS
[ReferenceDataSourceDescription] -> ShowS
ReferenceDataSourceDescription -> String
(Int -> ReferenceDataSourceDescription -> ShowS)
-> (ReferenceDataSourceDescription -> String)
-> ([ReferenceDataSourceDescription] -> ShowS)
-> Show ReferenceDataSourceDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReferenceDataSourceDescription] -> ShowS
$cshowList :: [ReferenceDataSourceDescription] -> ShowS
show :: ReferenceDataSourceDescription -> String
$cshow :: ReferenceDataSourceDescription -> String
showsPrec :: Int -> ReferenceDataSourceDescription -> ShowS
$cshowsPrec :: Int -> ReferenceDataSourceDescription -> ShowS
Prelude.Show, (forall x.
 ReferenceDataSourceDescription
 -> Rep ReferenceDataSourceDescription x)
-> (forall x.
    Rep ReferenceDataSourceDescription x
    -> ReferenceDataSourceDescription)
-> Generic ReferenceDataSourceDescription
forall x.
Rep ReferenceDataSourceDescription x
-> ReferenceDataSourceDescription
forall x.
ReferenceDataSourceDescription
-> Rep ReferenceDataSourceDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReferenceDataSourceDescription x
-> ReferenceDataSourceDescription
$cfrom :: forall x.
ReferenceDataSourceDescription
-> Rep ReferenceDataSourceDescription x
Prelude.Generic)

-- |
-- Create a value of 'ReferenceDataSourceDescription' 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:
--
-- 'referenceSchema', 'referenceDataSourceDescription_referenceSchema' - Describes the format of the data in the streaming source, and how each
-- data element maps to corresponding columns created in the in-application
-- stream.
--
-- 'referenceId', 'referenceDataSourceDescription_referenceId' - ID of the reference data source. This is the ID that Amazon Kinesis
-- Analytics assigns when you add the reference data source to your
-- application using the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_AddApplicationReferenceDataSource.html AddApplicationReferenceDataSource>
-- operation.
--
-- 'tableName', 'referenceDataSourceDescription_tableName' - The in-application table name created by the specific reference data
-- source configuration.
--
-- 's3ReferenceDataSourceDescription', 'referenceDataSourceDescription_s3ReferenceDataSourceDescription' - Provides the S3 bucket name, the object key name that contains the
-- reference data. It also provides the Amazon Resource Name (ARN) of the
-- IAM role that Amazon Kinesis Analytics can assume to read the Amazon S3
-- object and populate the in-application reference table.
newReferenceDataSourceDescription ::
  -- | 'referenceId'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  -- | 's3ReferenceDataSourceDescription'
  S3ReferenceDataSourceDescription ->
  ReferenceDataSourceDescription
newReferenceDataSourceDescription :: Text
-> Text
-> S3ReferenceDataSourceDescription
-> ReferenceDataSourceDescription
newReferenceDataSourceDescription
  Text
pReferenceId_
  Text
pTableName_
  S3ReferenceDataSourceDescription
pS3ReferenceDataSourceDescription_ =
    ReferenceDataSourceDescription' :: Maybe SourceSchema
-> Text
-> Text
-> S3ReferenceDataSourceDescription
-> ReferenceDataSourceDescription
ReferenceDataSourceDescription'
      { $sel:referenceSchema:ReferenceDataSourceDescription' :: Maybe SourceSchema
referenceSchema =
          Maybe SourceSchema
forall a. Maybe a
Prelude.Nothing,
        $sel:referenceId:ReferenceDataSourceDescription' :: Text
referenceId = Text
pReferenceId_,
        $sel:tableName:ReferenceDataSourceDescription' :: Text
tableName = Text
pTableName_,
        $sel:s3ReferenceDataSourceDescription:ReferenceDataSourceDescription' :: S3ReferenceDataSourceDescription
s3ReferenceDataSourceDescription =
          S3ReferenceDataSourceDescription
pS3ReferenceDataSourceDescription_
      }

-- | Describes the format of the data in the streaming source, and how each
-- data element maps to corresponding columns created in the in-application
-- stream.
referenceDataSourceDescription_referenceSchema :: Lens.Lens' ReferenceDataSourceDescription (Prelude.Maybe SourceSchema)
referenceDataSourceDescription_referenceSchema :: (Maybe SourceSchema -> f (Maybe SourceSchema))
-> ReferenceDataSourceDescription
-> f ReferenceDataSourceDescription
referenceDataSourceDescription_referenceSchema = (ReferenceDataSourceDescription -> Maybe SourceSchema)
-> (ReferenceDataSourceDescription
    -> Maybe SourceSchema -> ReferenceDataSourceDescription)
-> Lens
     ReferenceDataSourceDescription
     ReferenceDataSourceDescription
     (Maybe SourceSchema)
     (Maybe SourceSchema)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceDescription' {Maybe SourceSchema
referenceSchema :: Maybe SourceSchema
$sel:referenceSchema:ReferenceDataSourceDescription' :: ReferenceDataSourceDescription -> Maybe SourceSchema
referenceSchema} -> Maybe SourceSchema
referenceSchema) (\s :: ReferenceDataSourceDescription
s@ReferenceDataSourceDescription' {} Maybe SourceSchema
a -> ReferenceDataSourceDescription
s {$sel:referenceSchema:ReferenceDataSourceDescription' :: Maybe SourceSchema
referenceSchema = Maybe SourceSchema
a} :: ReferenceDataSourceDescription)

-- | ID of the reference data source. This is the ID that Amazon Kinesis
-- Analytics assigns when you add the reference data source to your
-- application using the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_AddApplicationReferenceDataSource.html AddApplicationReferenceDataSource>
-- operation.
referenceDataSourceDescription_referenceId :: Lens.Lens' ReferenceDataSourceDescription Prelude.Text
referenceDataSourceDescription_referenceId :: (Text -> f Text)
-> ReferenceDataSourceDescription
-> f ReferenceDataSourceDescription
referenceDataSourceDescription_referenceId = (ReferenceDataSourceDescription -> Text)
-> (ReferenceDataSourceDescription
    -> Text -> ReferenceDataSourceDescription)
-> Lens
     ReferenceDataSourceDescription
     ReferenceDataSourceDescription
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceDescription' {Text
referenceId :: Text
$sel:referenceId:ReferenceDataSourceDescription' :: ReferenceDataSourceDescription -> Text
referenceId} -> Text
referenceId) (\s :: ReferenceDataSourceDescription
s@ReferenceDataSourceDescription' {} Text
a -> ReferenceDataSourceDescription
s {$sel:referenceId:ReferenceDataSourceDescription' :: Text
referenceId = Text
a} :: ReferenceDataSourceDescription)

-- | The in-application table name created by the specific reference data
-- source configuration.
referenceDataSourceDescription_tableName :: Lens.Lens' ReferenceDataSourceDescription Prelude.Text
referenceDataSourceDescription_tableName :: (Text -> f Text)
-> ReferenceDataSourceDescription
-> f ReferenceDataSourceDescription
referenceDataSourceDescription_tableName = (ReferenceDataSourceDescription -> Text)
-> (ReferenceDataSourceDescription
    -> Text -> ReferenceDataSourceDescription)
-> Lens
     ReferenceDataSourceDescription
     ReferenceDataSourceDescription
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceDescription' {Text
tableName :: Text
$sel:tableName:ReferenceDataSourceDescription' :: ReferenceDataSourceDescription -> Text
tableName} -> Text
tableName) (\s :: ReferenceDataSourceDescription
s@ReferenceDataSourceDescription' {} Text
a -> ReferenceDataSourceDescription
s {$sel:tableName:ReferenceDataSourceDescription' :: Text
tableName = Text
a} :: ReferenceDataSourceDescription)

-- | Provides the S3 bucket name, the object key name that contains the
-- reference data. It also provides the Amazon Resource Name (ARN) of the
-- IAM role that Amazon Kinesis Analytics can assume to read the Amazon S3
-- object and populate the in-application reference table.
referenceDataSourceDescription_s3ReferenceDataSourceDescription :: Lens.Lens' ReferenceDataSourceDescription S3ReferenceDataSourceDescription
referenceDataSourceDescription_s3ReferenceDataSourceDescription :: (S3ReferenceDataSourceDescription
 -> f S3ReferenceDataSourceDescription)
-> ReferenceDataSourceDescription
-> f ReferenceDataSourceDescription
referenceDataSourceDescription_s3ReferenceDataSourceDescription = (ReferenceDataSourceDescription
 -> S3ReferenceDataSourceDescription)
-> (ReferenceDataSourceDescription
    -> S3ReferenceDataSourceDescription
    -> ReferenceDataSourceDescription)
-> Lens
     ReferenceDataSourceDescription
     ReferenceDataSourceDescription
     S3ReferenceDataSourceDescription
     S3ReferenceDataSourceDescription
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceDescription' {S3ReferenceDataSourceDescription
s3ReferenceDataSourceDescription :: S3ReferenceDataSourceDescription
$sel:s3ReferenceDataSourceDescription:ReferenceDataSourceDescription' :: ReferenceDataSourceDescription -> S3ReferenceDataSourceDescription
s3ReferenceDataSourceDescription} -> S3ReferenceDataSourceDescription
s3ReferenceDataSourceDescription) (\s :: ReferenceDataSourceDescription
s@ReferenceDataSourceDescription' {} S3ReferenceDataSourceDescription
a -> ReferenceDataSourceDescription
s {$sel:s3ReferenceDataSourceDescription:ReferenceDataSourceDescription' :: S3ReferenceDataSourceDescription
s3ReferenceDataSourceDescription = S3ReferenceDataSourceDescription
a} :: ReferenceDataSourceDescription)

instance Core.FromJSON ReferenceDataSourceDescription where
  parseJSON :: Value -> Parser ReferenceDataSourceDescription
parseJSON =
    String
-> (Object -> Parser ReferenceDataSourceDescription)
-> Value
-> Parser ReferenceDataSourceDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReferenceDataSourceDescription"
      ( \Object
x ->
          Maybe SourceSchema
-> Text
-> Text
-> S3ReferenceDataSourceDescription
-> ReferenceDataSourceDescription
ReferenceDataSourceDescription'
            (Maybe SourceSchema
 -> Text
 -> Text
 -> S3ReferenceDataSourceDescription
 -> ReferenceDataSourceDescription)
-> Parser (Maybe SourceSchema)
-> Parser
     (Text
      -> Text
      -> S3ReferenceDataSourceDescription
      -> ReferenceDataSourceDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SourceSchema)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ReferenceSchema")
            Parser
  (Text
   -> Text
   -> S3ReferenceDataSourceDescription
   -> ReferenceDataSourceDescription)
-> Parser Text
-> Parser
     (Text
      -> S3ReferenceDataSourceDescription
      -> ReferenceDataSourceDescription)
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
"ReferenceId")
            Parser
  (Text
   -> S3ReferenceDataSourceDescription
   -> ReferenceDataSourceDescription)
-> Parser Text
-> Parser
     (S3ReferenceDataSourceDescription
      -> ReferenceDataSourceDescription)
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
"TableName")
            Parser
  (S3ReferenceDataSourceDescription
   -> ReferenceDataSourceDescription)
-> Parser S3ReferenceDataSourceDescription
-> Parser ReferenceDataSourceDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser S3ReferenceDataSourceDescription
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"S3ReferenceDataSourceDescription")
      )

instance
  Prelude.Hashable
    ReferenceDataSourceDescription

instance
  Prelude.NFData
    ReferenceDataSourceDescription