{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KinesisAnalytics.Types.Input where

import qualified Amazonka.Core as Core
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.Lens as Lens
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 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,
    -- | 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,
    -- | 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
(Input -> Input -> Bool) -> (Input -> Input -> Bool) -> Eq Input
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]
(Int -> ReadS Input)
-> ReadS [Input]
-> ReadPrec Input
-> ReadPrec [Input]
-> Read 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
(Int -> Input -> ShowS)
-> (Input -> String) -> ([Input] -> ShowS) -> Show Input
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. Input -> Rep Input x)
-> (forall x. Rep Input x -> Input) -> Generic Input
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>.
--
-- '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.
--
-- '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.
--
-- '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' :: Maybe InputParallelism
-> Maybe InputProcessingConfiguration
-> Maybe KinesisStreamsInput
-> Maybe KinesisFirehoseInput
-> Text
-> SourceSchema
-> Input
Input'
    { $sel:inputParallelism:Input' :: Maybe InputParallelism
inputParallelism = Maybe InputParallelism
forall a. Maybe a
Prelude.Nothing,
      $sel:inputProcessingConfiguration:Input' :: Maybe InputProcessingConfiguration
inputProcessingConfiguration = Maybe InputProcessingConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisStreamsInput:Input' :: Maybe KinesisStreamsInput
kinesisStreamsInput = Maybe KinesisStreamsInput
forall a. Maybe a
Prelude.Nothing,
      $sel:kinesisFirehoseInput:Input' :: Maybe KinesisFirehoseInput
kinesisFirehoseInput = Maybe KinesisFirehoseInput
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 :: (Maybe InputParallelism -> f (Maybe InputParallelism))
-> Input -> f Input
input_inputParallelism = (Input -> Maybe InputParallelism)
-> (Input -> Maybe InputParallelism -> Input)
-> Lens
     Input Input (Maybe InputParallelism) (Maybe 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 :: (Maybe InputProcessingConfiguration
 -> f (Maybe InputProcessingConfiguration))
-> Input -> f Input
input_inputProcessingConfiguration = (Input -> Maybe InputProcessingConfiguration)
-> (Input -> Maybe InputProcessingConfiguration -> Input)
-> Lens
     Input
     Input
     (Maybe InputProcessingConfiguration)
     (Maybe 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 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 :: (Maybe KinesisStreamsInput -> f (Maybe KinesisStreamsInput))
-> Input -> f Input
input_kinesisStreamsInput = (Input -> Maybe KinesisStreamsInput)
-> (Input -> Maybe KinesisStreamsInput -> Input)
-> Lens
     Input Input (Maybe KinesisStreamsInput) (Maybe 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)

-- | 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 :: (Maybe KinesisFirehoseInput -> f (Maybe KinesisFirehoseInput))
-> Input -> f Input
input_kinesisFirehoseInput = (Input -> Maybe KinesisFirehoseInput)
-> (Input -> Maybe KinesisFirehoseInput -> Input)
-> Lens
     Input
     Input
     (Maybe KinesisFirehoseInput)
     (Maybe 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)

-- | 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 :: (Text -> f Text) -> Input -> f Input
input_namePrefix = (Input -> Text)
-> (Input -> Text -> Input) -> Lens Input Input Text Text
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 :: (SourceSchema -> f SourceSchema) -> Input -> f Input
input_inputSchema = (Input -> SourceSchema)
-> (Input -> SourceSchema -> Input)
-> Lens Input Input SourceSchema SourceSchema
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

instance Prelude.NFData Input

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