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

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

-- | The range of timestamps for which to return fragments.
--
-- /See:/ 'newTimestampRange' smart constructor.
data TimestampRange = TimestampRange'
  { -- | The starting timestamp in the range of timestamps for which to return
    -- fragments.
    TimestampRange -> POSIX
startTimestamp :: Core.POSIX,
    -- | The ending timestamp in the range of timestamps for which to return
    -- fragments.
    TimestampRange -> POSIX
endTimestamp :: Core.POSIX
  }
  deriving (TimestampRange -> TimestampRange -> Bool
(TimestampRange -> TimestampRange -> Bool)
-> (TimestampRange -> TimestampRange -> Bool) -> Eq TimestampRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestampRange -> TimestampRange -> Bool
$c/= :: TimestampRange -> TimestampRange -> Bool
== :: TimestampRange -> TimestampRange -> Bool
$c== :: TimestampRange -> TimestampRange -> Bool
Prelude.Eq, ReadPrec [TimestampRange]
ReadPrec TimestampRange
Int -> ReadS TimestampRange
ReadS [TimestampRange]
(Int -> ReadS TimestampRange)
-> ReadS [TimestampRange]
-> ReadPrec TimestampRange
-> ReadPrec [TimestampRange]
-> Read TimestampRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestampRange]
$creadListPrec :: ReadPrec [TimestampRange]
readPrec :: ReadPrec TimestampRange
$creadPrec :: ReadPrec TimestampRange
readList :: ReadS [TimestampRange]
$creadList :: ReadS [TimestampRange]
readsPrec :: Int -> ReadS TimestampRange
$creadsPrec :: Int -> ReadS TimestampRange
Prelude.Read, Int -> TimestampRange -> ShowS
[TimestampRange] -> ShowS
TimestampRange -> String
(Int -> TimestampRange -> ShowS)
-> (TimestampRange -> String)
-> ([TimestampRange] -> ShowS)
-> Show TimestampRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestampRange] -> ShowS
$cshowList :: [TimestampRange] -> ShowS
show :: TimestampRange -> String
$cshow :: TimestampRange -> String
showsPrec :: Int -> TimestampRange -> ShowS
$cshowsPrec :: Int -> TimestampRange -> ShowS
Prelude.Show, (forall x. TimestampRange -> Rep TimestampRange x)
-> (forall x. Rep TimestampRange x -> TimestampRange)
-> Generic TimestampRange
forall x. Rep TimestampRange x -> TimestampRange
forall x. TimestampRange -> Rep TimestampRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimestampRange x -> TimestampRange
$cfrom :: forall x. TimestampRange -> Rep TimestampRange x
Prelude.Generic)

-- |
-- Create a value of 'TimestampRange' 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:
--
-- 'startTimestamp', 'timestampRange_startTimestamp' - The starting timestamp in the range of timestamps for which to return
-- fragments.
--
-- 'endTimestamp', 'timestampRange_endTimestamp' - The ending timestamp in the range of timestamps for which to return
-- fragments.
newTimestampRange ::
  -- | 'startTimestamp'
  Prelude.UTCTime ->
  -- | 'endTimestamp'
  Prelude.UTCTime ->
  TimestampRange
newTimestampRange :: UTCTime -> UTCTime -> TimestampRange
newTimestampRange UTCTime
pStartTimestamp_ UTCTime
pEndTimestamp_ =
  TimestampRange' :: POSIX -> POSIX -> TimestampRange
TimestampRange'
    { $sel:startTimestamp:TimestampRange' :: POSIX
startTimestamp =
        Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTimestamp_,
      $sel:endTimestamp:TimestampRange' :: POSIX
endTimestamp = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTimestamp_
    }

-- | The starting timestamp in the range of timestamps for which to return
-- fragments.
timestampRange_startTimestamp :: Lens.Lens' TimestampRange Prelude.UTCTime
timestampRange_startTimestamp :: (UTCTime -> f UTCTime) -> TimestampRange -> f TimestampRange
timestampRange_startTimestamp = (TimestampRange -> POSIX)
-> (TimestampRange -> POSIX -> TimestampRange)
-> Lens TimestampRange TimestampRange POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampRange' {POSIX
startTimestamp :: POSIX
$sel:startTimestamp:TimestampRange' :: TimestampRange -> POSIX
startTimestamp} -> POSIX
startTimestamp) (\s :: TimestampRange
s@TimestampRange' {} POSIX
a -> TimestampRange
s {$sel:startTimestamp:TimestampRange' :: POSIX
startTimestamp = POSIX
a} :: TimestampRange) ((POSIX -> f POSIX) -> TimestampRange -> f TimestampRange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> TimestampRange
-> f TimestampRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The ending timestamp in the range of timestamps for which to return
-- fragments.
timestampRange_endTimestamp :: Lens.Lens' TimestampRange Prelude.UTCTime
timestampRange_endTimestamp :: (UTCTime -> f UTCTime) -> TimestampRange -> f TimestampRange
timestampRange_endTimestamp = (TimestampRange -> POSIX)
-> (TimestampRange -> POSIX -> TimestampRange)
-> Lens TimestampRange TimestampRange POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampRange' {POSIX
endTimestamp :: POSIX
$sel:endTimestamp:TimestampRange' :: TimestampRange -> POSIX
endTimestamp} -> POSIX
endTimestamp) (\s :: TimestampRange
s@TimestampRange' {} POSIX
a -> TimestampRange
s {$sel:endTimestamp:TimestampRange' :: POSIX
endTimestamp = POSIX
a} :: TimestampRange) ((POSIX -> f POSIX) -> TimestampRange -> f TimestampRange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> TimestampRange
-> f TimestampRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.Hashable TimestampRange

instance Prelude.NFData TimestampRange

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