{-# 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.ElasticTranscoder.Types.TimeSpan
-- 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.ElasticTranscoder.Types.TimeSpan 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

-- | Settings that determine when a clip begins and how long it lasts.
--
-- /See:/ 'newTimeSpan' smart constructor.
data TimeSpan = TimeSpan'
  { -- | The duration of the clip. The format can be either HH:mm:ss.SSS (maximum
    -- value: 23:59:59.999; SSS is thousandths of a second) or sssss.SSS
    -- (maximum value: 86399.999). If you don\'t specify a value, Elastic
    -- Transcoder creates an output file from StartTime to the end of the file.
    --
    -- If you specify a value longer than the duration of the input file,
    -- Elastic Transcoder transcodes the file and returns a warning message.
    TimeSpan -> Maybe Text
duration :: Prelude.Maybe Prelude.Text,
    -- | The place in the input file where you want a clip to start. The format
    -- can be either HH:mm:ss.SSS (maximum value: 23:59:59.999; SSS is
    -- thousandths of a second) or sssss.SSS (maximum value: 86399.999). If you
    -- don\'t specify a value, Elastic Transcoder starts at the beginning of
    -- the input file.
    TimeSpan -> Maybe Text
startTime :: Prelude.Maybe Prelude.Text
  }
  deriving (TimeSpan -> TimeSpan -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeSpan -> TimeSpan -> Bool
$c/= :: TimeSpan -> TimeSpan -> Bool
== :: TimeSpan -> TimeSpan -> Bool
$c== :: TimeSpan -> TimeSpan -> Bool
Prelude.Eq, ReadPrec [TimeSpan]
ReadPrec TimeSpan
Int -> ReadS TimeSpan
ReadS [TimeSpan]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeSpan]
$creadListPrec :: ReadPrec [TimeSpan]
readPrec :: ReadPrec TimeSpan
$creadPrec :: ReadPrec TimeSpan
readList :: ReadS [TimeSpan]
$creadList :: ReadS [TimeSpan]
readsPrec :: Int -> ReadS TimeSpan
$creadsPrec :: Int -> ReadS TimeSpan
Prelude.Read, Int -> TimeSpan -> ShowS
[TimeSpan] -> ShowS
TimeSpan -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeSpan] -> ShowS
$cshowList :: [TimeSpan] -> ShowS
show :: TimeSpan -> String
$cshow :: TimeSpan -> String
showsPrec :: Int -> TimeSpan -> ShowS
$cshowsPrec :: Int -> TimeSpan -> ShowS
Prelude.Show, forall x. Rep TimeSpan x -> TimeSpan
forall x. TimeSpan -> Rep TimeSpan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeSpan x -> TimeSpan
$cfrom :: forall x. TimeSpan -> Rep TimeSpan x
Prelude.Generic)

-- |
-- Create a value of 'TimeSpan' 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:
--
-- 'duration', 'timeSpan_duration' - The duration of the clip. The format can be either HH:mm:ss.SSS (maximum
-- value: 23:59:59.999; SSS is thousandths of a second) or sssss.SSS
-- (maximum value: 86399.999). If you don\'t specify a value, Elastic
-- Transcoder creates an output file from StartTime to the end of the file.
--
-- If you specify a value longer than the duration of the input file,
-- Elastic Transcoder transcodes the file and returns a warning message.
--
-- 'startTime', 'timeSpan_startTime' - The place in the input file where you want a clip to start. The format
-- can be either HH:mm:ss.SSS (maximum value: 23:59:59.999; SSS is
-- thousandths of a second) or sssss.SSS (maximum value: 86399.999). If you
-- don\'t specify a value, Elastic Transcoder starts at the beginning of
-- the input file.
newTimeSpan ::
  TimeSpan
newTimeSpan :: TimeSpan
newTimeSpan =
  TimeSpan'
    { $sel:duration:TimeSpan' :: Maybe Text
duration = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:TimeSpan' :: Maybe Text
startTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The duration of the clip. The format can be either HH:mm:ss.SSS (maximum
-- value: 23:59:59.999; SSS is thousandths of a second) or sssss.SSS
-- (maximum value: 86399.999). If you don\'t specify a value, Elastic
-- Transcoder creates an output file from StartTime to the end of the file.
--
-- If you specify a value longer than the duration of the input file,
-- Elastic Transcoder transcodes the file and returns a warning message.
timeSpan_duration :: Lens.Lens' TimeSpan (Prelude.Maybe Prelude.Text)
timeSpan_duration :: Lens' TimeSpan (Maybe Text)
timeSpan_duration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeSpan' {Maybe Text
duration :: Maybe Text
$sel:duration:TimeSpan' :: TimeSpan -> Maybe Text
duration} -> Maybe Text
duration) (\s :: TimeSpan
s@TimeSpan' {} Maybe Text
a -> TimeSpan
s {$sel:duration:TimeSpan' :: Maybe Text
duration = Maybe Text
a} :: TimeSpan)

-- | The place in the input file where you want a clip to start. The format
-- can be either HH:mm:ss.SSS (maximum value: 23:59:59.999; SSS is
-- thousandths of a second) or sssss.SSS (maximum value: 86399.999). If you
-- don\'t specify a value, Elastic Transcoder starts at the beginning of
-- the input file.
timeSpan_startTime :: Lens.Lens' TimeSpan (Prelude.Maybe Prelude.Text)
timeSpan_startTime :: Lens' TimeSpan (Maybe Text)
timeSpan_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeSpan' {Maybe Text
startTime :: Maybe Text
$sel:startTime:TimeSpan' :: TimeSpan -> Maybe Text
startTime} -> Maybe Text
startTime) (\s :: TimeSpan
s@TimeSpan' {} Maybe Text
a -> TimeSpan
s {$sel:startTime:TimeSpan' :: Maybe Text
startTime = Maybe Text
a} :: TimeSpan)

instance Data.FromJSON TimeSpan where
  parseJSON :: Value -> Parser TimeSpan
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimeSpan"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> TimeSpan
TimeSpan'
            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
"Duration")
            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 TimeSpan where
  hashWithSalt :: Int -> TimeSpan -> Int
hashWithSalt Int
_salt TimeSpan' {Maybe Text
startTime :: Maybe Text
duration :: Maybe Text
$sel:startTime:TimeSpan' :: TimeSpan -> Maybe Text
$sel:duration:TimeSpan' :: TimeSpan -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
duration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
startTime

instance Prelude.NFData TimeSpan where
  rnf :: TimeSpan -> ()
rnf TimeSpan' {Maybe Text
startTime :: Maybe Text
duration :: Maybe Text
$sel:startTime:TimeSpan' :: TimeSpan -> Maybe Text
$sel:duration:TimeSpan' :: TimeSpan -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
duration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
startTime

instance Data.ToJSON TimeSpan where
  toJSON :: TimeSpan -> Value
toJSON TimeSpan' {Maybe Text
startTime :: Maybe Text
duration :: Maybe Text
$sel:startTime:TimeSpan' :: TimeSpan -> Maybe Text
$sel:duration:TimeSpan' :: TimeSpan -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Duration" 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 Text
duration,
            (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 Text
startTime
          ]
      )