{-# 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.Input
-- 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.KinesisAnalytics.Types.Input where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisAnalytics.Types.InputParallelism
import Amazonka.KinesisAnalytics.Types.InputProcessingConfiguration
import Amazonka.KinesisAnalytics.Types.KinesisFirehoseInput
import Amazonka.KinesisAnalytics.Types.KinesisStreamsInput
import Amazonka.KinesisAnalytics.Types.SourceSchema
import qualified Amazonka.Prelude as Prelude

-- | When you configure the application input, you specify the streaming
-- source, the in-application stream name that is created, and the mapping
-- between the two. For more information, see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html Configuring Application Input>.
--
-- /See:/ 'newInput' smart constructor.
data Input = Input'
  { -- | Describes the number of in-application streams to create.
    --
    -- Data from your source is routed to these in-application input streams.
    --
    -- (see
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html Configuring Application Input>.
    Input -> Maybe InputParallelism
inputParallelism :: Prelude.Maybe InputParallelism,
    -- | The
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html InputProcessingConfiguration>
    -- for the input. An input processor transforms records as they are
    -- received from the stream, before the application\'s SQL code executes.
    -- Currently, the only input processing configuration available is
    -- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html InputLambdaProcessor>.
    Input -> Maybe InputProcessingConfiguration
inputProcessingConfiguration :: Prelude.Maybe InputProcessingConfiguration,
    -- | If the streaming source is an Amazon Kinesis Firehose delivery stream,
    -- identifies the delivery stream\'s ARN and an IAM role that enables
    -- Amazon Kinesis Analytics to access the stream on your behalf.
    --
    -- Note: Either @KinesisStreamsInput@ or @KinesisFirehoseInput@ is
    -- required.
    Input -> Maybe KinesisFirehoseInput
kinesisFirehoseInput :: Prelude.Maybe KinesisFirehoseInput,
    -- | If the streaming source is an Amazon Kinesis stream, identifies the
    -- stream\'s Amazon Resource Name (ARN) and an IAM role that enables Amazon
    -- Kinesis Analytics to access the stream on your behalf.
    --
    -- Note: Either @KinesisStreamsInput@ or @KinesisFirehoseInput@ is
    -- required.
    Input -> Maybe KinesisStreamsInput
kinesisStreamsInput :: Prelude.Maybe KinesisStreamsInput,
    -- | Name prefix to use when creating an in-application stream. Suppose that
    -- you specify a prefix \"MyInApplicationStream.\" Amazon Kinesis Analytics
    -- then creates one or more (as per the @InputParallelism@ count you
    -- specified) in-application streams with names
    -- \"MyInApplicationStream_001,\" \"MyInApplicationStream_002,\" and so on.
    Input -> Text
namePrefix :: Prelude.Text,
    -- | Describes the format of the data in the streaming source, and how each
    -- data element maps to corresponding columns in the in-application stream
    -- that is being created.
    --
    -- Also used to describe the format of the reference data source.
    Input -> SourceSchema
inputSchema :: SourceSchema
  }
  deriving (Input -> Input -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Input -> Input -> Bool
$c/= :: Input -> Input -> Bool
== :: Input -> Input -> Bool
$c== :: Input -> Input -> Bool
Prelude.Eq, ReadPrec [Input]
ReadPrec Input
Int -> ReadS Input
ReadS [Input]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Input]
$creadListPrec :: ReadPrec [Input]
readPrec :: ReadPrec Input
$creadPrec :: ReadPrec Input
readList :: ReadS [Input]
$creadList :: ReadS [Input]
readsPrec :: Int -> ReadS Input
$creadsPrec :: Int -> ReadS Input
Prelude.Read, Int -> Input -> ShowS
[Input] -> ShowS
Input -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Input] -> ShowS
$cshowList :: [Input] -> ShowS
show :: Input -> String
$cshow :: Input -> String
showsPrec :: Int -> Input -> ShowS
$cshowsPrec :: Int -> Input -> ShowS
Prelude.Show, forall x. Rep Input x -> Input
forall x. Input -> Rep Input x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Input x -> Input
$cfrom :: forall x. Input -> Rep Input x
Prelude.Generic)

