{-# 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.KinesisVideoMedia.Types.StartSelector
-- 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.KinesisVideoMedia.Types.StartSelector where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisVideoMedia.Types.StartSelectorType
import qualified Amazonka.Prelude as Prelude

-- | Identifies the chunk on the Kinesis video stream where you want the
-- @GetMedia@ API to start returning media data. You have the following
-- options to identify the starting chunk:
--
-- -   Choose the latest (or oldest) chunk.
--
-- -   Identify a specific chunk. You can identify a specific chunk either
--     by providing a fragment number or timestamp (server or producer).
--
-- -   Each chunk\'s metadata includes a continuation token as a Matroska
--     (MKV) tag (@AWS_KINESISVIDEO_CONTINUATION_TOKEN@). If your previous
--     @GetMedia@ request terminated, you can use this tag value in your
--     next @GetMedia@ request. The API then starts returning chunks
--     starting where the last API ended.
--
-- /See:/ 'newStartSelector' smart constructor.
data StartSelector = StartSelector'
  { -- | Specifies the fragment number from where you want the @GetMedia@ API to
    -- start returning the fragments.
    StartSelector -> Maybe Text
afterFragmentNumber :: Prelude.Maybe Prelude.Text,
    -- | Continuation token that Kinesis Video Streams returned in the previous
    -- @GetMedia@ response. The @GetMedia@ API then starts with the chunk
    -- identified by the continuation token.
    StartSelector -> Maybe Text
continuationToken :: Prelude.Maybe Prelude.Text,
    -- | A timestamp value. This value is required if you choose the
    -- PRODUCER_TIMESTAMP or the SERVER_TIMESTAMP as the @startSelectorType@.
    -- The @GetMedia@ API then starts with the chunk containing the fragment
    -- that has the specified timestamp.
    StartSelector -> Maybe POSIX
startTimestamp :: Prelude.Maybe Data.POSIX,
    -- | Identifies the fragment on the Kinesis video stream where you want to
    -- start getting the data from.
    --
    -- -   NOW - Start with the latest chunk on the stream.
    --
    -- -   EARLIEST - Start with earliest available chunk on the stream.
    --
    -- -   FRAGMENT_NUMBER - Start with the chunk after a specific fragment.
    --     You must also specify the @AfterFragmentNumber@ parameter.
    --
    -- -   PRODUCER_TIMESTAMP or SERVER_TIMESTAMP - Start with the chunk
    --     containing a fragment with the specified producer or server
    --     timestamp. You specify the timestamp by adding @StartTimestamp@.
    --
    -- -   CONTINUATION_TOKEN - Read using the specified continuation token.
    --
    -- If you choose the NOW, EARLIEST, or CONTINUATION_TOKEN as the
    -- @startSelectorType@, you don\'t provide any additional information in
    -- the @startSelector@.
    StartSelector -> StartSelectorType
startSelectorType :: StartSelectorType
  }
  deriving (StartSelector -> StartSelector -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartSelector -> StartSelector -> Bool
$c/= :: StartSelector -> StartSelector -> Bool
== :: StartSelector -> StartSelector -> Bool
$c== :: StartSelector -> StartSelector -> Bool
Prelude.Eq, ReadPrec [StartSelector]
ReadPrec StartSelector
Int -> ReadS StartSelector
ReadS [StartSelector]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartSelector]
$creadListPrec :: ReadPrec [StartSelector]
readPrec :: ReadPrec StartSelector
$creadPrec :: ReadPrec StartSelector
readList :: ReadS [StartSelector]
$creadList :: ReadS [StartSelector]
readsPrec :: Int -> ReadS StartSelector
$creadsPrec :: Int -> ReadS StartSelector
Prelude.Read, Int -> StartSelector -> ShowS
[StartSelector] -> ShowS
StartSelector -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartSelector] -> ShowS
$cshowList :: [StartSelector] -> ShowS
show :: StartSelector -> String
$cshow :: StartSelector -> String
showsPrec :: Int -> StartSelector -> ShowS
$cshowsPrec :: Int -> StartSelector -> ShowS
Prelude.Show, forall x. Rep StartSelector x -> StartSelector
forall x. StartSelector -> Rep StartSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartSelector x -> StartSelector
$cfrom :: forall x. StartSelector -> Rep StartSelector x
Prelude.Generic)

