{-# 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.ConnectParticipant.Types.StartPosition
-- 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.ConnectParticipant.Types.StartPosition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A filtering option for where to start. For example, if you sent 100
-- messages, start with message 50.
--
-- /See:/ 'newStartPosition' smart constructor.
data StartPosition = StartPosition'
  { -- | The time in ISO format where to start.
    --
    -- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
    -- example, 2019-11-08T02:41:28.172Z.
    StartPosition -> Maybe Text
absoluteTime :: Prelude.Maybe Prelude.Text,
    -- | The ID of the message or event where to start.
    StartPosition -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The start position of the most recent message where you want to start.
    StartPosition -> Maybe Natural
mostRecent :: Prelude.Maybe Prelude.Natural
  }
  deriving (StartPosition -> StartPosition -> Bool
(StartPosition -> StartPosition -> Bool)
-> (StartPosition -> StartPosition -> Bool) -> Eq StartPosition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartPosition -> StartPosition -> Bool
$c/= :: StartPosition -> StartPosition -> Bool
== :: StartPosition -> StartPosition -> Bool
$c== :: StartPosition -> StartPosition -> Bool
Prelude.Eq, ReadPrec [StartPosition]
ReadPrec StartPosition
Int -> ReadS StartPosition
ReadS [StartPosition]
(Int -> ReadS StartPosition)
-> ReadS [StartPosition]
-> ReadPrec StartPosition
-> ReadPrec [StartPosition]
-> Read StartPosition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartPosition]
$creadListPrec :: ReadPrec [StartPosition]
readPrec :: ReadPrec StartPosition
$creadPrec :: ReadPrec StartPosition
readList :: ReadS [StartPosition]
$creadList :: ReadS [StartPosition]
readsPrec :: Int -> ReadS StartPosition
$creadsPrec :: Int -> ReadS StartPosition
Prelude.Read, Int -> StartPosition -> ShowS
[StartPosition] -> ShowS
StartPosition -> String
(Int -> StartPosition -> ShowS)
-> (StartPosition -> String)
-> ([StartPosition] -> ShowS)
-> Show StartPosition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartPosition] -> ShowS
$cshowList :: [StartPosition] -> ShowS
show :: StartPosition -> String
$cshow :: StartPosition -> String
showsPrec :: Int -> StartPosition -> ShowS
$cshowsPrec :: Int -> StartPosition -> ShowS
Prelude.Show, (forall x. StartPosition -> Rep StartPosition x)
-> (forall x. Rep StartPosition x -> StartPosition)
-> Generic StartPosition
forall x. Rep StartPosition x -> StartPosition
forall x. StartPosition -> Rep StartPosition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartPosition x -> StartPosition
$cfrom :: forall x. StartPosition -> Rep StartPosition x
Prelude.Generic)

-- |
-- Create a value of 'StartPosition' 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:
--
-- 'absoluteTime', 'startPosition_absoluteTime' - The time in ISO format where to start.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
--
-- 'id', 'startPosition_id' - The ID of the message or event where to start.
--
-- 'mostRecent', 'startPosition_mostRecent' - The start position of the most recent message where you want to start.
newStartPosition ::
  StartPosition
newStartPosition :: StartPosition
newStartPosition =
  StartPosition' :: Maybe Text -> Maybe Text -> Maybe Natural -> StartPosition
StartPosition'
    { $sel:absoluteTime:StartPosition' :: Maybe Text
absoluteTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:StartPosition' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:mostRecent:StartPosition' :: Maybe Natural
mostRecent = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The time in ISO format where to start.
--
-- It\'s specified in ISO 8601 format: yyyy-MM-ddThh:mm:ss.SSSZ. For
-- example, 2019-11-08T02:41:28.172Z.
startPosition_absoluteTime :: Lens.Lens' StartPosition (Prelude.Maybe Prelude.Text)
startPosition_absoluteTime :: (Maybe Text -> f (Maybe Text)) -> StartPosition -> f StartPosition
startPosition_absoluteTime = (StartPosition -> Maybe Text)
-> (StartPosition -> Maybe Text -> StartPosition)
-> Lens StartPosition StartPosition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPosition' {Maybe Text
absoluteTime :: Maybe Text
$sel:absoluteTime:StartPosition' :: StartPosition -> Maybe Text
absoluteTime} -> Maybe Text
absoluteTime) (\s :: StartPosition
s@StartPosition' {} Maybe Text
a -> StartPosition
s {$sel:absoluteTime:StartPosition' :: Maybe Text
absoluteTime = Maybe Text
a} :: StartPosition)

-- | The ID of the message or event where to start.
startPosition_id :: Lens.Lens' StartPosition (Prelude.Maybe Prelude.Text)
startPosition_id :: (Maybe Text -> f (Maybe Text)) -> StartPosition -> f StartPosition
startPosition_id = (StartPosition -> Maybe Text)
-> (StartPosition -> Maybe Text -> StartPosition)
-> Lens StartPosition StartPosition (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPosition' {Maybe Text
id :: Maybe Text
$sel:id:StartPosition' :: StartPosition -> Maybe Text
id} -> Maybe Text
id) (\s :: StartPosition
s@StartPosition' {} Maybe Text
a -> StartPosition
s {$sel:id:StartPosition' :: Maybe Text
id = Maybe Text
a} :: StartPosition)

-- | The start position of the most recent message where you want to start.
startPosition_mostRecent :: Lens.Lens' StartPosition (Prelude.Maybe Prelude.Natural)
startPosition_mostRecent :: (Maybe Natural -> f (Maybe Natural))
-> StartPosition -> f StartPosition
startPosition_mostRecent = (StartPosition -> Maybe Natural)
-> (StartPosition -> Maybe Natural -> StartPosition)
-> Lens StartPosition StartPosition (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPosition' {Maybe Natural
mostRecent :: Maybe Natural
$sel:mostRecent:StartPosition' :: StartPosition -> Maybe Natural
mostRecent} -> Maybe Natural
mostRecent) (\s :: StartPosition
s@StartPosition' {} Maybe Natural
a -> StartPosition
s {$sel:mostRecent:StartPosition' :: Maybe Natural
mostRecent = Maybe Natural
a} :: StartPosition)

instance Prelude.Hashable StartPosition

instance Prelude.NFData StartPosition

instance Core.ToJSON StartPosition where
  toJSON :: StartPosition -> Value
toJSON StartPosition' {Maybe Natural
Maybe Text
mostRecent :: Maybe Natural
id :: Maybe Text
absoluteTime :: Maybe Text
$sel:mostRecent:StartPosition' :: StartPosition -> Maybe Natural
$sel:id:StartPosition' :: StartPosition -> Maybe Text
$sel:absoluteTime:StartPosition' :: StartPosition -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AbsoluteTime" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
absoluteTime,
            (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
id,
            (Text
"MostRecent" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
mostRecent
          ]
      )