-- |
-- Create a value of 'Input' 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:
--
-- 'inputParallelism', 'input_inputParallelism' - Describes the number of in-application streams to create.
--
-- Data from your source is routed to these in-application input streams.
--
-- (see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html Configuring Application Input>.
--
-- 'inputProcessingConfiguration', 'input_inputProcessingConfiguration' - The
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html InputProcessingConfiguration>
-- for the input. An input processor transforms records as they are
-- received from the stream, before the application\'s SQL code executes.
-- Currently, the only input processing configuration available is
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html InputLambdaProcessor>.
--
-- 'kinesisFirehoseInput', 'input_kinesisFirehoseInput' - If the streaming source is an Amazon Kinesis Firehose delivery stream,
-- identifies the delivery stream\'s ARN and an IAM role that enables
-- Amazon Kinesis Analytics to access the stream on your behalf.
--
-- Note: Either @KinesisStreamsInput@ or @KinesisFirehoseInput@ is
-- required.
--
-- 'kinesisStreamsInput', 'input_kinesisStreamsInput' - If the streaming source is an Amazon Kinesis stream, identifies the
-- stream\'s Amazon Resource Name (ARN) and an IAM role that enables Amazon
-- Kinesis Analytics to access the stream on your behalf.
--
-- Note: Either @KinesisStreamsInput@ or @KinesisFirehoseInput@ is
-- required.
--
-- 'namePrefix', 'input_namePrefix' - Name prefix to use when creating an in-application stream. Suppose that
-- you specify a prefix \"MyInApplicationStream.\" Amazon Kinesis Analytics
-- then creates one or more (as per the @InputParallelism@ count you
-- specified) in-application streams with names
-- \"MyInApplicationStream_001,\" \"MyInApplicationStream_002,\" and so on.
--
-- 'inputSchema', 'input_inputSchema' - Describes the format of the data in the streaming source, and how each
-- data element maps to corresponding columns in the in-application stream
-- that is being created.
--
-- Also used to describe the format of the reference data source.
newInput ::
  -- | 'namePrefix'
  Prelude.Text ->
  -- | 'inputSchema'
  SourceSchema ->
  Input
newInput :: Text -> SourceSchema -> Input
newInput Text
pNamePrefix_ SourceSchema
pInputSchema_ =
  Input'
    { $sel:inputParallelism:Input' :: Maybe InputParallelism
inputParallelism = forall a. Maybe a
Prelude.Nothing,
      $sel:inputProcessingConfiguration:Input' :: Maybe InputProcessingConfiguration
inputProcessingConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisFirehoseInput:Input' :: Maybe KinesisFirehoseInput
kinesisFirehoseInput = forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisStreamsInput:Input' :: Maybe KinesisStreamsInput
kinesisStreamsInput = forall a. Maybe a
Prelude.Nothing,
      $sel:namePrefix:Input' :: Text
namePrefix = Text
pNamePrefix_,
      $sel:inputSchema:Input' :: SourceSchema
inputSchema = SourceSchema
pInputSchema_
    }

-- | Describes the number of in-application streams to create.
--
-- Data from your source is routed to these in-application input streams.
--
-- (see
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/how-it-works-input.html Configuring Application Input>.
input_inputParallelism :: Lens.Lens' Input (Prelude.Maybe InputParallelism)
input_inputParallelism :: Lens' Input (Maybe InputParallelism)
input_inputParallelism = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe InputParallelism
inputParallelism :: Maybe InputParallelism
$sel:inputParallelism:Input' :: Input -> Maybe InputParallelism
inputParallelism} -> Maybe InputParallelism
inputParallelism) (\s :: Input
s@Input' {} Maybe InputParallelism
a -> Input
s {$sel:inputParallelism:Input' :: Maybe InputParallelism
inputParallelism = Maybe InputParallelism
a} :: Input)

-- | The
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputProcessingConfiguration.html InputProcessingConfiguration>
-- for the input. An input processor transforms records as they are
-- received from the stream, before the application\'s SQL code executes.
-- Currently, the only input processing configuration available is
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_InputLambdaProcessor.html InputLambdaProcessor>.
input_inputProcessingConfiguration :: Lens.Lens' Input (Prelude.Maybe InputProcessingConfiguration)
input_inputProcessingConfiguration :: Lens' Input (Maybe InputProcessingConfiguration)
input_inputProcessingConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe InputProcessingConfiguration
inputProcessingConfiguration :: Maybe InputProcessingConfiguration
$sel:inputProcessingConfiguration:Input' :: Input -> Maybe InputProcessingConfiguration
inputProcessingConfiguration} -> Maybe InputProcessingConfiguration
inputProcessingConfiguration) (\s :: Input
s@Input' {} Maybe InputProcessingConfiguration
a -> Input
s {$sel:inputProcessingConfiguration:Input' :: Maybe InputProcessingConfiguration
inputProcessingConfiguration = Maybe InputProcessingConfiguration
a} :: Input)

