{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Transcribe.Types.AbsoluteTimeRange where

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

-- | A time range, in milliseconds, between two points in your media file.
--
-- You can use @StartTime@ and @EndTime@ to search a custom segment. For
-- example, setting @StartTime@ to 10000 and @EndTime@ to 50000 only
-- searches for your specified criteria in the audio contained between the
-- 10,000 millisecond mark and the 50,000 millisecond mark of your media
-- file. You must use @StartTime@ and @EndTime@ as a set; that is, if you
-- include one, you must include both.
--
-- You can use also @First@ to search from the start of the audio until the
-- time that you specify, or @Last@ to search from the time that you
-- specify until the end of the audio. For example, setting @First@ to
-- 50000 only searches for your specified criteria in the audio contained
-- between the start of the media file to the 50,000 millisecond mark. You
-- can use @First@ and @Last@ independently of each other.
--
-- If you prefer to use percentage instead of milliseconds, see .
--
-- /See:/ 'newAbsoluteTimeRange' smart constructor.
data AbsoluteTimeRange = AbsoluteTimeRange'
  { -- | The time, in milliseconds, when Amazon Transcribe stops searching for
    -- the specified criteria in your audio. If you include @EndTime@ in your
    -- request, you must also include @StartTime@.
    AbsoluteTimeRange -> Maybe Natural
endTime :: Prelude.Maybe Prelude.Natural,
    -- | The time, in milliseconds, from the start of your media file until the
    -- specified value. Amazon Transcribe searches for your specified criteria
    -- in this time segment.
    AbsoluteTimeRange -> Maybe Natural
first :: Prelude.Maybe Prelude.Natural,
    -- | The time, in milliseconds, from the specified value until the end of
    -- your media file. Amazon Transcribe searches for your specified criteria
    -- in this time segment.
    AbsoluteTimeRange -> Maybe Natural
last :: Prelude.Maybe Prelude.Natural,
    -- | The time, in milliseconds, when Amazon Transcribe starts searching for
    -- the specified criteria in your audio. If you include @StartTime@ in your
    -- request, you must also include @EndTime@.
    AbsoluteTimeRange -> Maybe Natural
startTime :: Prelude.Maybe Prelude.Natural
  }
  deriving (AbsoluteTimeRange -> AbsoluteTimeRange -> Bool
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]
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
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. 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:
--
-- 'endTime', 'absoluteTimeRange_endTime' - The time, in milliseconds, when Amazon Transcribe stops searching for
-- the specified criteria in your audio. If you include @EndTime@ in your
-- request, you must also include @StartTime@.
--
-- 'first', 'absoluteTimeRange_first' - The time, in milliseconds, from the start of your media file until the
-- specified value. Amazon Transcribe searches for your specified criteria
-- in this time segment.
--
-- 'last', 'absoluteTimeRange_last' - The time, in milliseconds, from the specified value until the end of
-- your media file. Amazon Transcribe searches for your specified criteria
-- in this time segment.
--
-- 'startTime', 'absoluteTimeRange_startTime' - The time, in milliseconds, when Amazon Transcribe starts searching for
-- the specified criteria in your audio. If you include @StartTime@ in your
-- request, you must also include @EndTime@.
newAbsoluteTimeRange ::
  AbsoluteTimeRange
newAbsoluteTimeRange :: AbsoluteTimeRange
newAbsoluteTimeRange =
  AbsoluteTimeRange'
    { $sel:endTime:AbsoluteTimeRange' :: Maybe Natural
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:first:AbsoluteTimeRange' :: Maybe Natural
first = forall a. Maybe a
Prelude.Nothing,
      $sel:last:AbsoluteTimeRange' :: Maybe Natural
last = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:AbsoluteTimeRange' :: Maybe Natural
startTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The time, in milliseconds, when Amazon Transcribe stops searching for
-- the specified criteria in your audio. If you include @EndTime@ in your
-- request, you must also include @StartTime@.
absoluteTimeRange_endTime :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_endTime :: Lens' AbsoluteTimeRange (Maybe Natural)
absoluteTimeRange_endTime = 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)

-- | The time, in milliseconds, from the start of your media file until the
-- specified value. Amazon Transcribe searches for your specified criteria
-- in this time segment.
absoluteTimeRange_first :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_first :: Lens' AbsoluteTimeRange (Maybe Natural)
absoluteTimeRange_first = 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)

-- | The time, in milliseconds, from the specified value until the end of
-- your media file. Amazon Transcribe searches for your specified criteria
-- in this time segment.
absoluteTimeRange_last :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_last :: Lens' AbsoluteTimeRange (Maybe Natural)
absoluteTimeRange_last = 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)

-- | The time, in milliseconds, when Amazon Transcribe starts searching for
-- the specified criteria in your audio. If you include @StartTime@ in your
-- request, you must also include @EndTime@.
absoluteTimeRange_startTime :: Lens.Lens' AbsoluteTimeRange (Prelude.Maybe Prelude.Natural)
absoluteTimeRange_startTime :: Lens' AbsoluteTimeRange (Maybe Natural)
absoluteTimeRange_startTime = 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)

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

instance Prelude.Hashable AbsoluteTimeRange where
  hashWithSalt :: Int -> AbsoluteTimeRange -> Int
hashWithSalt Int
_salt AbsoluteTimeRange' {Maybe Natural
startTime :: Maybe Natural
last :: Maybe Natural
first :: Maybe Natural
endTime :: Maybe Natural
$sel:startTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:last:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:first:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:endTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
first
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
last
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
startTime

instance Prelude.NFData AbsoluteTimeRange where
  rnf :: AbsoluteTimeRange -> ()
rnf AbsoluteTimeRange' {Maybe Natural
startTime :: Maybe Natural
last :: Maybe Natural
first :: Maybe Natural
endTime :: Maybe Natural
$sel:startTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:last:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:first:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
$sel:endTime:AbsoluteTimeRange' :: AbsoluteTimeRange -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
first
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
last
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
startTime

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