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

-- |
-- Create a value of 'DirectKinesisSource' 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', 'directKinesisSource_dataPreviewOptions' - Additional options for data preview.
--
-- 'detectSchema', 'directKinesisSource_detectSchema' - Whether to automatically determine the schema from the incoming data.
--
-- 'streamingOptions', 'directKinesisSource_streamingOptions' - Additional options for the Kinesis streaming data source.
--
-- 'windowSize', 'directKinesisSource_windowSize' - The amount of time to spend processing each micro batch.
--
-- 'name', 'directKinesisSource_name' - The name of the data source.
newDirectKinesisSource ::
  -- | 'name'
  Prelude.Text ->
  DirectKinesisSource
newDirectKinesisSource :: Text -> DirectKinesisSource
newDirectKinesisSource Text
pName_ =
  DirectKinesisSource'
    { $sel:dataPreviewOptions:DirectKinesisSource' :: Maybe StreamingDataPreviewOptions
dataPreviewOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:detectSchema:DirectKinesisSource' :: Maybe Bool
detectSchema = forall a. Maybe a
Prelude.Nothing,
      $sel:streamingOptions:DirectKinesisSource' :: Maybe KinesisStreamingSourceOptions
streamingOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:windowSize:DirectKinesisSource' :: Maybe Natural
windowSize = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DirectKinesisSource' :: Text
name = Text
pName_
    }

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

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

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

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

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

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

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

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