{-# 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.MediaConvert.Types.Timing
-- 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.MediaConvert.Types.Timing 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

-- | Information about when jobs are submitted, started, and finished is
-- specified in Unix epoch format in seconds.
--
-- /See:/ 'newTiming' smart constructor.
data Timing = Timing'
  { -- | The time, in Unix epoch format, that the transcoding job finished
    Timing -> Maybe POSIX
finishTime :: Prelude.Maybe Data.POSIX,
    -- | The time, in Unix epoch format, that transcoding for the job began.
    Timing -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX,
    -- | The time, in Unix epoch format, that you submitted the job.
    Timing -> Maybe POSIX
submitTime :: Prelude.Maybe Data.POSIX
  }
  deriving (Timing -> Timing -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Timing -> Timing -> Bool
$c/= :: Timing -> Timing -> Bool
== :: Timing -> Timing -> Bool
$c== :: Timing -> Timing -> Bool
Prelude.Eq, ReadPrec [Timing]
ReadPrec Timing
Int -> ReadS Timing
ReadS [Timing]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Timing]
$creadListPrec :: ReadPrec [Timing]
readPrec :: ReadPrec Timing
$creadPrec :: ReadPrec Timing
readList :: ReadS [Timing]
$creadList :: ReadS [Timing]
readsPrec :: Int -> ReadS Timing
$creadsPrec :: Int -> ReadS Timing
Prelude.Read, Int -> Timing -> ShowS
[Timing] -> ShowS
Timing -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Timing] -> ShowS
$cshowList :: [Timing] -> ShowS
show :: Timing -> String
$cshow :: Timing -> String
showsPrec :: Int -> Timing -> ShowS
$cshowsPrec :: Int -> Timing -> ShowS
Prelude.Show, forall x. Rep Timing x -> Timing
forall x. Timing -> Rep Timing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Timing x -> Timing
$cfrom :: forall x. Timing -> Rep Timing x
Prelude.Generic)

-- |
-- Create a value of 'Timing' 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:
--
-- 'finishTime', 'timing_finishTime' - The time, in Unix epoch format, that the transcoding job finished
--
-- 'startTime', 'timing_startTime' - The time, in Unix epoch format, that transcoding for the job began.
--
-- 'submitTime', 'timing_submitTime' - The time, in Unix epoch format, that you submitted the job.
newTiming ::
  Timing
newTiming :: Timing
newTiming =
  Timing'
    { $sel:finishTime:Timing' :: Maybe POSIX
finishTime = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:Timing' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:submitTime:Timing' :: Maybe POSIX
submitTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The time, in Unix epoch format, that the transcoding job finished
timing_finishTime :: Lens.Lens' Timing (Prelude.Maybe Prelude.UTCTime)
timing_finishTime :: Lens' Timing (Maybe UTCTime)
timing_finishTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Timing' {Maybe POSIX
finishTime :: Maybe POSIX
$sel:finishTime:Timing' :: Timing -> Maybe POSIX
finishTime} -> Maybe POSIX
finishTime) (\s :: Timing
s@Timing' {} Maybe POSIX
a -> Timing
s {$sel:finishTime:Timing' :: Maybe POSIX
finishTime = Maybe POSIX
a} :: Timing) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time, in Unix epoch format, that transcoding for the job began.
timing_startTime :: Lens.Lens' Timing (Prelude.Maybe Prelude.UTCTime)
timing_startTime :: Lens' Timing (Maybe UTCTime)
timing_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Timing' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:Timing' :: Timing -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: Timing
s@Timing' {} Maybe POSIX
a -> Timing
s {$sel:startTime:Timing' :: Maybe POSIX
startTime = Maybe POSIX
a} :: Timing) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time, in Unix epoch format, that you submitted the job.
timing_submitTime :: Lens.Lens' Timing (Prelude.Maybe Prelude.UTCTime)
timing_submitTime :: Lens' Timing (Maybe UTCTime)
timing_submitTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Timing' {Maybe POSIX
submitTime :: Maybe POSIX
$sel:submitTime:Timing' :: Timing -> Maybe POSIX
submitTime} -> Maybe POSIX
submitTime) (\s :: Timing
s@Timing' {} Maybe POSIX
a -> Timing
s {$sel:submitTime:Timing' :: Maybe POSIX
submitTime = Maybe POSIX
a} :: Timing) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON Timing where
  parseJSON :: Value -> Parser Timing
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Timing"
      ( \Object
x ->
          Maybe POSIX -> Maybe POSIX -> Maybe POSIX -> Timing
Timing'
            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
"finishTime")
            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")
            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
"submitTime")
      )

instance Prelude.Hashable Timing where
  hashWithSalt :: Int -> Timing -> Int
hashWithSalt Int
_salt Timing' {Maybe POSIX
submitTime :: Maybe POSIX
startTime :: Maybe POSIX
finishTime :: Maybe POSIX
$sel:submitTime:Timing' :: Timing -> Maybe POSIX
$sel:startTime:Timing' :: Timing -> Maybe POSIX
$sel:finishTime:Timing' :: Timing -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
finishTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
submitTime

instance Prelude.NFData Timing where
  rnf :: Timing -> ()
rnf Timing' {Maybe POSIX
submitTime :: Maybe POSIX
startTime :: Maybe POSIX
finishTime :: Maybe POSIX
$sel:submitTime:Timing' :: Timing -> Maybe POSIX
$sel:startTime:Timing' :: Timing -> Maybe POSIX
$sel:finishTime:Timing' :: Timing -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
finishTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
submitTime