{-# 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.Glue.Types.CatalogKinesisSource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.CatalogKinesisSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.KinesisStreamingSourceOptions
import Amazonka.Glue.Types.StreamingDataPreviewOptions
import qualified Amazonka.Prelude as Prelude

-- | Specifies a Kinesis data source in the Glue Data Catalog.
--
-- /See:/ 'newCatalogKinesisSource' smart constructor.
data CatalogKinesisSource = CatalogKinesisSource'
  { -- | Additional options for data preview.
    CatalogKinesisSource -> Maybe StreamingDataPreviewOptions
dataPreviewOptions :: Prelude.Maybe StreamingDataPreviewOptions,
    -- | Whether to automatically determine the schema from the incoming data.
    CatalogKinesisSource -> Maybe Bool
detectSchema :: Prelude.Maybe Prelude.Bool,
    -- | Additional options for the Kinesis streaming data source.
    CatalogKinesisSource -> Maybe KinesisStreamingSourceOptions
streamingOptions :: Prelude.Maybe KinesisStreamingSourceOptions,
    -- | The amount of time to spend processing each micro batch.
    CatalogKinesisSource -> Maybe Natural
windowSize :: Prelude.Maybe Prelude.Natural,
    -- | The name of the data source.
    CatalogKinesisSource -> Text
name :: Prelude.Text,
    -- | The name of the table in the database to read from.
    CatalogKinesisSource -> Text
table :: Prelude.Text,
    -- | The name of the database to read from.
    CatalogKinesisSource -> Text
database :: Prelude.Text
  }
  deriving (CatalogKinesisSource -> CatalogKinesisSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CatalogKinesisSource -> CatalogKinesisSource -> Bool
$c/= :: CatalogKinesisSource -> CatalogKinesisSource -> Bool
== :: CatalogKinesisSource -> CatalogKinesisSource -> Bool
$c== :: CatalogKinesisSource -> CatalogKinesisSource -> Bool
Prelude.Eq, ReadPrec [CatalogKinesisSource]
ReadPrec CatalogKinesisSource
Int -> ReadS CatalogKinesisSource
ReadS [CatalogKinesisSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CatalogKinesisSource]
$creadListPrec :: ReadPrec [CatalogKinesisSource]
readPrec :: ReadPrec CatalogKinesisSource
$creadPrec :: ReadPrec CatalogKinesisSource
readList :: ReadS [CatalogKinesisSource]
$creadList :: ReadS [CatalogKinesisSource]
readsPrec :: Int -> ReadS CatalogKinesisSource
$creadsPrec :: Int -> ReadS CatalogKinesisSource
Prelude.Read, Int -> CatalogKinesisSource -> ShowS
[CatalogKinesisSource] -> ShowS
CatalogKinesisSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CatalogKinesisSource] -> ShowS
$cshowList :: [CatalogKinesisSource] -> ShowS
show :: CatalogKinesisSource -> String
$cshow :: CatalogKinesisSource -> String
showsPrec :: Int -> CatalogKinesisSource -> ShowS
$cshowsPrec :: Int -> CatalogKinesisSource -> ShowS
Prelude.Show, forall x. Rep CatalogKinesisSource x -> CatalogKinesisSource
forall x. CatalogKinesisSource -> Rep CatalogKinesisSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CatalogKinesisSource x -> CatalogKinesisSource
$cfrom :: forall x. CatalogKinesisSource -> Rep CatalogKinesisSource x
Prelude.Generic)

