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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 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,
    -- | 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
  }
  deriving (TimeSpan -> TimeSpan -> Bool
(TimeSpan -> TimeSpan -> Bool)
-> (TimeSpan -> TimeSpan -> Bool) -> Eq TimeSpan
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]
(Int -> ReadS TimeSpan)
-> ReadS [TimeSpan]
-> ReadPrec TimeSpan
-> ReadPrec [TimeSpan]
-> Read 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
(Int -> TimeSpan -> ShowS)
-> (TimeSpan -> String) -> ([TimeSpan] -> ShowS) -> Show TimeSpan
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. TimeSpan -> Rep TimeSpan x)
-> (forall x. Rep TimeSpan x -> TimeSpan) -> Generic TimeSpan
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:
--
-- '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.
--
-- '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.
newTimeSpan ::
  TimeSpan
newTimeSpan :: TimeSpan
newTimeSpan =
  TimeSpan' :: Maybe Text -> Maybe Text -> TimeSpan
TimeSpan'
    { $sel:startTime:TimeSpan' :: Maybe Text
startTime = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:duration:TimeSpan' :: Maybe Text
duration = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> TimeSpan -> f TimeSpan
timeSpan_startTime = (TimeSpan -> Maybe Text)
-> (TimeSpan -> Maybe Text -> TimeSpan)
-> Lens TimeSpan TimeSpan (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> TimeSpan -> f TimeSpan
timeSpan_duration = (TimeSpan -> Maybe Text)
-> (TimeSpan -> Maybe Text -> TimeSpan)
-> Lens TimeSpan TimeSpan (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable TimeSpan

instance Prelude.NFData TimeSpan

instance Core.ToJSON TimeSpan where
  toJSON :: TimeSpan -> Value
toJSON TimeSpan' {Maybe Text
duration :: Maybe Text
startTime :: Maybe Text
$sel:duration:TimeSpan' :: TimeSpan -> Maybe Text
$sel:startTime:TimeSpan' :: TimeSpan -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StartTime" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
startTime,
            (Text
"Duration" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
duration
          ]
      )