-- |
-- Create a value of 'StartSelector' 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:
--
-- 'afterFragmentNumber', 'startSelector_afterFragmentNumber' - Specifies the fragment number from where you want the @GetMedia@ API to
-- start returning the fragments.
--
-- 'continuationToken', 'startSelector_continuationToken' - Continuation token that Kinesis Video Streams returned in the previous
-- @GetMedia@ response. The @GetMedia@ API then starts with the chunk
-- identified by the continuation token.
--
-- 'startTimestamp', 'startSelector_startTimestamp' - A timestamp value. This value is required if you choose the
-- PRODUCER_TIMESTAMP or the SERVER_TIMESTAMP as the @startSelectorType@.
-- The @GetMedia@ API then starts with the chunk containing the fragment
-- that has the specified timestamp.
--
-- 'startSelectorType', 'startSelector_startSelectorType' - Identifies the fragment on the Kinesis video stream where you want to
-- start getting the data from.
--
-- -   NOW - Start with the latest chunk on the stream.
--
-- -   EARLIEST - Start with earliest available chunk on the stream.
--
-- -   FRAGMENT_NUMBER - Start with the chunk after a specific fragment.
--     You must also specify the @AfterFragmentNumber@ parameter.
--
-- -   PRODUCER_TIMESTAMP or SERVER_TIMESTAMP - Start with the chunk
--     containing a fragment with the specified producer or server
--     timestamp. You specify the timestamp by adding @StartTimestamp@.
--
-- -   CONTINUATION_TOKEN - Read using the specified continuation token.
--
-- If you choose the NOW, EARLIEST, or CONTINUATION_TOKEN as the
-- @startSelectorType@, you don\'t provide any additional information in
-- the @startSelector@.
newStartSelector ::
  -- | 'startSelectorType'
  StartSelectorType ->
  StartSelector
newStartSelector :: StartSelectorType -> StartSelector
newStartSelector StartSelectorType
pStartSelectorType_ =
  StartSelector'
    { $sel:afterFragmentNumber:StartSelector' :: Maybe Text
afterFragmentNumber =
        forall a. Maybe a
Prelude.Nothing,
      $sel:continuationToken:StartSelector' :: Maybe Text
continuationToken = forall a. Maybe a
Prelude.Nothing,
      $sel:startTimestamp:StartSelector' :: Maybe POSIX
startTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:startSelectorType:StartSelector' :: StartSelectorType
startSelectorType = StartSelectorType
pStartSelectorType_
    }

-- | Specifies the fragment number from where you want the @GetMedia@ API to
-- start returning the fragments.
startSelector_afterFragmentNumber :: Lens.Lens' StartSelector (Prelude.Maybe Prelude.Text)
startSelector_afterFragmentNumber :: Lens' StartSelector (Maybe Text)
startSelector_afterFragmentNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartSelector' {Maybe Text
afterFragmentNumber :: Maybe Text
$sel:afterFragmentNumber:StartSelector' :: StartSelector -> Maybe Text
afterFragmentNumber} -> Maybe Text
afterFragmentNumber) (\s :: StartSelector
s@StartSelector' {} Maybe Text
a -> StartSelector
s {$sel:afterFragmentNumber:StartSelector' :: Maybe Text
afterFragmentNumber = Maybe Text
a} :: StartSelector)

-- | Continuation token that Kinesis Video Streams returned in the previous
-- @GetMedia@ response. The @GetMedia@ API then starts with the chunk
-- identified by the continuation token.
startSelector_continuationToken :: Lens.Lens' StartSelector (Prelude.Maybe Prelude.Text)
startSelector_continuationToken :: Lens' StartSelector (Maybe Text)
startSelector_continuationToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartSelector' {Maybe Text
continuationToken :: Maybe Text
$sel:continuationToken:StartSelector' :: StartSelector -> Maybe Text
continuationToken} -> Maybe Text
continuationToken) (\s :: StartSelector
s@StartSelector' {} Maybe Text
a -> StartSelector
s {$sel:continuationToken:StartSelector' :: Maybe Text
continuationToken = Maybe Text
a} :: StartSelector)