-- |
-- Create a value of 'CatalogKinesisSource' 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:
--
-- 'dataPreviewOptions', 'catalogKinesisSource_dataPreviewOptions' - Additional options for data preview.
--
-- 'detectSchema', 'catalogKinesisSource_detectSchema' - Whether to automatically determine the schema from the incoming data.
--
-- 'streamingOptions', 'catalogKinesisSource_streamingOptions' - Additional options for the Kinesis streaming data source.
--
-- 'windowSize', 'catalogKinesisSource_windowSize' - The amount of time to spend processing each micro batch.
--
-- 'name', 'catalogKinesisSource_name' - The name of the data source.
--
-- 'table', 'catalogKinesisSource_table' - The name of the table in the database to read from.
--
-- 'database', 'catalogKinesisSource_database' - The name of the database to read from.
newCatalogKinesisSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  CatalogKinesisSource
newCatalogKinesisSource :: Text -> Text -> Text -> CatalogKinesisSource
newCatalogKinesisSource Text
pName_ Text
pTable_ Text
pDatabase_ =
  CatalogKinesisSource'
    { $sel:dataPreviewOptions:CatalogKinesisSource' :: Maybe StreamingDataPreviewOptions
dataPreviewOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:detectSchema:CatalogKinesisSource' :: Maybe Bool
detectSchema = forall a. Maybe a
Prelude.Nothing,
      $sel:streamingOptions:CatalogKinesisSource' :: Maybe KinesisStreamingSourceOptions
streamingOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:windowSize:CatalogKinesisSource' :: Maybe Natural
windowSize = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CatalogKinesisSource' :: Text
name = Text
pName_,
      $sel:table:CatalogKinesisSource' :: Text
table = Text
pTable_,
      $sel:database:CatalogKinesisSource' :: Text
database = Text
pDatabase_
    }

-- | Additional options for data preview.
catalogKinesisSource_dataPreviewOptions :: Lens.Lens' CatalogKinesisSource (Prelude.Maybe StreamingDataPreviewOptions)
catalogKinesisSource_dataPreviewOptions :: Lens' CatalogKinesisSource (Maybe StreamingDataPreviewOptions)
catalogKinesisSource_dataPreviewOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Maybe StreamingDataPreviewOptions
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:dataPreviewOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe StreamingDataPreviewOptions
dataPreviewOptions} -> Maybe StreamingDataPreviewOptions
dataPreviewOptions) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Maybe StreamingDataPreviewOptions
a -> CatalogKinesisSource
s {$sel:dataPreviewOptions:CatalogKinesisSource' :: Maybe StreamingDataPreviewOptions
dataPreviewOptions = Maybe StreamingDataPreviewOptions
a} :: CatalogKinesisSource)

-- | Whether to automatically determine the schema from the incoming data.
catalogKinesisSource_detectSchema :: Lens.Lens' CatalogKinesisSource (Prelude.Maybe Prelude.Bool)
catalogKinesisSource_detectSchema :: Lens' CatalogKinesisSource (Maybe Bool)
catalogKinesisSource_detectSchema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Maybe Bool
detectSchema :: Maybe Bool
$sel:detectSchema:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Bool
detectSchema} -> Maybe Bool
detectSchema) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Maybe Bool
a -> CatalogKinesisSource
s {$sel:detectSchema:CatalogKinesisSource' :: Maybe Bool
detectSchema = Maybe Bool
a} :: CatalogKinesisSource)

-- | Additional options for the Kinesis streaming data source.
catalogKinesisSource_streamingOptions :: Lens.Lens' CatalogKinesisSource (Prelude.Maybe KinesisStreamingSourceOptions)
catalogKinesisSource_streamingOptions :: Lens' CatalogKinesisSource (Maybe KinesisStreamingSourceOptions)
catalogKinesisSource_streamingOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Maybe KinesisStreamingSourceOptions
streamingOptions :: Maybe KinesisStreamingSourceOptions
$sel:streamingOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe KinesisStreamingSourceOptions
streamingOptions} -> Maybe KinesisStreamingSourceOptions
streamingOptions) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Maybe KinesisStreamingSourceOptions
a -> CatalogKinesisSource
s {$sel:streamingOptions:CatalogKinesisSource' :: Maybe KinesisStreamingSourceOptions
streamingOptions = Maybe KinesisStreamingSourceOptions
a} :: CatalogKinesisSource)

-- | The amount of time to spend processing each micro batch.
catalogKinesisSource_windowSize :: Lens.Lens' CatalogKinesisSource (Prelude.Maybe Prelude.Natural)
catalogKinesisSource_windowSize :: Lens' CatalogKinesisSource (Maybe Natural)
catalogKinesisSource_windowSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Maybe Natural
windowSize :: Maybe Natural
$sel:windowSize:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Natural
windowSize} -> Maybe Natural
windowSize) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Maybe Natural
a -> CatalogKinesisSource
s {$sel:windowSize:CatalogKinesisSource' :: Maybe Natural
windowSize = Maybe Natural
a} :: CatalogKinesisSource)

