{-# 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.Transcribe.Types.AbsoluteTimeRange
-- 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.Transcribe.Types.AbsoluteTimeRange where

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

-- | A time range, set in seconds, between two points in the call.
--
-- /See:/ 'newAbsoluteTimeRange' smart constructor.
data AbsoluteTimeRange = AbsoluteTimeRange'
  { -- | A time range from the beginning of the call to the value that you\'ve
    -- specified. For example, if you specify 100000, the time range is set to
    -- the first 100,000 milliseconds of the call.
    AbsoluteTimeRange -> Maybe Natural
first :: Prelude.Maybe Prelude.Natural,
    -- | A value that indicates the beginning of the time range in seconds. To
    -- set absolute time range, you must specify a start time and an end time.
    -- For example, if you specify the following values:
    --
    -- -   StartTime - 10000
    --
    -- -   Endtime - 50000
    --
    -- The time range is set between 10,000 milliseconds and 50,000
    -- milliseconds into the call.
    AbsoluteTimeRange -> Maybe Natural
startTime :: Prelude.Maybe Prelude.Natural,
    -- | A time range from the value that you\'ve specified to the end of the
    -- call. For example, if you specify 100000, the time range is set to the
    -- last 100,000 milliseconds of the call.
    AbsoluteTimeRange -> Maybe Natural
last :: Prelude.Maybe Prelude.Natural,
    -- | A value that indicates the end of the time range in milliseconds. To set
    -- absolute time range, you must specify a start time and an end time. For
    -- example, if you specify the following values:
    --
    -- -   StartTime - 10000
    --
    -- -   Endtime - 50000
    --
    -- The time range is set between 10,000 milliseconds and 50,000
    -- milliseconds into the call.
    AbsoluteTimeRange -> Maybe Natural
endTime :: Prelude.Maybe Prelude.Natural
  }
  deriving (AbsoluteTimeRange -> AbsoluteTimeRange -> Bool
(AbsoluteTimeRange -> AbsoluteTimeRange -> Bool)
-> (AbsoluteTimeRange -> AbsoluteTimeRange -> Bool)
-> Eq AbsoluteTimeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbsoluteTimeRange -> AbsoluteTimeRange -> Bool
$c/= :: AbsoluteTimeRange -> AbsoluteTimeRange -> Bool
== :: AbsoluteTimeRange -> AbsoluteTimeRange -> Bool
$c== :: AbsoluteTimeRange -> AbsoluteTimeRange -> Bool
Prelude.Eq, ReadPrec [AbsoluteTimeRange]
ReadPrec AbsoluteTimeRange
Int -> ReadS AbsoluteTimeRange
ReadS [AbsoluteTimeRange]
(Int -> ReadS AbsoluteTimeRange)
-> ReadS [AbsoluteTimeRange]
-> ReadPrec AbsoluteTimeRange
-> ReadPrec [AbsoluteTimeRange]
-> Read AbsoluteTimeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AbsoluteTimeRange]
$creadListPrec :: ReadPrec [AbsoluteTimeRange]
readPrec :: ReadPrec AbsoluteTimeRange
$creadPrec :: ReadPrec AbsoluteTimeRange
readList :: ReadS [AbsoluteTimeRange]
$creadList :: ReadS [AbsoluteTimeRange]
readsPrec :: Int -> ReadS AbsoluteTimeRange
$creadsPrec :: Int -> ReadS AbsoluteTimeRange
Prelude.Read, Int -> AbsoluteTimeRange -> ShowS
[AbsoluteTimeRange] -> ShowS
AbsoluteTimeRange -> String
(Int -> AbsoluteTimeRange -> ShowS)
-> (AbsoluteTimeRange -> String)
-> ([AbsoluteTimeRange] -> ShowS)
-> Show AbsoluteTimeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbsoluteTimeRange] -> ShowS
$cshowList :: [AbsoluteTimeRange] -> ShowS
show :: AbsoluteTimeRange -> String
$cshow :: AbsoluteTimeRange -> String
showsPrec :: Int -> AbsoluteTimeRange -> ShowS
$cshowsPrec :: Int -> AbsoluteTimeRange -> ShowS
Prelude.Show, (forall x. AbsoluteTimeRange -> Rep AbsoluteTimeRange x)
-> (forall x. Rep AbsoluteTimeRange x -> AbsoluteTimeRange)
-> Generic AbsoluteTimeRange
forall x. Rep AbsoluteTimeRange x -> AbsoluteTimeRange
forall x. AbsoluteTimeRange -> Rep AbsoluteTimeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AbsoluteTimeRange x -> AbsoluteTimeRange
$cfrom :: forall x. AbsoluteTimeRange -> Rep AbsoluteTimeRange x
Prelude.Generic)