-- | A timestamp value. This value is required if you choose the
-- PRODUCER_TIMESTAMP or the SERVER_TIMESTAMP as the @startSelectorType@.
-- The @GetMedia@ API then starts with the chunk containing the fragment
-- that has the specified timestamp.
startSelector_startTimestamp :: Lens.Lens' StartSelector (Prelude.Maybe Prelude.UTCTime)
startSelector_startTimestamp :: Lens' StartSelector (Maybe UTCTime)
startSelector_startTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartSelector' {Maybe POSIX
startTimestamp :: Maybe POSIX
$sel:startTimestamp:StartSelector' :: StartSelector -> Maybe POSIX
startTimestamp} -> Maybe POSIX
startTimestamp) (\s :: StartSelector
s@StartSelector' {} Maybe POSIX
a -> StartSelector
s {$sel:startTimestamp:StartSelector' :: Maybe POSIX
startTimestamp = Maybe POSIX
a} :: StartSelector) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Identifies the fragment on the Kinesis video stream where you want to
-- start getting the data from.
--
-- -   NOW - Start with the latest chunk on the stream.
--
-- -   EARLIEST - Start with earliest available chunk on the stream.
--
-- -   FRAGMENT_NUMBER - Start with the chunk after a specific fragment.
--     You must also specify the @AfterFragmentNumber@ parameter.
--
-- -   PRODUCER_TIMESTAMP or SERVER_TIMESTAMP - Start with the chunk
--     containing a fragment with the specified producer or server
--     timestamp. You specify the timestamp by adding @StartTimestamp@.
--
-- -   CONTINUATION_TOKEN - Read using the specified continuation token.
--
-- If you choose the NOW, EARLIEST, or CONTINUATION_TOKEN as the
-- @startSelectorType@, you don\'t provide any additional information in
-- the @startSelector@.
startSelector_startSelectorType :: Lens.Lens' StartSelector StartSelectorType
startSelector_startSelectorType :: Lens' StartSelector StartSelectorType
startSelector_startSelectorType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartSelector' {StartSelectorType
startSelectorType :: StartSelectorType
$sel:startSelectorType:StartSelector' :: StartSelector -> StartSelectorType
startSelectorType} -> StartSelectorType
startSelectorType) (\s :: StartSelector
s@StartSelector' {} StartSelectorType
a -> StartSelector
s {$sel:startSelectorType:StartSelector' :: StartSelectorType
startSelectorType = StartSelectorType
a} :: StartSelector)

instance Prelude.Hashable StartSelector where
  hashWithSalt :: Int -> StartSelector -> Int
hashWithSalt Int
_salt StartSelector' {Maybe Text
Maybe POSIX
StartSelectorType
startSelectorType :: StartSelectorType
startTimestamp :: Maybe POSIX
continuationToken :: Maybe Text
afterFragmentNumber :: Maybe Text
$sel:startSelectorType:StartSelector' :: StartSelector -> StartSelectorType
$sel:startTimestamp:StartSelector' :: StartSelector -> Maybe POSIX
$sel:continuationToken:StartSelector' :: StartSelector -> Maybe Text
$sel:afterFragmentNumber:StartSelector' :: StartSelector -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
afterFragmentNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
continuationToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StartSelectorType
startSelectorType

instance Prelude.NFData StartSelector where
  rnf :: StartSelector -> ()
rnf StartSelector' {Maybe Text
Maybe POSIX
StartSelectorType
startSelectorType :: StartSelectorType
startTimestamp :: Maybe POSIX
continuationToken :: Maybe Text
afterFragmentNumber :: Maybe Text
$sel:startSelectorType:StartSelector' :: StartSelector -> StartSelectorType
$sel:startTimestamp:StartSelector' :: StartSelector -> Maybe POSIX
$sel:continuationToken:StartSelector' :: StartSelector -> Maybe Text
$sel:afterFragmentNumber:StartSelector' :: StartSelector -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
afterFragmentNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
continuationToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StartSelectorType
startSelectorType

instance Data.ToJSON StartSelector where
  toJSON :: StartSelector -> Value
toJSON StartSelector' {Maybe Text
Maybe POSIX
StartSelectorType
startSelectorType :: StartSelectorType
startTimestamp :: Maybe POSIX
continuationToken :: Maybe Text
afterFragmentNumber :: Maybe Text
$sel:startSelectorType:StartSelector' :: StartSelector -> StartSelectorType
$sel:startTimestamp:StartSelector' :: StartSelector -> Maybe POSIX
$sel:continuationToken:StartSelector' :: StartSelector -> Maybe Text
$sel:afterFragmentNumber:StartSelector' :: StartSelector -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AfterFragmentNumber" 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 Text
afterFragmentNumber,
            (Key
"ContinuationToken" 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 Text
continuationToken,
            (Key
"StartTimestamp" 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 POSIX
startTimestamp,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"StartSelectorType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= StartSelectorType
startSelectorType)
          ]
      )