{-# 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.DASHTimestampRange
-- 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.DASHTimestampRange 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@.
--
-- The values in @DASHimestampRange@ are inclusive. Fragments that start
-- exactly at or after the start time are included in the session.
-- Fragments that start before the start time and continue past it are not
-- included in the session.
--
-- /See:/ 'newDASHTimestampRange' smart constructor.
data DASHTimestampRange = DASHTimestampRange'
  { -- | 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.
    DASHTimestampRange -> Maybe POSIX
endTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The start of the timestamp range for the requested media.
    --
    -- If the @DASHTimestampRange@ 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.
    DASHTimestampRange -> Maybe POSIX
startTimestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (DASHTimestampRange -> DASHTimestampRange -> Bool
(DASHTimestampRange -> DASHTimestampRange -> Bool)
-> (DASHTimestampRange -> DASHTimestampRange -> Bool)
-> Eq DASHTimestampRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DASHTimestampRange -> DASHTimestampRange -> Bool
$c/= :: DASHTimestampRange -> DASHTimestampRange -> Bool
== :: DASHTimestampRange -> DASHTimestampRange -> Bool
$c== :: DASHTimestampRange -> DASHTimestampRange -> Bool
Prelude.Eq, ReadPrec [DASHTimestampRange]
ReadPrec DASHTimestampRange
Int -> ReadS DASHTimestampRange
ReadS [DASHTimestampRange]
(Int -> ReadS DASHTimestampRange)
-> ReadS [DASHTimestampRange]
-> ReadPrec DASHTimestampRange
-> ReadPrec [DASHTimestampRange]
-> Read DASHTimestampRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DASHTimestampRange]
$creadListPrec :: ReadPrec [DASHTimestampRange]
readPrec :: ReadPrec DASHTimestampRange
$creadPrec :: ReadPrec DASHTimestampRange
readList :: ReadS [DASHTimestampRange]
$creadList :: ReadS [DASHTimestampRange]
readsPrec :: Int -> ReadS DASHTimestampRange
$creadsPrec :: Int -> ReadS DASHTimestampRange
Prelude.Read, Int -> DASHTimestampRange -> ShowS
[DASHTimestampRange] -> ShowS
DASHTimestampRange -> String
(Int -> DASHTimestampRange -> ShowS)
-> (DASHTimestampRange -> String)
-> ([DASHTimestampRange] -> ShowS)
-> Show DASHTimestampRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DASHTimestampRange] -> ShowS
$cshowList :: [DASHTimestampRange] -> ShowS
show :: DASHTimestampRange -> String
$cshow :: DASHTimestampRange -> String
showsPrec :: Int -> DASHTimestampRange -> ShowS
$cshowsPrec :: Int -> DASHTimestampRange -> ShowS
Prelude.Show, (forall x. DASHTimestampRange -> Rep DASHTimestampRange x)
-> (forall x. Rep DASHTimestampRange x -> DASHTimestampRange)
-> Generic DASHTimestampRange
forall x. Rep DASHTimestampRange x -> DASHTimestampRange
forall x. DASHTimestampRange -> Rep DASHTimestampRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DASHTimestampRange x -> DASHTimestampRange
$cfrom :: forall x. DASHTimestampRange -> Rep DASHTimestampRange x
Prelude.Generic)

-- |
-- Create a value of 'DASHTimestampRange' 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', 'dASHTimestampRange_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', 'dASHTimestampRange_startTimestamp' - The start of the timestamp range for the requested media.
--
-- If the @DASHTimestampRange@ 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.
newDASHTimestampRange ::
  DASHTimestampRange
newDASHTimestampRange :: DASHTimestampRange
newDASHTimestampRange =
  DASHTimestampRange' :: Maybe POSIX -> Maybe POSIX -> DASHTimestampRange
DASHTimestampRange'
    { $sel:endTimestamp:DASHTimestampRange' :: Maybe POSIX
endTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:startTimestamp:DASHTimestampRange' :: 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.
dASHTimestampRange_endTimestamp :: Lens.Lens' DASHTimestampRange (Prelude.Maybe Prelude.UTCTime)
dASHTimestampRange_endTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DASHTimestampRange -> f DASHTimestampRange
dASHTimestampRange_endTimestamp = (DASHTimestampRange -> Maybe POSIX)
-> (DASHTimestampRange -> Maybe POSIX -> DASHTimestampRange)
-> Lens
     DASHTimestampRange DASHTimestampRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DASHTimestampRange' {Maybe POSIX
endTimestamp :: Maybe POSIX
$sel:endTimestamp:DASHTimestampRange' :: DASHTimestampRange -> Maybe POSIX
endTimestamp} -> Maybe POSIX
endTimestamp) (\s :: DASHTimestampRange
s@DASHTimestampRange' {} Maybe POSIX
a -> DASHTimestampRange
s {$sel:endTimestamp:DASHTimestampRange' :: Maybe POSIX
endTimestamp = Maybe POSIX
a} :: DASHTimestampRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> DASHTimestampRange -> f DASHTimestampRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DASHTimestampRange
-> f DASHTimestampRange
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 @DASHTimestampRange@ 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.
dASHTimestampRange_startTimestamp :: Lens.Lens' DASHTimestampRange (Prelude.Maybe Prelude.UTCTime)
dASHTimestampRange_startTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DASHTimestampRange -> f DASHTimestampRange
dASHTimestampRange_startTimestamp = (DASHTimestampRange -> Maybe POSIX)
-> (DASHTimestampRange -> Maybe POSIX -> DASHTimestampRange)
-> Lens
     DASHTimestampRange DASHTimestampRange (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DASHTimestampRange' {Maybe POSIX
startTimestamp :: Maybe POSIX
$sel:startTimestamp:DASHTimestampRange' :: DASHTimestampRange -> Maybe POSIX
startTimestamp} -> Maybe POSIX
startTimestamp) (\s :: DASHTimestampRange
s@DASHTimestampRange' {} Maybe POSIX
a -> DASHTimestampRange
s {$sel:startTimestamp:DASHTimestampRange' :: Maybe POSIX
startTimestamp = Maybe POSIX
a} :: DASHTimestampRange) ((Maybe POSIX -> f (Maybe POSIX))
 -> DASHTimestampRange -> f DASHTimestampRange)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DASHTimestampRange
-> f DASHTimestampRange
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 DASHTimestampRange

instance Prelude.NFData DASHTimestampRange

instance Core.ToJSON DASHTimestampRange where
  toJSON :: DASHTimestampRange -> Value
toJSON DASHTimestampRange' {Maybe POSIX
startTimestamp :: Maybe POSIX
endTimestamp :: Maybe POSIX
$sel:startTimestamp:DASHTimestampRange' :: DASHTimestampRange -> Maybe POSIX
$sel:endTimestamp:DASHTimestampRange' :: DASHTimestampRange -> 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
          ]
      )