-- |
-- Create a value of 'AbsoluteTimeRange' 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:
--
-- 'first', 'absoluteTimeRange_first' - A time range from the beginning of the call to the value that you\'ve
-- specified. For example, if you specify 100000, the time range is set to
-- the first 100,000 milliseconds of the call.
--
-- 'startTime', 'absoluteTimeRange_startTime' - A value that indicates the beginning of the time range in seconds. To
-- set absolute time range, you must specify a start time and an end time.
-- For example, if you specify the following values:
--
-- -   StartTime - 10000
--
-- -   Endtime - 50000
--
-- The time range is set between 10,000 milliseconds and 50,000
-- milliseconds into the call.
--
-- 'last', 'absoluteTimeRange_last' - A time range from the value that you\'ve specified to the end of the
-- call. For example, if you specify 100000, the time range is set to the
-- last 100,000 milliseconds of the call.
--
-- 'endTime', 'absoluteTimeRange_endTime' - A value that indicates the end of the time range in milliseconds. To set
-- absolute time range, you must specify a start time and an end time. For
-- example, if you specify the following values:
--
-- -   StartTime - 10000
--
-- -   Endtime - 50000
--
-- The time range is set between 10,000 milliseconds and 50,000
-- milliseconds into the call.
newAbsoluteTimeRange ::
  AbsoluteTimeRange
newAbsoluteTimeRange :: AbsoluteTimeRange
newAbsoluteTimeRange =
  AbsoluteTimeRange' :: Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> AbsoluteTimeRange
AbsoluteTimeRange'
    { $sel:first:AbsoluteTimeRange' :: Maybe Natural
first = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:AbsoluteTimeRange' :: Maybe Natural
startTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:last:AbsoluteTimeRange' :: Maybe Natural
last = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:AbsoluteTimeRange' :: Maybe Natural
endTime = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | A time range from the beginning of the call to the value that you\'ve
-- specified. For example, if you specify 100000, the time range is set to
-- the first 100,000 milliseconds of the call.
absoluteTimeRange_first :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_first :: (Maybe Natural -> f (Maybe Natural))
-> AbsoluteTimeRange -> f AbsoluteTimeRange
absoluteTimeRange_first = (AbsoluteTimeRange -> Maybe Natural)
-> (AbsoluteTimeRange -> Maybe Natural -> AbsoluteTimeRange)
-> Lens
     AbsoluteTimeRange AbsoluteTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbsoluteTimeRange' {Maybe Natural
first :: Maybe Natural
$sel:first:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
first} -> Maybe Natural
first) (\s :: AbsoluteTimeRange
s@AbsoluteTimeRange' {} Maybe Natural
a -> AbsoluteTimeRange
s {$sel:first:AbsoluteTimeRange' :: Maybe Natural
first = Maybe Natural
a} :: AbsoluteTimeRange)

-- | A value that indicates the beginning of the time range in seconds. To
-- set absolute time range, you must specify a start time and an end time.
-- For example, if you specify the following values:
--
-- -   StartTime - 10000
--
-- -   Endtime - 50000
--
-- The time range is set between 10,000 milliseconds and 50,000
-- milliseconds into the call.
absoluteTimeRange_startTime :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_startTime :: (Maybe Natural -> f (Maybe Natural))
-> AbsoluteTimeRange -> f AbsoluteTimeRange
absoluteTimeRange_startTime = (AbsoluteTimeRange -> Maybe Natural)
-> (AbsoluteTimeRange -> Maybe Natural -> AbsoluteTimeRange)
-> Lens
     AbsoluteTimeRange AbsoluteTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbsoluteTimeRange' {Maybe Natural
