{-# 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.KinesisAnalyticsV2.Types.SqlRunConfiguration
-- 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.KinesisAnalyticsV2.Types.SqlRunConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.InputStartingPositionConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the starting parameters for a SQL-based Kinesis Data Analytics
-- application.
--
-- /See:/ 'newSqlRunConfiguration' smart constructor.
data SqlRunConfiguration = SqlRunConfiguration'
  { -- | The input source ID. You can get this ID by calling the
    -- DescribeApplication operation.
    SqlRunConfiguration -> Text
inputId :: Prelude.Text,
    -- | The point at which you want the application to start processing records
    -- from the streaming source.
    SqlRunConfiguration -> InputStartingPositionConfiguration
inputStartingPositionConfiguration :: InputStartingPositionConfiguration
  }
  deriving (SqlRunConfiguration -> SqlRunConfiguration -> Bool
(SqlRunConfiguration -> SqlRunConfiguration -> Bool)
-> (SqlRunConfiguration -> SqlRunConfiguration -> Bool)
-> Eq SqlRunConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqlRunConfiguration -> SqlRunConfiguration -> Bool
$c/= :: SqlRunConfiguration -> SqlRunConfiguration -> Bool
== :: SqlRunConfiguration -> SqlRunConfiguration -> Bool
$c== :: SqlRunConfiguration -> SqlRunConfiguration -> Bool
Prelude.Eq, ReadPrec [SqlRunConfiguration]
ReadPrec SqlRunConfiguration
Int -> ReadS SqlRunConfiguration
ReadS [SqlRunConfiguration]
(Int -> ReadS SqlRunConfiguration)
-> ReadS [SqlRunConfiguration]
-> ReadPrec SqlRunConfiguration
-> ReadPrec [SqlRunConfiguration]
-> Read SqlRunConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SqlRunConfiguration]
$creadListPrec :: ReadPrec [SqlRunConfiguration]
readPrec :: ReadPrec SqlRunConfiguration
$creadPrec :: ReadPrec SqlRunConfiguration
readList :: ReadS [SqlRunConfiguration]
$creadList :: ReadS [SqlRunConfiguration]
readsPrec :: Int -> ReadS SqlRunConfiguration
$creadsPrec :: Int -> ReadS SqlRunConfiguration
Prelude.Read, Int -> SqlRunConfiguration -> ShowS
[SqlRunConfiguration] -> ShowS
SqlRunConfiguration -> String
(Int -> SqlRunConfiguration -> ShowS)
-> (SqlRunConfiguration -> String)
-> ([SqlRunConfiguration] -> ShowS)
-> Show SqlRunConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqlRunConfiguration] -> ShowS
$cshowList :: [SqlRunConfiguration] -> ShowS
show :: SqlRunConfiguration -> String
$cshow :: SqlRunConfiguration -> String
showsPrec :: Int -> SqlRunConfiguration -> ShowS
$cshowsPrec :: Int -> SqlRunConfiguration -> ShowS
Prelude.Show, (forall x. SqlRunConfiguration -> Rep SqlRunConfiguration x)
-> (forall x. Rep SqlRunConfiguration x -> SqlRunConfiguration)
-> Generic SqlRunConfiguration
forall x. Rep SqlRunConfiguration x -> SqlRunConfiguration
forall x. SqlRunConfiguration -> Rep SqlRunConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SqlRunConfiguration x -> SqlRunConfiguration
$cfrom :: forall x. SqlRunConfiguration -> Rep SqlRunConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SqlRunConfiguration' 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:
--
-- 'inputId', 'sqlRunConfiguration_inputId' - The input source ID. You can get this ID by calling the
-- DescribeApplication operation.
--
-- 'inputStartingPositionConfiguration', 'sqlRunConfiguration_inputStartingPositionConfiguration' - The point at which you want the application to start processing records
-- from the streaming source.
newSqlRunConfiguration ::
  -- | 'inputId'
  Prelude.Text ->
  -- | 'inputStartingPositionConfiguration'
  InputStartingPositionConfiguration ->
  SqlRunConfiguration
