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

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

-- | An object that allows percentages to specify the proportion of the call
-- where you would like to apply a filter. For example, you can specify the
-- first half of the call. You can also specify the period of time between
-- halfway through to three-quarters of the way through the call. Because
-- the length of conversation can vary between calls, you can apply
-- relative time ranges across all calls.
--
-- /See:/ 'newRelativeTimeRange' smart constructor.
data RelativeTimeRange = RelativeTimeRange'
  { -- | A value that indicates the percentage of the end of the time range. To
    -- set a relative time range, you must specify a start percentage and an
    -- end percentage. For example, if you specify the following values:
    --
    -- -   StartPercentage - 10
    --
    -- -   EndPercentage - 50
    --
    -- This looks at the time range starting from 10% of the way into the call
    -- to 50% of the way through the call. For a call that lasts 100,000
    -- milliseconds, this example range would apply from the 10,000 millisecond
    -- mark to the 50,000 millisecond mark.
    RelativeTimeRange -> Maybe Natural
endPercentage :: Prelude.Maybe Prelude.Natural,
    -- | A range that takes the portion of the call up to the time in
    -- milliseconds set by the value that you\'ve specified. For example, if
    -- you specify @120000@, the time range is set for the first 120,000
    -- milliseconds of the call.
    RelativeTimeRange -> Maybe Natural
first :: Prelude.Maybe Prelude.Natural,
    -- | A range that takes the portion of the call from the time in milliseconds
    -- set by the value that you\'ve specified to the end of the call. For
    -- example, if you specify @120000@, the time range is set for the last
    -- 120,000 milliseconds of the call.
    RelativeTimeRange -> Maybe Natural
last :: Prelude.Maybe Prelude.Natural,
    -- | A value that indicates the percentage of the beginning of the time
    -- range. To set a relative time range, you must specify a start percentage
    -- and an end percentage. For example, if you specify the following values:
    --
    -- -   StartPercentage - 10
    --
    -- -   EndPercentage - 50
    --
    -- This looks at the time range starting from 10% of the way into the call
    -- to 50% of the way through the call. For a call that lasts 100,000
    -- milliseconds, this example range would apply from the 10,000 millisecond
    -- mark to the 50,000 millisecond mark.
    RelativeTimeRange -> Maybe Natural
startPercentage :: Prelude.Maybe Prelude.Natural
  }
  deriving (RelativeTimeRange -> RelativeTimeRange -> Bool
(RelativeTimeRange -> RelativeTimeRange -> Bool)
-> (RelativeTimeRange -> RelativeTimeRange -> Bool)
-> Eq RelativeTimeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelativeTimeRange -> RelativeTimeRange -> Bool
$c/= :: RelativeTimeRange -> RelativeTimeRange -> Bool
== :: RelativeTimeRange -> RelativeTimeRange -> Bool
$c== :: RelativeTimeRange -> RelativeTimeRange -> Bool
Prelude.Eq, ReadPrec [RelativeTimeRange]
ReadPrec RelativeTimeRange
Int -> ReadS RelativeTimeRange
ReadS [RelativeTimeRange]
(Int -> ReadS RelativeTimeRange)
-> ReadS [RelativeTimeRange]
-> ReadPrec RelativeTimeRange
-> ReadPrec [RelativeTimeRange]
-> Read RelativeTimeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelativeTimeRange]
$creadListPrec :: ReadPrec [RelativeTimeRange]
readPrec :: ReadPrec RelativeTimeRange
$creadPrec :: ReadPrec RelativeTimeRange
readList :: ReadS [RelativeTimeRange]
$creadList :: ReadS [RelativeTimeRange]
readsPrec :: Int -> ReadS RelativeTimeRange
$creadsPrec :: Int -> ReadS RelativeTimeRange
Prelude.Read, Int -> RelativeTimeRange -> ShowS
[RelativeTimeRange] -> ShowS
RelativeTimeRange -> String
(Int -> RelativeTimeRange -> ShowS)
-> (RelativeTimeRange -> String)
-> ([RelativeTimeRange] -> ShowS)
-> Show RelativeTimeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelativeTimeRange] -> ShowS
$cshowList :: [RelativeTimeRange] -> ShowS
show :: RelativeTimeRange -> String
$cshow :: RelativeTimeRange -> String
showsPrec :: Int -> RelativeTimeRange -> ShowS
$cshowsPrec :: Int -> RelativeTimeRange -> ShowS
Prelude.Show, (forall x. RelativeTimeRange -> Rep RelativeTimeRange x)
-> (forall x. Rep RelativeTimeRange x -> RelativeTimeRange)
-> Generic RelativeTimeRange
forall x. Rep RelativeTimeRange x -> RelativeTimeRange
forall x. RelativeTimeRange -> Rep RelativeTimeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelativeTimeRange x -> RelativeTimeRange
$cfrom :: forall x. RelativeTimeRange -> Rep RelativeTimeRange x
Prelude.Generic)

