{-# 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.InputStartingPositionConfiguration
-- 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.InputStartingPositionConfiguration where

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

-- | Describes the point at which the application reads from the streaming
-- source.
--
-- /See:/ 'newInputStartingPositionConfiguration' smart constructor.
data InputStartingPositionConfiguration = InputStartingPositionConfiguration'
  { -- | The starting position on the stream.
    --
    -- -   @NOW@ - Start reading just after the most recent record in the
    --     stream, and start at the request timestamp that the customer issued.
    --
    -- -   @TRIM_HORIZON@ - Start reading at the last untrimmed record in the
    --     stream, which is the oldest record available in the stream. This
    --     option is not available for an Amazon Kinesis Data Firehose delivery
    --     stream.
    --
    -- -   @LAST_STOPPED_POINT@ - Resume reading from where the application
    --     last stopped reading.
    InputStartingPositionConfiguration -> Maybe InputStartingPosition
inputStartingPosition :: Prelude.Maybe InputStartingPosition
  }
  deriving (InputStartingPositionConfiguration
-> InputStartingPositionConfiguration -> Bool
(InputStartingPositionConfiguration
 -> InputStartingPositionConfiguration -> Bool)
-> (InputStartingPositionConfiguration
    -> InputStartingPositionConfiguration -> Bool)
-> Eq InputStartingPositionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputStartingPositionConfiguration
-> InputStartingPositionConfiguration -> Bool
$c/= :: InputStartingPositionConfiguration
-> InputStartingPositionConfiguration -> Bool
== :: InputStartingPositionConfiguration
-> InputStartingPositionConfiguration -> Bool
$c== :: InputStartingPositionConfiguration
-> InputStartingPositionConfiguration -> Bool
Prelude.Eq, ReadPrec [InputStartingPositionConfiguration]
ReadPrec InputStartingPositionConfiguration
Int -> ReadS InputStartingPositionConfiguration
ReadS [InputStartingPositionConfiguration]
(Int -> ReadS InputStartingPositionConfiguration)
-> ReadS [InputStartingPositionConfiguration]
-> ReadPrec InputStartingPositionConfiguration
-> ReadPrec [InputStartingPositionConfiguration]
-> Read InputStartingPositionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputStartingPositionConfiguration]
$creadListPrec :: ReadPrec [InputStartingPositionConfiguration]
readPrec :: ReadPrec InputStartingPositionConfiguration
$creadPrec :: ReadPrec InputStartingPositionConfiguration
readList :: ReadS [InputStartingPositionConfiguration]
$creadList :: ReadS [InputStartingPositionConfiguration]
readsPrec :: Int -> ReadS InputStartingPositionConfiguration
$creadsPrec :: Int -> ReadS InputStartingPositionConfiguration
Prelude.Read, Int -> InputStartingPositionConfiguration -> ShowS
[InputStartingPositionConfiguration] -> ShowS
InputStartingPositionConfiguration -> String
(Int -> InputStartingPositionConfiguration -> ShowS)
-> (InputStartingPositionConfiguration -> String)
-> ([InputStartingPositionConfiguration] -> ShowS)
-> Show InputStartingPositionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputStartingPositionConfiguration] -> ShowS
$cshowList :: [InputStartingPositionConfiguration] -> ShowS
show :: InputStartingPositionConfiguration -> String
$cshow :: InputStartingPositionConfiguration -> String
showsPrec :: Int -> InputStartingPositionConfiguration -> ShowS
$cshowsPrec :: Int -> InputStartingPositionConfiguration -> ShowS
Prelude.Show, (forall x.
 InputStartingPositionConfiguration
 -> Rep InputStartingPositionConfiguration x)
-> (forall x.
    Rep InputStartingPositionConfiguration x
    -> InputStartingPositionConfiguration)
-> Generic InputStartingPositionConfiguration
forall x.
Rep InputStartingPositionConfiguration x
-> InputStartingPositionConfiguration
forall x.
InputStartingPositionConfiguration
-> Rep InputStartingPositionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InputStartingPositionConfiguration x
-> InputStartingPositionConfiguration
$cfrom :: forall x.
InputStartingPositionConfiguration
-> Rep InputStartingPositionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'InputStartingPositionConfiguration' 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:
--
-- 'inputStartingPosition', 'inputStartingPositionConfiguration_inputStartingPosition' - The starting position on the stream.
--
-- -   @NOW@ - Start reading just after the most recent record in the
--     stream, and start at the request timestamp that the customer issued.
--
-- -   @TRIM_HORIZON@ - Start reading at the last untrimmed record in the
--     stream, which is the oldest record available in the stream. This
--     option is not available for an Amazon Kinesis Data Firehose delivery
--     stream.
--
-- -   @LAST_STOPPED_POINT@ - Resume reading from where the application
--     last stopped reading.
newInputStartingPositionConfiguration ::
  InputStartingPositionConfiguration
