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

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

-- | When you update a reference data source configuration for an
-- application, this object provides all the updated values (such as the
-- source bucket name and object key name), the in-application table name
-- that is created, and updated mapping information that maps the data in
-- the Amazon S3 object to the in-application reference table that is
-- created.
--
-- /See:/ 'newReferenceDataSourceUpdate' smart constructor.
data ReferenceDataSourceUpdate = ReferenceDataSourceUpdate'
  { -- | In-application table name that is created by this update.
    ReferenceDataSourceUpdate -> Maybe Text
tableNameUpdate :: Prelude.Maybe Prelude.Text,
    -- | Describes the S3 bucket name, object key name, and IAM role that Amazon
    -- Kinesis Analytics can assume to read the Amazon S3 object on your behalf
    -- and populate the in-application reference table.
    ReferenceDataSourceUpdate -> Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate :: Prelude.Maybe S3ReferenceDataSourceUpdate,
    -- | 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.
    ReferenceDataSourceUpdate -> Maybe SourceSchema
referenceSchemaUpdate :: Prelude.Maybe SourceSchema,
    -- | ID of the reference data source being updated. You can use the
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
    -- operation to get this value.
    ReferenceDataSourceUpdate -> Text
referenceId :: Prelude.Text
  }
  deriving (ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool
(ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool)
-> (ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool)
-> Eq ReferenceDataSourceUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool
$c/= :: ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool
== :: ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool
$c== :: ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate -> Bool
Prelude.Eq, ReadPrec [ReferenceDataSourceUpdate]
ReadPrec ReferenceDataSourceUpdate
Int -> ReadS ReferenceDataSourceUpdate
ReadS [ReferenceDataSourceUpdate]
(Int -> ReadS ReferenceDataSourceUpdate)
-> ReadS [ReferenceDataSourceUpdate]
-> ReadPrec ReferenceDataSourceUpdate
-> ReadPrec [ReferenceDataSourceUpdate]
-> Read ReferenceDataSourceUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReferenceDataSourceUpdate]
$creadListPrec :: ReadPrec [ReferenceDataSourceUpdate]
readPrec :: ReadPrec ReferenceDataSourceUpdate
$creadPrec :: ReadPrec ReferenceDataSourceUpdate
readList :: ReadS [ReferenceDataSourceUpdate]
$creadList :: ReadS [ReferenceDataSourceUpdate]
readsPrec :: Int -> ReadS ReferenceDataSourceUpdate
$creadsPrec :: Int -> ReadS ReferenceDataSourceUpdate
Prelude.Read, Int -> ReferenceDataSourceUpdate -> ShowS
[ReferenceDataSourceUpdate] -> ShowS
ReferenceDataSourceUpdate -> String
(Int -> ReferenceDataSourceUpdate -> ShowS)
-> (ReferenceDataSourceUpdate -> String)
-> ([ReferenceDataSourceUpdate] -> ShowS)
-> Show ReferenceDataSourceUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReferenceDataSourceUpdate] -> ShowS
$cshowList :: [ReferenceDataSourceUpdate] -> ShowS
show :: ReferenceDataSourceUpdate -> String
$cshow :: ReferenceDataSourceUpdate -> String
showsPrec :: Int -> ReferenceDataSourceUpdate -> ShowS
$cshowsPrec :: Int -> ReferenceDataSourceUpdate -> ShowS
Prelude.Show, (forall x.
 ReferenceDataSourceUpdate -> Rep ReferenceDataSourceUpdate x)
-> (forall x.
    Rep ReferenceDataSourceUpdate x -> ReferenceDataSourceUpdate)
-> Generic ReferenceDataSourceUpdate
forall x.
Rep ReferenceDataSourceUpdate x -> ReferenceDataSourceUpdate
forall x.
ReferenceDataSourceUpdate -> Rep ReferenceDataSourceUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReferenceDataSourceUpdate x -> ReferenceDataSourceUpdate
$cfrom :: forall x.
ReferenceDataSourceUpdate -> Rep ReferenceDataSourceUpdate x
Prelude.Generic)