startTime :: Maybe Natural
$sel:startTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
startTime} -> Maybe Natural
startTime) (\s :: AbsoluteTimeRange
s@AbsoluteTimeRange' {} Maybe Natural
a -> AbsoluteTimeRange
s {$sel:startTime:AbsoluteTimeRange' :: Maybe Natural
startTime = Maybe Natural
a} :: AbsoluteTimeRange)

-- | A time range from the value that you\'ve specified to the end of the
-- call. For example, if you specify 100000, the time range is set to the
-- last 100,000 milliseconds of the call.
absoluteTimeRange_last :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_last :: (Maybe Natural -> f (Maybe Natural))
-> AbsoluteTimeRange -> f AbsoluteTimeRange
absoluteTimeRange_last = (AbsoluteTimeRange -> Maybe Natural)
-> (AbsoluteTimeRange -> Maybe Natural -> AbsoluteTimeRange)
-> Lens
     AbsoluteTimeRange AbsoluteTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbsoluteTimeRange' {Maybe Natural
last :: Maybe Natural
$sel:last:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
last} -> Maybe Natural
last) (\s :: AbsoluteTimeRange
s@AbsoluteTimeRange' {} Maybe Natural
a -> AbsoluteTimeRange
s {$sel:last:AbsoluteTimeRange' :: Maybe Natural
last = Maybe Natural
a} :: AbsoluteTimeRange)

-- | A value that indicates the end of the time range in milliseconds. To set
-- absolute time range, you must specify a start time and an end time. For
-- example, if you specify the following values:
--
-- -   StartTime - 10000
--
-- -   Endtime - 50000
--
-- The time range is set between 10,000 milliseconds and 50,000
-- milliseconds into the call.
absoluteTimeRange_endTime :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_endTime :: (Maybe Natural -> f (Maybe Natural))
-> AbsoluteTimeRange -> f AbsoluteTimeRange
absoluteTimeRange_endTime = (AbsoluteTimeRange -> Maybe Natural)
-> (AbsoluteTimeRange -> Maybe Natural -> AbsoluteTimeRange)
-> Lens
     AbsoluteTimeRange AbsoluteTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbsoluteTimeRange' {Maybe Natural
endTime :: Maybe Natural
$sel:endTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
endTime} -> Maybe Natural
endTime) (\s :: AbsoluteTimeRange
s@AbsoluteTimeRange' {} Maybe Natural
a -> AbsoluteTimeRange
s {$sel:endTime:AbsoluteTimeRange' :: Maybe Natural
endTime = Maybe Natural
a} :: AbsoluteTimeRange)

instance Core.FromJSON AbsoluteTimeRange where
  parseJSON :: Value -> Parser AbsoluteTimeRange
parseJSON =
    String
-> (Object -> Parser AbsoluteTimeRange)
-> Value
-> Parser AbsoluteTimeRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AbsoluteTimeRange"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> AbsoluteTimeRange
AbsoluteTimeRange'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> AbsoluteTimeRange)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural -> Maybe Natural -> AbsoluteTimeRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"First")
            Parser
  (Maybe Natural
   -> Maybe Natural -> Maybe Natural -> AbsoluteTimeRange)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> AbsoluteTimeRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartTime")
            Parser (Maybe Natural -> Maybe Natural -> AbsoluteTimeRange)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> AbsoluteTimeRange)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Last")
            Parser (Maybe Natural -> AbsoluteTimeRange)
-> Parser (Maybe Natural) -> Parser AbsoluteTimeRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndTime")
      )

instance Prelude.Hashable AbsoluteTimeRange

instance Prelude.NFData AbsoluteTimeRange

instance Core.ToJSON AbsoluteTimeRange where
  toJSON :: AbsoluteTimeRange -> Value
toJSON AbsoluteTimeRange' {Maybe Natural
endTime :: Maybe Natural
last :: Maybe Natural
startTime :: Maybe Natural
first :: Maybe Natural
$sel:endTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:last:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:startTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:first:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"First" 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
first,
            (Text
"StartTime" 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
startTime,
            (Text
"Last" 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
last,
            (Text
"EndTime" 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
endTime
          ]
      )