-- | The name of the data source.
catalogKinesisSource_name :: Lens.Lens' CatalogKinesisSource Prelude.Text
catalogKinesisSource_name :: Lens' CatalogKinesisSource Text
catalogKinesisSource_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Text
name :: Text
$sel:name:CatalogKinesisSource' :: CatalogKinesisSource -> Text
name} -> Text
name) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Text
a -> CatalogKinesisSource
s {$sel:name:CatalogKinesisSource' :: Text
name = Text
a} :: CatalogKinesisSource)

-- | The name of the table in the database to read from.
catalogKinesisSource_table :: Lens.Lens' CatalogKinesisSource Prelude.Text
catalogKinesisSource_table :: Lens' CatalogKinesisSource Text
catalogKinesisSource_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Text
table :: Text
$sel:table:CatalogKinesisSource' :: CatalogKinesisSource -> Text
table} -> Text
table) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Text
a -> CatalogKinesisSource
s {$sel:table:CatalogKinesisSource' :: Text
table = Text
a} :: CatalogKinesisSource)

-- | The name of the database to read from.
catalogKinesisSource_database :: Lens.Lens' CatalogKinesisSource Prelude.Text
catalogKinesisSource_database :: Lens' CatalogKinesisSource Text
catalogKinesisSource_database = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKinesisSource' {Text
database :: Text
$sel:database:CatalogKinesisSource' :: CatalogKinesisSource -> Text
database} -> Text
database) (\s :: CatalogKinesisSource
s@CatalogKinesisSource' {} Text
a -> CatalogKinesisSource
s {$sel:database:CatalogKinesisSource' :: Text
database = Text
a} :: CatalogKinesisSource)

instance Data.FromJSON CatalogKinesisSource where
  parseJSON :: Value -> Parser CatalogKinesisSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CatalogKinesisSource"
      ( \Object
x ->
          Maybe StreamingDataPreviewOptions
-> Maybe Bool
-> Maybe KinesisStreamingSourceOptions
-> Maybe Natural
-> Text
-> Text
-> Text
-> CatalogKinesisSource
CatalogKinesisSource'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DataPreviewOptions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DetectSchema")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StreamingOptions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"WindowSize")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Table")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Database")
      )

instance Prelude.Hashable CatalogKinesisSource where
  hashWithSalt :: Int -> CatalogKinesisSource -> Int
hashWithSalt Int
_salt CatalogKinesisSource' {Maybe Bool
Maybe Natural
Maybe KinesisStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
database :: Text
table :: Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KinesisStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:database:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:table:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:name:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:windowSize:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Natural
$sel:streamingOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe KinesisStreamingSourceOptions
$sel:detectSchema:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Bool
$sel:dataPreviewOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe StreamingDataPreviewOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StreamingDataPreviewOptions
dataPreviewOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
detectSchema
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KinesisStreamingSourceOptions
streamingOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
windowSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
table
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
database

instance Prelude.NFData CatalogKinesisSource where
  rnf :: CatalogKinesisSource -> ()
rnf CatalogKinesisSource' {Maybe Bool
Maybe Natural
Maybe KinesisStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
database :: Text
table :: Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KinesisStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:database:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:table:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:name:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:windowSize:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Natural
$sel:streamingOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe KinesisStreamingSourceOptions
$sel:detectSchema:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Bool
$sel:dataPreviewOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe StreamingDataPreviewOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StreamingDataPreviewOptions
dataPreviewOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
detectSchema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KinesisStreamingSourceOptions
streamingOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
windowSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
table
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
database

instance Data.ToJSON CatalogKinesisSource where
  toJSON :: CatalogKinesisSource -> Value
toJSON CatalogKinesisSource' {Maybe Bool
Maybe Natural
Maybe KinesisStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
database :: Text
table :: Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KinesisStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:database:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:table:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:name:CatalogKinesisSource' :: CatalogKinesisSource -> Text
$sel:windowSize:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Natural
$sel:streamingOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe KinesisStreamingSourceOptions
$sel:detectSchema:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe Bool
$sel:dataPreviewOptions:CatalogKinesisSource' :: CatalogKinesisSource -> Maybe StreamingDataPreviewOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DataPreviewOptions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StreamingDataPreviewOptions
dataPreviewOptions,
            (Key
"DetectSchema" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
detectSchema,
            (Key
"StreamingOptions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KinesisStreamingSourceOptions
streamingOptions,
            (Key
"WindowSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
windowSize,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Table" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
table),
            forall a. a -> Maybe a
Prelude.Just (Key
"Database" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
database)
          ]
      )