-- | If the streaming source is an Amazon Kinesis Firehose delivery stream,
-- identifies the delivery stream\'s ARN and an IAM role that enables
-- Amazon Kinesis Analytics to access the stream on your behalf.
--
-- Note: Either @KinesisStreamsInput@ or @KinesisFirehoseInput@ is
-- required.
input_kinesisFirehoseInput :: Lens.Lens' Input (Prelude.Maybe KinesisFirehoseInput)
input_kinesisFirehoseInput :: Lens' Input (Maybe KinesisFirehoseInput)
input_kinesisFirehoseInput = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe KinesisFirehoseInput
kinesisFirehoseInput :: Maybe KinesisFirehoseInput
$sel:kinesisFirehoseInput:Input' :: Input -> Maybe KinesisFirehoseInput
kinesisFirehoseInput} -> Maybe KinesisFirehoseInput
kinesisFirehoseInput) (\s :: Input
s@Input' {} Maybe KinesisFirehoseInput
a -> Input
s {$sel:kinesisFirehoseInput:Input' :: Maybe KinesisFirehoseInput
kinesisFirehoseInput = Maybe KinesisFirehoseInput
a} :: Input)

-- | If the streaming source is an Amazon Kinesis stream, identifies the
-- stream\'s Amazon Resource Name (ARN) and an IAM role that enables Amazon
-- Kinesis Analytics to access the stream on your behalf.
--
-- Note: Either @KinesisStreamsInput@ or @KinesisFirehoseInput@ is
-- required.
input_kinesisStreamsInput :: Lens.Lens' Input (Prelude.Maybe KinesisStreamsInput)
input_kinesisStreamsInput :: Lens' Input (Maybe KinesisStreamsInput)
input_kinesisStreamsInput = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Maybe KinesisStreamsInput
kinesisStreamsInput :: Maybe KinesisStreamsInput
$sel:kinesisStreamsInput:Input' :: Input -> Maybe KinesisStreamsInput
kinesisStreamsInput} -> Maybe KinesisStreamsInput
kinesisStreamsInput) (\s :: Input
s@Input' {} Maybe KinesisStreamsInput
a -> Input
s {$sel:kinesisStreamsInput:Input' :: Maybe KinesisStreamsInput
kinesisStreamsInput = Maybe KinesisStreamsInput
a} :: Input)

-- | Name prefix to use when creating an in-application stream. Suppose that
-- you specify a prefix \"MyInApplicationStream.\" Amazon Kinesis Analytics
-- then creates one or more (as per the @InputParallelism@ count you
-- specified) in-application streams with names
-- \"MyInApplicationStream_001,\" \"MyInApplicationStream_002,\" and so on.
input_namePrefix :: Lens.Lens' Input Prelude.Text
input_namePrefix :: Lens' Input Text
input_namePrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {Text
namePrefix :: Text
$sel:namePrefix:Input' :: Input -> Text
namePrefix} -> Text
namePrefix) (\s :: Input
s@Input' {} Text
a -> Input
s {$sel:namePrefix:Input' :: Text
namePrefix = Text
a} :: Input)

-- | Describes the format of the data in the streaming source, and how each
-- data element maps to corresponding columns in the in-application stream
-- that is being created.
--
-- Also used to describe the format of the reference data source.
input_inputSchema :: Lens.Lens' Input SourceSchema
input_inputSchema :: Lens' Input SourceSchema
input_inputSchema = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Input' {SourceSchema
inputSchema :: SourceSchema
$sel:inputSchema:Input' :: Input -> SourceSchema
inputSchema} -> SourceSchema
inputSchema) (\s :: Input
s@Input' {} SourceSchema
a -> Input
s {$sel:inputSchema:Input' :: SourceSchema
inputSchema = SourceSchema
a} :: Input)

instance Prelude.Hashable Input where
  hashWithSalt :: Int -> Input -> Int