newInputStartingPositionConfiguration :: InputStartingPositionConfiguration
newInputStartingPositionConfiguration =
  InputStartingPositionConfiguration' :: Maybe InputStartingPosition -> InputStartingPositionConfiguration
InputStartingPositionConfiguration'
    { $sel:inputStartingPosition:InputStartingPositionConfiguration' :: Maybe InputStartingPosition
inputStartingPosition =
        Maybe InputStartingPosition
forall a. Maybe a
Prelude.Nothing
    }

-- | The starting position on the stream.
--
-- -   @NOW@ - Start reading just after the most recent record in the
--     stream, and start at the request timestamp that the customer issued.
--
-- -   @TRIM_HORIZON@ - Start reading at the last untrimmed record in the
--     stream, which is the oldest record available in the stream. This
--     option is not available for an Amazon Kinesis Data Firehose delivery
--     stream.
--
-- -   @LAST_STOPPED_POINT@ - Resume reading from where the application
--     last stopped reading.
inputStartingPositionConfiguration_inputStartingPosition :: Lens.Lens' InputStartingPositionConfiguration (Prelude.Maybe InputStartingPosition)
inputStartingPositionConfiguration_inputStartingPosition :: (Maybe InputStartingPosition -> f (Maybe InputStartingPosition))
-> InputStartingPositionConfiguration
-> f InputStartingPositionConfiguration
inputStartingPositionConfiguration_inputStartingPosition = (InputStartingPositionConfiguration -> Maybe InputStartingPosition)
-> (InputStartingPositionConfiguration
    -> Maybe InputStartingPosition
    -> InputStartingPositionConfiguration)
-> Lens
     InputStartingPositionConfiguration
     InputStartingPositionConfiguration
     (Maybe InputStartingPosition)
     (Maybe InputStartingPosition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputStartingPositionConfiguration' {Maybe InputStartingPosition
inputStartingPosition :: Maybe InputStartingPosition
$sel:inputStartingPosition:InputStartingPositionConfiguration' :: InputStartingPositionConfiguration -> Maybe InputStartingPosition
inputStartingPosition} -> Maybe InputStartingPosition
inputStartingPosition) (\s :: InputStartingPositionConfiguration
s@InputStartingPositionConfiguration' {} Maybe InputStartingPosition
a -> InputStartingPositionConfiguration
s {$sel:inputStartingPosition:InputStartingPositionConfiguration' :: Maybe InputStartingPosition
inputStartingPosition = Maybe InputStartingPosition
a} :: InputStartingPositionConfiguration)

instance
  Core.FromJSON
    InputStartingPositionConfiguration
  where
  parseJSON :: Value -> Parser InputStartingPositionConfiguration
parseJSON =
    String
-> (Object -> Parser InputStartingPositionConfiguration)
-> Value
-> Parser InputStartingPositionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputStartingPositionConfiguration"
      ( \Object
x ->
          Maybe InputStartingPosition -> InputStartingPositionConfiguration
InputStartingPositionConfiguration'
            (Maybe InputStartingPosition -> InputStartingPositionConfiguration)
-> Parser (Maybe InputStartingPosition)
-> Parser InputStartingPositionConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InputStartingPosition)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InputStartingPosition")
      )

instance
  Prelude.Hashable
    InputStartingPositionConfiguration

instance
  Prelude.NFData
    InputStartingPositionConfiguration

instance
  Core.ToJSON
    InputStartingPositionConfiguration
  where
  toJSON :: InputStartingPositionConfiguration -> Value
toJSON InputStartingPositionConfiguration' {Maybe InputStartingPosition
inputStartingPosition :: Maybe InputStartingPosition
$sel:inputStartingPosition:InputStartingPositionConfiguration' :: InputStartingPositionConfiguration -> Maybe InputStartingPosition
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InputStartingPosition" Text -> InputStartingPosition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (InputStartingPosition -> Pair)
-> Maybe InputStartingPosition -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputStartingPosition
inputStartingPosition
          ]
      )