-- |
-- Create a value of 'RelativeTimeRange' 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:
--
-- 'endPercentage', 'relativeTimeRange_endPercentage' - A value that indicates the percentage of the end of the time range. To
-- set a relative time range, you must specify a start percentage and an
-- end percentage. For example, if you specify the following values:
--
-- -   StartPercentage - 10
--
-- -   EndPercentage - 50
--
-- This looks at the time range starting from 10% of the way into the call
-- to 50% of the way through the call. For a call that lasts 100,000
-- milliseconds, this example range would apply from the 10,000 millisecond
-- mark to the 50,000 millisecond mark.
--
-- 'first', 'relativeTimeRange_first' - A range that takes the portion of the call up to the time in
-- milliseconds set by the value that you\'ve specified. For example, if
-- you specify @120000@, the time range is set for the first 120,000
-- milliseconds of the call.
--
-- 'last', 'relativeTimeRange_last' - A range that takes the portion of the call from the time in milliseconds
-- set by the value that you\'ve specified to the end of the call. For
-- example, if you specify @120000@, the time range is set for the last
-- 120,000 milliseconds of the call.
--
-- 'startPercentage', 'relativeTimeRange_startPercentage' - A value that indicates the percentage of the beginning of the time
-- range. To set a relative time range, you must specify a start percentage
-- and an end percentage. For example, if you specify the following values:
--
-- -   StartPercentage - 10
--
-- -   EndPercentage - 50
--
-- This looks at the time range starting from 10% of the way into the call
-- to 50% of the way through the call. For a call that lasts 100,000
-- milliseconds, this example range would apply from the 10,000 millisecond
-- mark to the 50,000 millisecond mark.
newRelativeTimeRange ::
  RelativeTimeRange
newRelativeTimeRange :: RelativeTimeRange
newRelativeTimeRange =
  RelativeTimeRange' :: Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> RelativeTimeRange
RelativeTimeRange'
    { $sel:endPercentage:RelativeTimeRange' :: Maybe Natural
endPercentage = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:first:RelativeTimeRange' :: Maybe Natural
first = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:last:RelativeTimeRange' :: Maybe Natural
last = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:startPercentage:RelativeTimeRange' :: Maybe Natural
startPercentage = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | A value that indicates the percentage of the end of the time range. To
-- set a relative time range, you must specify a start percentage and an
-- end percentage. For example, if you specify the following values:
--
-- -   StartPercentage - 10
--
-- -   EndPercentage - 50
--
-- This looks at the time range starting from 10% of the way into the call
-- to 50% of the way through the call. For a call that lasts 100,000
-- milliseconds, this example range would apply from the 10,000 millisecond
-- mark to the 50,000 millisecond mark.
relativeTimeRange_endPercentage :: Lens.Lens' RelativeTimeRange (Prelude.Maybe Prelude.Natural)
relativeTimeRange_endPercentage :: (Maybe Natural -> f (Maybe Natural))
-> RelativeTimeRange -> f RelativeTimeRange
relativeTimeRange_endPercentage = (RelativeTimeRange -> Maybe Natural)
-> (RelativeTimeRange -> Maybe Natural -> RelativeTimeRange)
-> Lens
     RelativeTimeRange RelativeTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelativeTimeRange' {Maybe Natural
endPercentage :: Maybe Natural
$sel:endPercentage:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
endPercentage} -> Maybe Natural
endPercentage) (\s :: RelativeTimeRange
s@RelativeTimeRange' {} Maybe Natural
a -> RelativeTimeRange
s {$sel:endPercentage:RelativeTimeRange' :: Maybe Natural
endPercentage = Maybe Natural
a} :: RelativeTimeRange)

-- | A range that takes the portion of the call up to the time in
-- milliseconds set by the value that you\'ve specified. For example, if
-- you specify @120000@, the time range is set for the first 120,000
-- milliseconds of the call.
relativeTimeRange_first :: Lens.Lens' RelativeTimeRange (Prelude.Maybe Prelude.Natural)
relativeTimeRange_first :: (Maybe Natural -> f (Maybe Natural))
-> RelativeTimeRange -> f RelativeTimeRange
relativeTimeRange_first = (RelativeTimeRange -> Maybe Natural)
-> (RelativeTimeRange -> Maybe Natural -> RelativeTimeRange)
-> Lens
     RelativeTimeRange RelativeTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelativeTimeRange' {Maybe Natural