-- |
-- Create a value of 'ReferenceDataSourceUpdate' 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:
--
-- 'tableNameUpdate', 'referenceDataSourceUpdate_tableNameUpdate' - In-application table name that is created by this update.
--
-- 's3ReferenceDataSourceUpdate', 'referenceDataSourceUpdate_s3ReferenceDataSourceUpdate' - Describes the S3 bucket name, object key name, and IAM role that Amazon
-- Kinesis Analytics can assume to read the Amazon S3 object on your behalf
-- and populate the in-application reference table.
--
-- 'referenceSchemaUpdate', 'referenceDataSourceUpdate_referenceSchemaUpdate' - 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', 'referenceDataSourceUpdate_referenceId' - ID of the reference data source being updated. You can use the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
-- operation to get this value.
newReferenceDataSourceUpdate ::
  -- | 'referenceId'
  Prelude.Text ->
  ReferenceDataSourceUpdate
newReferenceDataSourceUpdate :: Text -> ReferenceDataSourceUpdate
newReferenceDataSourceUpdate Text
pReferenceId_ =
  ReferenceDataSourceUpdate' :: Maybe Text
-> Maybe S3ReferenceDataSourceUpdate
-> Maybe SourceSchema
-> Text
-> ReferenceDataSourceUpdate
ReferenceDataSourceUpdate'
    { $sel:tableNameUpdate:ReferenceDataSourceUpdate' :: Maybe Text
tableNameUpdate =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3ReferenceDataSourceUpdate:ReferenceDataSourceUpdate' :: Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate = Maybe S3ReferenceDataSourceUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:referenceSchemaUpdate:ReferenceDataSourceUpdate' :: Maybe SourceSchema
referenceSchemaUpdate = Maybe SourceSchema
forall a. Maybe a
Prelude.Nothing,
      $sel:referenceId:ReferenceDataSourceUpdate' :: Text
referenceId = Text
pReferenceId_
    }

-- | In-application table name that is created by this update.
referenceDataSourceUpdate_tableNameUpdate :: Lens.Lens' ReferenceDataSourceUpdate (Prelude.Maybe Prelude.Text)
referenceDataSourceUpdate_tableNameUpdate :: (Maybe Text -> f (Maybe Text))
-> ReferenceDataSourceUpdate -> f ReferenceDataSourceUpdate
referenceDataSourceUpdate_tableNameUpdate = (ReferenceDataSourceUpdate -> Maybe Text)
-> (ReferenceDataSourceUpdate
    -> Maybe Text -> ReferenceDataSourceUpdate)
-> Lens
     ReferenceDataSourceUpdate
     ReferenceDataSourceUpdate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceUpdate' {Maybe Text
tableNameUpdate :: Maybe Text
$sel:tableNameUpdate:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Maybe Text
tableNameUpdate} -> Maybe Text
tableNameUpdate) (\s :: ReferenceDataSourceUpdate
s@ReferenceDataSourceUpdate' {} Maybe Text
a -> ReferenceDataSourceUpdate
s {$sel:tableNameUpdate:ReferenceDataSourceUpdate' :: Maybe Text
tableNameUpdate = Maybe Text
a} :: ReferenceDataSourceUpdate)

-- | Describes the S3 bucket name, object key name, and IAM role that Amazon
-- Kinesis Analytics can assume to read the Amazon S3 object on your behalf
-- and populate the in-application reference table.
referenceDataSourceUpdate_s3ReferenceDataSourceUpdate :: Lens.Lens' ReferenceDataSourceUpdate (Prelude.Maybe S3ReferenceDataSourceUpdate)
referenceDataSourceUpdate_s3ReferenceDataSourceUpdate :: (Maybe S3ReferenceDataSourceUpdate
 -> f (Maybe S3ReferenceDataSourceUpdate))
-> ReferenceDataSourceUpdate -> f ReferenceDataSourceUpdate
referenceDataSourceUpdate_s3ReferenceDataSourceUpdate = (ReferenceDataSourceUpdate -> Maybe S3ReferenceDataSourceUpdate)
-> (ReferenceDataSourceUpdate
    -> Maybe S3ReferenceDataSourceUpdate -> ReferenceDataSourceUpdate)
-> Lens
     ReferenceDataSourceUpdate
     ReferenceDataSourceUpdate
     (Maybe S3ReferenceDataSourceUpdate)
     (Maybe S3ReferenceDataSourceUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceUpdate' {Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate :: Maybe S3ReferenceDataSourceUpdate
$sel:s3ReferenceDataSourceUpdate:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate} -> Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate) (\s :: ReferenceDataSourceUpdate
s@ReferenceDataSourceUpdate' {} Maybe S3ReferenceDataSourceUpdate
a -> ReferenceDataSourceUpdate
s {$sel:s3ReferenceDataSourceUpdate:ReferenceDataSourceUpdate' :: Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate = Maybe S3ReferenceDataSourceUpdate
a} :: ReferenceDataSourceUpdate)