hashWithSalt Int
_salt Input' {Maybe InputParallelism
Maybe InputProcessingConfiguration
Maybe KinesisFirehoseInput
Maybe KinesisStreamsInput
Text
SourceSchema
inputSchema :: SourceSchema
namePrefix :: Text
kinesisStreamsInput :: Maybe KinesisStreamsInput
kinesisFirehoseInput :: Maybe KinesisFirehoseInput
inputProcessingConfiguration :: Maybe InputProcessingConfiguration
inputParallelism :: Maybe InputParallelism
$sel:inputSchema:Input' :: Input -> SourceSchema
$sel:namePrefix:Input' :: Input -> Text
$sel:kinesisStreamsInput:Input' :: Input -> Maybe KinesisStreamsInput
$sel:kinesisFirehoseInput:Input' :: Input -> Maybe KinesisFirehoseInput
$sel:inputProcessingConfiguration:Input' :: Input -> Maybe InputProcessingConfiguration
$sel:inputParallelism:Input' :: Input -> Maybe InputParallelism
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputParallelism
inputParallelism
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputProcessingConfiguration
inputProcessingConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KinesisFirehoseInput
kinesisFirehoseInput
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KinesisStreamsInput
kinesisStreamsInput
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
namePrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SourceSchema
inputSchema

instance Prelude.NFData Input where
  rnf :: Input -> ()
rnf Input' {Maybe InputParallelism
Maybe InputProcessingConfiguration
Maybe KinesisFirehoseInput
Maybe KinesisStreamsInput
Text
SourceSchema
inputSchema :: SourceSchema
namePrefix :: Text
kinesisStreamsInput :: Maybe KinesisStreamsInput
kinesisFirehoseInput :: Maybe KinesisFirehoseInput
inputProcessingConfiguration :: Maybe InputProcessingConfiguration
inputParallelism :: Maybe InputParallelism
$sel:inputSchema:Input' :: Input -> SourceSchema
$sel:namePrefix:Input' :: Input -> Text
$sel:kinesisStreamsInput:Input' :: Input -> Maybe KinesisStreamsInput
$sel:kinesisFirehoseInput:Input' :: Input -> Maybe KinesisFirehoseInput
$sel:inputProcessingConfiguration:Input' :: Input -> Maybe InputProcessingConfiguration
$sel:inputParallelism:Input' :: Input -> Maybe InputParallelism
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InputParallelism
inputParallelism
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InputProcessingConfiguration
inputProcessingConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KinesisFirehoseInput
kinesisFirehoseInput
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe KinesisStreamsInput
kinesisStreamsInput
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
namePrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SourceSchema
inputSchema

instance Data.ToJSON Input where
  toJSON :: Input -> Value
toJSON Input' {Maybe InputParallelism
Maybe InputProcessingConfiguration
Maybe KinesisFirehoseInput
Maybe KinesisStreamsInput
Text
SourceSchema
inputSchema :: SourceSchema
namePrefix :: Text
kinesisStreamsInput :: Maybe KinesisStreamsInput
kinesisFirehoseInput :: Maybe KinesisFirehoseInput
inputProcessingConfiguration :: Maybe InputProcessingConfiguration
inputParallelism :: Maybe InputParallelism
$sel:inputSchema:Input' :: Input -> SourceSchema
$sel:namePrefix:Input' :: Input -> Text
$sel:kinesisStreamsInput:Input' :: Input -> Maybe KinesisStreamsInput
$sel:kinesisFirehoseInput:Input' :: Input -> Maybe KinesisFirehoseInput
$sel:inputProcessingConfiguration:Input' :: Input -> Maybe InputProcessingConfiguration
$sel:inputParallelism:Input' :: Input -> Maybe InputParallelism
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"InputParallelism" 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 InputParallelism
inputParallelism,
            (Key
"InputProcessingConfiguration" 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 InputProcessingConfiguration
inputProcessingConfiguration,
            (Key
"KinesisFirehoseInput" 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 KinesisFirehoseInput
kinesisFirehoseInput,
            (Key
"KinesisStreamsInput" 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 KinesisStreamsInput
kinesisStreamsInput,
            forall a. a -> Maybe a
Prelude.Just (Key
"NamePrefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
namePrefix),
            forall a. a -> Maybe a
Prelude.Just (Key
"InputSchema" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SourceSchema
inputSchema)
          ]
      )