{-# 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.CatalogKafkaSource
-- 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.CatalogKafkaSource 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.KafkaStreamingSourceOptions
import Amazonka.Glue.Types.StreamingDataPreviewOptions
import qualified Amazonka.Prelude as Prelude

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

-- |
-- Create a value of 'CatalogKafkaSource' 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', 'catalogKafkaSource_dataPreviewOptions' - Specifies options related to data preview for viewing a sample of your
-- data.
--
-- 'detectSchema', 'catalogKafkaSource_detectSchema' - Whether to automatically determine the schema from the incoming data.
--
-- 'streamingOptions', 'catalogKafkaSource_streamingOptions' - Specifies the streaming options.
--
-- 'windowSize', 'catalogKafkaSource_windowSize' - The amount of time to spend processing each micro batch.
--
-- 'name', 'catalogKafkaSource_name' - The name of the data store.
--
-- 'table', 'catalogKafkaSource_table' - The name of the table in the database to read from.
--
-- 'database', 'catalogKafkaSource_database' - The name of the database to read from.
newCatalogKafkaSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  CatalogKafkaSource
newCatalogKafkaSource :: Text -> Text -> Text -> CatalogKafkaSource
newCatalogKafkaSource Text
pName_ Text
pTable_ Text
pDatabase_ =
  CatalogKafkaSource'
    { $sel:dataPreviewOptions:CatalogKafkaSource' :: Maybe StreamingDataPreviewOptions
dataPreviewOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:detectSchema:CatalogKafkaSource' :: Maybe Bool
detectSchema = forall a. Maybe a
Prelude.Nothing,
      $sel:streamingOptions:CatalogKafkaSource' :: Maybe KafkaStreamingSourceOptions
streamingOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:windowSize:CatalogKafkaSource' :: Maybe Natural
windowSize = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CatalogKafkaSource' :: Text
name = Text
pName_,
      $sel:table:CatalogKafkaSource' :: Text
table = Text
pTable_,
      $sel:database:CatalogKafkaSource' :: Text
database = Text
pDatabase_
    }

-- | Specifies options related to data preview for viewing a sample of your
-- data.
catalogKafkaSource_dataPreviewOptions :: Lens.Lens' CatalogKafkaSource (Prelude.Maybe StreamingDataPreviewOptions)
catalogKafkaSource_dataPreviewOptions :: Lens' CatalogKafkaSource (Maybe StreamingDataPreviewOptions)
catalogKafkaSource_dataPreviewOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKafkaSource' {Maybe StreamingDataPreviewOptions
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:dataPreviewOptions:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe StreamingDataPreviewOptions
dataPreviewOptions} -> Maybe StreamingDataPreviewOptions
dataPreviewOptions) (\s :: CatalogKafkaSource
s@CatalogKafkaSource' {} Maybe StreamingDataPreviewOptions
a -> CatalogKafkaSource
s {$sel:dataPreviewOptions:CatalogKafkaSource' :: Maybe StreamingDataPreviewOptions
dataPreviewOptions = Maybe StreamingDataPreviewOptions
a} :: CatalogKafkaSource)

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

-- | Specifies the streaming options.
catalogKafkaSource_streamingOptions :: Lens.Lens' CatalogKafkaSource (Prelude.Maybe KafkaStreamingSourceOptions)
catalogKafkaSource_streamingOptions :: Lens' CatalogKafkaSource (Maybe KafkaStreamingSourceOptions)
catalogKafkaSource_streamingOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogKafkaSource' {Maybe KafkaStreamingSourceOptions
streamingOptions :: Maybe KafkaStreamingSourceOptions
$sel:streamingOptions:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe KafkaStreamingSourceOptions
streamingOptions} -> Maybe KafkaStreamingSourceOptions
streamingOptions) (\s :: CatalogKafkaSource
s@CatalogKafkaSource' {} Maybe KafkaStreamingSourceOptions
a -> CatalogKafkaSource
s {$sel:streamingOptions:CatalogKafkaSource' :: Maybe KafkaStreamingSourceOptions
streamingOptions = Maybe KafkaStreamingSourceOptions
a} :: CatalogKafkaSource)

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

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

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

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

instance Data.FromJSON CatalogKafkaSource where
  parseJSON :: Value -> Parser CatalogKafkaSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CatalogKafkaSource"
      ( \Object
x ->
          Maybe StreamingDataPreviewOptions
-> Maybe Bool
-> Maybe KafkaStreamingSourceOptions
-> Maybe Natural
-> Text
-> Text
-> Text
-> CatalogKafkaSource
CatalogKafkaSource'
            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 CatalogKafkaSource where
  hashWithSalt :: Int -> CatalogKafkaSource -> Int
hashWithSalt Int
_salt CatalogKafkaSource' {Maybe Bool
Maybe Natural
Maybe KafkaStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
database :: Text
table :: Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KafkaStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:database:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:table:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:name:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:windowSize:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe Natural
$sel:streamingOptions:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe KafkaStreamingSourceOptions
$sel:detectSchema:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe Bool
$sel:dataPreviewOptions:CatalogKafkaSource' :: CatalogKafkaSource -> 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 KafkaStreamingSourceOptions
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 CatalogKafkaSource where
  rnf :: CatalogKafkaSource -> ()
rnf CatalogKafkaSource' {Maybe Bool
Maybe Natural
Maybe KafkaStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
database :: Text
table :: Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KafkaStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:database:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:table:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:name:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:windowSize:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe Natural
$sel:streamingOptions:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe KafkaStreamingSourceOptions
$sel:detectSchema:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe Bool
$sel:dataPreviewOptions:CatalogKafkaSource' :: CatalogKafkaSource -> 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 KafkaStreamingSourceOptions
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 CatalogKafkaSource where
  toJSON :: CatalogKafkaSource -> Value
toJSON CatalogKafkaSource' {Maybe Bool
Maybe Natural
Maybe KafkaStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
database :: Text
table :: Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KafkaStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:database:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:table:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:name:CatalogKafkaSource' :: CatalogKafkaSource -> Text
$sel:windowSize:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe Natural
$sel:streamingOptions:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe KafkaStreamingSourceOptions
$sel:detectSchema:CatalogKafkaSource' :: CatalogKafkaSource -> Maybe Bool
$sel:dataPreviewOptions:CatalogKafkaSource' :: CatalogKafkaSource -> 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 KafkaStreamingSourceOptions
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)
          ]
      )