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

-- |
-- Create a value of 'DirectKafkaSource' 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', 'directKafkaSource_dataPreviewOptions' - Specifies options related to data preview for viewing a sample of your
-- data.
--
-- 'detectSchema', 'directKafkaSource_detectSchema' - Whether to automatically determine the schema from the incoming data.
--
-- 'streamingOptions', 'directKafkaSource_streamingOptions' - Specifies the streaming options.
--
-- 'windowSize', 'directKafkaSource_windowSize' - The amount of time to spend processing each micro batch.
--
-- 'name', 'directKafkaSource_name' - The name of the data store.
newDirectKafkaSource ::
  -- | 'name'
  Prelude.Text ->
  DirectKafkaSource
newDirectKafkaSource :: Text -> DirectKafkaSource
newDirectKafkaSource Text
pName_ =
  DirectKafkaSource'
    { $sel:dataPreviewOptions:DirectKafkaSource' :: Maybe StreamingDataPreviewOptions
dataPreviewOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:detectSchema:DirectKafkaSource' :: Maybe Bool
detectSchema = forall a. Maybe a
Prelude.Nothing,
      $sel:streamingOptions:DirectKafkaSource' :: Maybe KafkaStreamingSourceOptions
streamingOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:windowSize:DirectKafkaSource' :: Maybe Natural
windowSize = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DirectKafkaSource' :: Text
name = Text
pName_
    }

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

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

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

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

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

instance Data.FromJSON DirectKafkaSource where
  parseJSON :: Value -> Parser DirectKafkaSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DirectKafkaSource"
      ( \Object
x ->
          Maybe StreamingDataPreviewOptions
-> Maybe Bool
-> Maybe KafkaStreamingSourceOptions
-> Maybe Natural
-> Text
-> DirectKafkaSource
DirectKafkaSource'
            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")
      )

instance Prelude.Hashable DirectKafkaSource where
  hashWithSalt :: Int -> DirectKafkaSource -> Int
hashWithSalt Int
_salt DirectKafkaSource' {Maybe Bool
Maybe Natural
Maybe KafkaStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KafkaStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:name:DirectKafkaSource' :: DirectKafkaSource -> Text
$sel:windowSize:DirectKafkaSource' :: DirectKafkaSource -> Maybe Natural
$sel:streamingOptions:DirectKafkaSource' :: DirectKafkaSource -> Maybe KafkaStreamingSourceOptions
$sel:detectSchema:DirectKafkaSource' :: DirectKafkaSource -> Maybe Bool
$sel:dataPreviewOptions:DirectKafkaSource' :: DirectKafkaSource -> 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

instance Prelude.NFData DirectKafkaSource where
  rnf :: DirectKafkaSource -> ()
rnf DirectKafkaSource' {Maybe Bool
Maybe Natural
Maybe KafkaStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KafkaStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:name:DirectKafkaSource' :: DirectKafkaSource -> Text
$sel:windowSize:DirectKafkaSource' :: DirectKafkaSource -> Maybe Natural
$sel:streamingOptions:DirectKafkaSource' :: DirectKafkaSource -> Maybe KafkaStreamingSourceOptions
$sel:detectSchema:DirectKafkaSource' :: DirectKafkaSource -> Maybe Bool
$sel:dataPreviewOptions:DirectKafkaSource' :: DirectKafkaSource -> 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

instance Data.ToJSON DirectKafkaSource where
  toJSON :: DirectKafkaSource -> Value
toJSON DirectKafkaSource' {Maybe Bool
Maybe Natural
Maybe KafkaStreamingSourceOptions
Maybe StreamingDataPreviewOptions
Text
name :: Text
windowSize :: Maybe Natural
streamingOptions :: Maybe KafkaStreamingSourceOptions
detectSchema :: Maybe Bool
dataPreviewOptions :: Maybe StreamingDataPreviewOptions
$sel:name:DirectKafkaSource' :: DirectKafkaSource -> Text
$sel:windowSize:DirectKafkaSource' :: DirectKafkaSource -> Maybe Natural
$sel:streamingOptions:DirectKafkaSource' :: DirectKafkaSource -> Maybe KafkaStreamingSourceOptions
$sel:detectSchema:DirectKafkaSource' :: DirectKafkaSource -> Maybe Bool
$sel:dataPreviewOptions:DirectKafkaSource' :: DirectKafkaSource -> 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)
          ]
      )