{-# 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.KinesisVideoArchivedMedia.Types.HLSTimestampRange
-- 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.KinesisVideoArchivedMedia.Types.HLSTimestampRange where

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

-- | The start and end of the timestamp range for the requested media.
--
-- This value should not be present if @PlaybackType@ is @LIVE@.
--
-- /See:/ 'newHLSTimestampRange' smart constructor.
data HLSTimestampRange = HLSTimestampRange'
  { -- | The end of the timestamp range for the requested media. This value must
    -- be within 24 hours of the specified @StartTimestamp@, and it must be
    -- later than the @StartTimestamp@ value.
    --
    -- If @FragmentSelectorType@ for the request is @SERVER_TIMESTAMP@, this
    -- value must be in the past.
    --
    -- The @EndTimestamp@ value is required for @ON_DEMAND@ mode, but optional
    -- for @LIVE_REPLAY@ mode. If the @EndTimestamp@ is not set for
    -- @LIVE_REPLAY@ mode then the session will continue to include newly
    -- ingested fragments until the session expires.
    --
    -- This value is inclusive. The @EndTimestamp@ is compared to the
    -- (starting) timestamp of the fragment. Fragments that start before the
    -- @EndTimestamp@ value and continue past it are included in the session.
    HLSTimestampRange -> Maybe POSIX
endTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The start of the timestamp range for the requested media.
    --
    -- If the @HLSTimestampRange@ value is specified, the @StartTimestamp@
    -- value is required.
    --
    -- Only fragments that start exactly at or after @StartTimestamp@ are
    -- included in the session. Fragments that start before @StartTimestamp@
    -- and continue past it aren\'t included in the session. If
    -- @FragmentSelectorType@ is @SERVER_TIMESTAMP@, the @StartTimestamp@ must
    -- be later than the stream head.
    HLSTimestampRange -> Maybe POSIX
startTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (HLSTimestampRange -> HLSTimestampRange -> Bool
(HLSTimestampRange -> HLSTimestampRange -> Bool)
-> (HLSTimestampRange -> HLSTimestampRange -> Bool)
-> Eq HLSTimestampRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HLSTimestampRange -> HLSTimestampRange -> Bool
$c/= :: HLSTimestampRange -> HLSTimestampRange -> Bool
== :: HLSTimestampRange -> HLSTimestampRange -> Bool
$c== :: HLSTimestampRange -> HLSTimestampRange -> Bool
Prelude.Eq, ReadPrec [HLSTimestampRange]
ReadPrec HLSTimestampRange
Int -> ReadS HLSTimestampRange
ReadS [HLSTimestampRange]
(Int -> ReadS HLSTimestampRange)
-> ReadS [HLSTimestampRange]
-> ReadPrec HLSTimestampRange
-> ReadPrec [HLSTimestampRange]
-> Read HLSTimestampRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HLSTimestampRange]
$creadListPrec :: ReadPrec [HLSTimestampRange]
readPrec :: ReadPrec HLSTimestampRange
$creadPrec :: ReadPrec HLSTimestampRange
readList :: ReadS [HLSTimestampRange]
$creadList :: ReadS [HLSTimestampRange]
readsPrec :: Int -> ReadS HLSTimestampRange
$creadsPrec :: Int -> ReadS HLSTimestampRange
Prelude.Read, Int -> HLSTimestampRange -> ShowS
[HLSTimestampRange] -> ShowS
HLSTimestampRange -> String
(Int -> HLSTimestampRange -> ShowS)
-> (HLSTimestampRange -> String)
-> ([HLSTimestampRange] -> ShowS)
-> Show HLSTimestampRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HLSTimestampRange] -> ShowS
$cshowList :: [HLSTimestampRange] -> ShowS
show :: HLSTimestampRange -> String
$cshow :: HLSTimestampRange -> String
showsPrec :: Int -> HLSTimestampRange -> ShowS
$cshowsPrec :: Int -> HLSTimestampRange -> ShowS
Prelude.Show, (forall x. HLSTimestampRange -> Rep HLSTimestampRange x)
-> (forall x. Rep HLSTimestampRange x -> HLSTimestampRange)
-> Generic HLSTimestampRange
forall x. Rep HLSTimestampRange x -> HLSTimestampRange
forall x. HLSTimestampRange -> Rep HLSTimestampRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HLSTimestampRange x -> HLSTimestampRange
$cfrom :: forall x. HLSTimestampRange -> Rep HLSTimestampRange x
Prelude.Generic)