first :: Maybe Natural
$sel:first:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
first} -> Maybe Natural
first) (\s :: RelativeTimeRange
s@RelativeTimeRange' {} Maybe Natural
a -> RelativeTimeRange
s {$sel:first:RelativeTimeRange' :: Maybe Natural
first = Maybe Natural
a} :: RelativeTimeRange)

-- | A range that takes the portion of the call from the time in milliseconds
-- set by the value that you\'ve specified to the end of the call. For
-- example, if you specify @120000@, the time range is set for the last
-- 120,000 milliseconds of the call.
relativeTimeRange_last :: Lens.Lens' RelativeTimeRange (Prelude.Maybe Prelude.Natural)
relativeTimeRange_last :: (Maybe Natural -> f (Maybe Natural))
-> RelativeTimeRange -> f RelativeTimeRange
relativeTimeRange_last = (RelativeTimeRange -> Maybe Natural)
-> (RelativeTimeRange -> Maybe Natural -> RelativeTimeRange)
-> Lens
     RelativeTimeRange RelativeTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelativeTimeRange' {Maybe Natural
last :: Maybe Natural
$sel:last:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
last} -> Maybe Natural
last) (\s :: RelativeTimeRange
s@RelativeTimeRange' {} Maybe Natural
a -> RelativeTimeRange
s {$sel:last:RelativeTimeRange' :: Maybe Natural
last = Maybe Natural
a} :: RelativeTimeRange)

-- | A value that indicates the percentage of the beginning of the time
-- range. To set a relative time range, you must specify a start percentage
-- and an end percentage. For example, if you specify the following values:
--
-- -   StartPercentage - 10
--
-- -   EndPercentage - 50
--
-- This looks at the time range starting from 10% of the way into the call
-- to 50% of the way through the call. For a call that lasts 100,000
-- milliseconds, this example range would apply from the 10,000 millisecond
-- mark to the 50,000 millisecond mark.
relativeTimeRange_startPercentage :: Lens.Lens' RelativeTimeRange (Prelude.Maybe Prelude.Natural)
relativeTimeRange_startPercentage :: (Maybe Natural -> f (Maybe Natural))
-> RelativeTimeRange -> f RelativeTimeRange
relativeTimeRange_startPercentage = (RelativeTimeRange -> Maybe Natural)
-> (RelativeTimeRange -> Maybe Natural -> RelativeTimeRange)
-> Lens
     RelativeTimeRange RelativeTimeRange (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelativeTimeRange' {Maybe Natural
startPercentage :: Maybe Natural
$sel:startPercentage:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
startPercentage} -> Maybe Natural
startPercentage) (\s :: RelativeTimeRange
s@RelativeTimeRange' {} Maybe Natural
a -> RelativeTimeRange
s {$sel:startPercentage:RelativeTimeRange' :: Maybe Natural
startPercentage = Maybe Natural
a} :: RelativeTimeRange)

instance Core.FromJSON RelativeTimeRange where
  parseJSON :: Value -> Parser RelativeTimeRange
parseJSON =
    String
-> (Object -> Parser RelativeTimeRange)
-> Value
-> Parser RelativeTimeRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RelativeTimeRange"
      ( \Object
x ->
          Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> RelativeTimeRange
RelativeTimeRange'
            (Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> RelativeTimeRange)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural -> Maybe Natural -> RelativeTimeRange)
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
"EndPercentage")
            Parser
  (Maybe Natural
   -> Maybe Natural -> Maybe Natural -> RelativeTimeRange)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> Maybe Natural -> RelativeTimeRange)
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
"First")
            Parser (Maybe Natural -> Maybe Natural -> RelativeTimeRange)
-> Parser (Maybe Natural)
-> Parser (Maybe Natural -> RelativeTimeRange)
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 -> RelativeTimeRange)
-> Parser (Maybe Natural) -> Parser RelativeTimeRange
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
"StartPercentage")
      )

instance Prelude.Hashable RelativeTimeRange

instance Prelude.NFData RelativeTimeRange

instance Core.ToJSON RelativeTimeRange where
  toJSON :: RelativeTimeRange -> Value
toJSON RelativeTimeRange' {Maybe Natural
startPercentage :: Maybe Natural
last :: Maybe Natural
first :: Maybe Natural
endPercentage :: Maybe Natural
$sel:startPercentage:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
$sel:last:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
$sel:first:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
$sel:endPercentage:RelativeTimeRange' :: RelativeTimeRange -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EndPercentage" 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
endPercentage,
            (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
"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
"StartPercentage" 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
startPercentage
          ]
      )