newSqlRunConfiguration :: Text -> InputStartingPositionConfiguration -> SqlRunConfiguration
newSqlRunConfiguration
  Text
pInputId_
  InputStartingPositionConfiguration
pInputStartingPositionConfiguration_ =
    SqlRunConfiguration' :: Text -> InputStartingPositionConfiguration -> SqlRunConfiguration
SqlRunConfiguration'
      { $sel:inputId:SqlRunConfiguration' :: Text
inputId = Text
pInputId_,
        $sel:inputStartingPositionConfiguration:SqlRunConfiguration' :: InputStartingPositionConfiguration
inputStartingPositionConfiguration =
          InputStartingPositionConfiguration
pInputStartingPositionConfiguration_
      }

-- | The input source ID. You can get this ID by calling the
-- DescribeApplication operation.
sqlRunConfiguration_inputId :: Lens.Lens' SqlRunConfiguration Prelude.Text
sqlRunConfiguration_inputId :: (Text -> f Text) -> SqlRunConfiguration -> f SqlRunConfiguration
sqlRunConfiguration_inputId = (SqlRunConfiguration -> Text)
-> (SqlRunConfiguration -> Text -> SqlRunConfiguration)
-> Lens SqlRunConfiguration SqlRunConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqlRunConfiguration' {Text
inputId :: Text
$sel:inputId:SqlRunConfiguration' :: SqlRunConfiguration -> Text
inputId} -> Text
inputId) (\s :: SqlRunConfiguration
s@SqlRunConfiguration' {} Text
a -> SqlRunConfiguration
s {$sel:inputId:SqlRunConfiguration' :: Text
inputId = Text
a} :: SqlRunConfiguration)

-- | The point at which you want the application to start processing records
-- from the streaming source.
sqlRunConfiguration_inputStartingPositionConfiguration :: Lens.Lens' SqlRunConfiguration InputStartingPositionConfiguration
sqlRunConfiguration_inputStartingPositionConfiguration :: (InputStartingPositionConfiguration
 -> f InputStartingPositionConfiguration)
-> SqlRunConfiguration -> f SqlRunConfiguration
sqlRunConfiguration_inputStartingPositionConfiguration = (SqlRunConfiguration -> InputStartingPositionConfiguration)
-> (SqlRunConfiguration
    -> InputStartingPositionConfiguration -> SqlRunConfiguration)
-> Lens
     SqlRunConfiguration
     SqlRunConfiguration
     InputStartingPositionConfiguration
     InputStartingPositionConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SqlRunConfiguration' {InputStartingPositionConfiguration
inputStartingPositionConfiguration :: InputStartingPositionConfiguration
$sel:inputStartingPositionConfiguration:SqlRunConfiguration' :: SqlRunConfiguration -> InputStartingPositionConfiguration
inputStartingPositionConfiguration} -> InputStartingPositionConfiguration
inputStartingPositionConfiguration) (\s :: SqlRunConfiguration
s@SqlRunConfiguration' {} InputStartingPositionConfiguration
a -> SqlRunConfiguration
s {$sel:inputStartingPositionConfiguration:SqlRunConfiguration' :: InputStartingPositionConfiguration
inputStartingPositionConfiguration = InputStartingPositionConfiguration
a} :: SqlRunConfiguration)

instance Prelude.Hashable SqlRunConfiguration

instance Prelude.NFData SqlRunConfiguration

instance Core.ToJSON SqlRunConfiguration where
  toJSON :: SqlRunConfiguration -> Value
toJSON SqlRunConfiguration' {Text
InputStartingPositionConfiguration
inputStartingPositionConfiguration :: InputStartingPositionConfiguration
inputId :: Text
$sel:inputStartingPositionConfiguration:SqlRunConfiguration' :: SqlRunConfiguration -> InputStartingPositionConfiguration
$sel:inputId:SqlRunConfiguration' :: SqlRunConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InputId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
inputId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"InputStartingPositionConfiguration"
                  Text -> InputStartingPositionConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InputStartingPositionConfiguration
inputStartingPositionConfiguration
              )
          ]
      )