-- |
-- Create a value of 'HLSTimestampRange' 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:
--
-- 'endTimestamp', 'hLSTimestampRange_endTimestamp' - The end of the timestamp range for the requested media. This value must
-- be within 24 hours of the specified @StartTimestamp@, and it must be
-- later than the @StartTimestamp@ value.
--
-- If @FragmentSelectorType@ for the request is @SERVER_TIMESTAMP@, this
-- value must be in the past.
--
-- The @EndTimestamp@ value is required for @ON_DEMAND@ mode, but optional
-- for @LIVE_REPLAY@ mode. If the @EndTimestamp@ is not set for
-- @LIVE_REPLAY@ mode then the session will continue to include newly
-- ingested fragments until the session expires.
--
-- This value is inclusive. The @EndTimestamp@ is compared to the
-- (starting) timestamp of the fragment. Fragments that start before the
-- @EndTimestamp@ value and continue past it are included in the session.
--
-- 'startTimestamp', 'hLSTimestampRange_startTimestamp' - The start of the timestamp range for the requested media.
--
-- If the @HLSTimestampRange@ value is specified, the @StartTimestamp@
-- value is required.
--
-- Only fragments that start exactly at or after @StartTimestamp@ are
-- included in the session. Fragments that start before @StartTimestamp@
-- and continue past it aren\'t included in the session. If
-- @FragmentSelectorType@ is @SERVER_TIMESTAMP@, the @StartTimestamp@ must
-- be later than the stream head.
newHLSTimestampRange ::
  HLSTimestampRange
newHLSTimestampRange :: HLSTimestampRange
newHLSTimestampRange =
  HLSTimestampRange' :: Maybe POSIX -> Maybe POSIX -> HLSTimestampRange
HLSTimestampRange'
    { $sel:endTimestamp:HLSTimestampRange' :: Maybe POSIX
endTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:startTimestamp:HLSTimestampRange' :: Maybe POSIX
startTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The end of the timestamp range for the requested media. This value must
-- be within 24 hours of the specified @StartTimestamp@, and it must be
-- later than the @StartTimestamp@ value.
--
-- If @FragmentSelectorType@ for the request is @SERVER_TIMESTAMP@, this
-- value must be in the past.
--
-- The @EndTimestamp@ value is required for @ON_DEMAND@ mode, but optional
-- for @LIVE_REPLAY@ mode. If the @EndTimestamp@ is not set for
-- @LIVE_REPLAY@ mode then the session will continue to include newly
-- ingested fragments until the session expires.
--
-- This value is inclusive. The @EndTimestamp@ is compared to the
-- (starting) timestamp of the fragment. Fragments that start before the
-- @EndTimestamp@ value and continue past it are included in the session.
hLSTimestampRange_endTimestamp :: Lens.Lens' HLSTimestampRange (Prelude.Maybe Prelude.UTCTime)
hLSTimestampRange_endTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> HLSTimestampRange -> f HLSTimestampRange
hLSTimestampRange_endTimestamp = (HLSTimestampRange -> Maybe POSIX)
-> (HLSTimestampRange -> Maybe POSIX -> HLSTimestampRange)
-> Lens
     HLSTimestampRange HLSTimestampRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HLSTimestampRange' {Maybe POSIX
endTimestamp :: Maybe POSIX
$sel:endTimestamp:HLSTimestampRange' :: HLSTimestampRange -> Maybe POSIX
endTimestamp} -> Maybe POSIX
endTimestamp) (\s :: HLSTimestampRange
s@HLSTimestampRange' {} Maybe POSIX
a -> HLSTimestampRange
s {$sel:endTimestamp:HLSTimestampRange' :: Maybe POSIX
endTimestamp = Maybe POSIX
a} :: HLSTimestampRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> HLSTimestampRange -> f HLSTimestampRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> HLSTimestampRange
-> f HLSTimestampRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The start of the timestamp range for the requested media.
--
-- If the @HLSTimestampRange@ value is specified, the @StartTimestamp@
-- value is required.
--
-- Only fragments that start exactly at or after @StartTimestamp@ are
-- included in the session. Fragments that start before @StartTimestamp@
-- and continue past it aren\'t included in the session. If
-- @FragmentSelectorType@ is @SERVER_TIMESTAMP@, the @StartTimestamp@ must
-- be later than the stream head.
hLSTimestampRange_startTimestamp :: Lens.Lens' HLSTimestampRange (Prelude.Maybe Prelude.UTCTime)
hLSTimestampRange_startTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> HLSTimestampRange -> f HLSTimestampRange
hLSTimestampRange_startTimestamp = (HLSTimestampRange -> Maybe POSIX)
-> (HLSTimestampRange -> Maybe POSIX -> HLSTimestampRange)
-> Lens
     HLSTimestampRange HLSTimestampRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HLSTimestampRange' {Maybe POSIX
startTimestamp :: Maybe POSIX
$sel:startTimestamp:HLSTimestampRange' :: HLSTimestampRange -> Maybe POSIX
startTimestamp} -> Maybe POSIX
startTimestamp) (\s :: HLSTimestampRange
s@HLSTimestampRange' {} Maybe POSIX
a -> HLSTimestampRange
s {$sel:startTimestamp:HLSTimestampRange' :: Maybe POSIX
startTimestamp = Maybe POSIX
a} :: HLSTimestampRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> HLSTimestampRange -> f HLSTimestampRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> HLSTimestampRange
-> f HLSTimestampRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.Hashable HLSTimestampRange

instance Prelude.NFData HLSTimestampRange

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