-- | 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.
referenceDataSourceUpdate_referenceSchemaUpdate :: Lens.Lens' ReferenceDataSourceUpdate (Prelude.Maybe SourceSchema)
referenceDataSourceUpdate_referenceSchemaUpdate :: (Maybe SourceSchema -> f (Maybe SourceSchema))
-> ReferenceDataSourceUpdate -> f ReferenceDataSourceUpdate
referenceDataSourceUpdate_referenceSchemaUpdate = (ReferenceDataSourceUpdate -> Maybe SourceSchema)
-> (ReferenceDataSourceUpdate
    -> Maybe SourceSchema -> ReferenceDataSourceUpdate)
-> Lens
     ReferenceDataSourceUpdate
     ReferenceDataSourceUpdate
     (Maybe SourceSchema)
     (Maybe SourceSchema)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceUpdate' {Maybe SourceSchema
referenceSchemaUpdate :: Maybe SourceSchema
$sel:referenceSchemaUpdate:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Maybe SourceSchema
referenceSchemaUpdate} -> Maybe SourceSchema
referenceSchemaUpdate) (\s :: ReferenceDataSourceUpdate
s@ReferenceDataSourceUpdate' {} Maybe SourceSchema
a -> ReferenceDataSourceUpdate
s {$sel:referenceSchemaUpdate:ReferenceDataSourceUpdate' :: Maybe SourceSchema
referenceSchemaUpdate = Maybe SourceSchema
a} :: ReferenceDataSourceUpdate)

-- | ID of the reference data source being updated. You can use the
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>
-- operation to get this value.
referenceDataSourceUpdate_referenceId :: Lens.Lens' ReferenceDataSourceUpdate Prelude.Text
referenceDataSourceUpdate_referenceId :: (Text -> f Text)
-> ReferenceDataSourceUpdate -> f ReferenceDataSourceUpdate
referenceDataSourceUpdate_referenceId = (ReferenceDataSourceUpdate -> Text)
-> (ReferenceDataSourceUpdate -> Text -> ReferenceDataSourceUpdate)
-> Lens
     ReferenceDataSourceUpdate ReferenceDataSourceUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReferenceDataSourceUpdate' {Text
referenceId :: Text
$sel:referenceId:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Text
referenceId} -> Text
referenceId) (\s :: ReferenceDataSourceUpdate
s@ReferenceDataSourceUpdate' {} Text
a -> ReferenceDataSourceUpdate
s {$sel:referenceId:ReferenceDataSourceUpdate' :: Text
referenceId = Text
a} :: ReferenceDataSourceUpdate)

instance Prelude.Hashable ReferenceDataSourceUpdate

instance Prelude.NFData ReferenceDataSourceUpdate

instance Core.ToJSON ReferenceDataSourceUpdate where
  toJSON :: ReferenceDataSourceUpdate -> Value
toJSON ReferenceDataSourceUpdate' {Maybe Text
Maybe S3ReferenceDataSourceUpdate
Maybe SourceSchema
Text
referenceId :: Text
referenceSchemaUpdate :: Maybe SourceSchema
s3ReferenceDataSourceUpdate :: Maybe S3ReferenceDataSourceUpdate
tableNameUpdate :: Maybe Text
$sel:referenceId:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Text
$sel:referenceSchemaUpdate:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Maybe SourceSchema
$sel:s3ReferenceDataSourceUpdate:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Maybe S3ReferenceDataSourceUpdate
$sel:tableNameUpdate:ReferenceDataSourceUpdate' :: ReferenceDataSourceUpdate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TableNameUpdate" 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
tableNameUpdate,
            (Text
"S3ReferenceDataSourceUpdate" Text -> S3ReferenceDataSourceUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3ReferenceDataSourceUpdate -> Pair)
-> Maybe S3ReferenceDataSourceUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3ReferenceDataSourceUpdate
s3ReferenceDataSourceUpdate,
            (Text
"ReferenceSchemaUpdate" Text -> SourceSchema -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SourceSchema -> Pair) -> Maybe SourceSchema -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourceSchema
referenceSchemaUpdate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ReferenceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
referenceId)
          ]
      )