{-# 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.Synthetics.Types.CanaryRunTimeline
-- 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.Synthetics.Types.CanaryRunTimeline where

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

-- | This structure contains the start and end times of a single canary run.
--
-- /See:/ 'newCanaryRunTimeline' smart constructor.
data CanaryRunTimeline = CanaryRunTimeline'
  { -- | The end time of the run.
    CanaryRunTimeline -> Maybe POSIX
completed :: Prelude.Maybe Core.POSIX,
    -- | The start time of the run.
    CanaryRunTimeline -> Maybe POSIX
started :: Prelude.Maybe Core.POSIX
  }
  deriving (CanaryRunTimeline -> CanaryRunTimeline -> Bool
(CanaryRunTimeline -> CanaryRunTimeline -> Bool)
-> (CanaryRunTimeline -> CanaryRunTimeline -> Bool)
-> Eq CanaryRunTimeline
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CanaryRunTimeline -> CanaryRunTimeline -> Bool
$c/= :: CanaryRunTimeline -> CanaryRunTimeline -> Bool
== :: CanaryRunTimeline -> CanaryRunTimeline -> Bool
$c== :: CanaryRunTimeline -> CanaryRunTimeline -> Bool
Prelude.Eq, ReadPrec [CanaryRunTimeline]
ReadPrec CanaryRunTimeline
Int -> ReadS CanaryRunTimeline
ReadS [CanaryRunTimeline]
(Int -> ReadS CanaryRunTimeline)
-> ReadS [CanaryRunTimeline]
-> ReadPrec CanaryRunTimeline
-> ReadPrec [CanaryRunTimeline]
-> Read CanaryRunTimeline
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CanaryRunTimeline]
$creadListPrec :: ReadPrec [CanaryRunTimeline]
readPrec :: ReadPrec CanaryRunTimeline
$creadPrec :: ReadPrec CanaryRunTimeline
readList :: ReadS [CanaryRunTimeline]
$creadList :: ReadS [CanaryRunTimeline]
readsPrec :: Int -> ReadS CanaryRunTimeline
$creadsPrec :: Int -> ReadS CanaryRunTimeline
Prelude.Read, Int -> CanaryRunTimeline -> ShowS
[CanaryRunTimeline] -> ShowS
CanaryRunTimeline -> String
(Int -> CanaryRunTimeline -> ShowS)
-> (CanaryRunTimeline -> String)
-> ([CanaryRunTimeline] -> ShowS)
-> Show CanaryRunTimeline
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CanaryRunTimeline] -> ShowS
$cshowList :: [CanaryRunTimeline] -> ShowS
show :: CanaryRunTimeline -> String
$cshow :: CanaryRunTimeline -> String
showsPrec :: Int -> CanaryRunTimeline -> ShowS
$cshowsPrec :: Int -> CanaryRunTimeline -> ShowS
Prelude.Show, (forall x. CanaryRunTimeline -> Rep CanaryRunTimeline x)
-> (forall x. Rep CanaryRunTimeline x -> CanaryRunTimeline)
-> Generic CanaryRunTimeline
forall x. Rep CanaryRunTimeline x -> CanaryRunTimeline
forall x. CanaryRunTimeline -> Rep CanaryRunTimeline x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CanaryRunTimeline x -> CanaryRunTimeline
$cfrom :: forall x. CanaryRunTimeline -> Rep CanaryRunTimeline x
Prelude.Generic)

-- |
-- Create a value of 'CanaryRunTimeline' 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:
--
-- 'completed', 'canaryRunTimeline_completed' - The end time of the run.
--
-- 'started', 'canaryRunTimeline_started' - The start time of the run.
newCanaryRunTimeline ::
  CanaryRunTimeline
newCanaryRunTimeline :: CanaryRunTimeline
newCanaryRunTimeline =
  CanaryRunTimeline' :: Maybe POSIX -> Maybe POSIX -> CanaryRunTimeline
CanaryRunTimeline'
    { $sel:completed:CanaryRunTimeline' :: Maybe POSIX
completed = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:started:CanaryRunTimeline' :: Maybe POSIX
started = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The end time of the run.
canaryRunTimeline_completed :: Lens.Lens' CanaryRunTimeline (Prelude.Maybe Prelude.UTCTime)
canaryRunTimeline_completed :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CanaryRunTimeline -> f CanaryRunTimeline
canaryRunTimeline_completed = (CanaryRunTimeline -> Maybe POSIX)
-> (CanaryRunTimeline -> Maybe POSIX -> CanaryRunTimeline)
-> Lens
     CanaryRunTimeline CanaryRunTimeline (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRunTimeline' {Maybe POSIX
completed :: Maybe POSIX
$sel:completed:CanaryRunTimeline' :: CanaryRunTimeline -> Maybe POSIX
completed} -> Maybe POSIX
completed) (\s :: CanaryRunTimeline
s@CanaryRunTimeline' {} Maybe POSIX
a -> CanaryRunTimeline
s {$sel:completed:CanaryRunTimeline' :: Maybe POSIX
completed = Maybe POSIX
a} :: CanaryRunTimeline) ((Maybe POSIX -> f (Maybe POSIX))
 -> CanaryRunTimeline -> f CanaryRunTimeline)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CanaryRunTimeline
-> f CanaryRunTimeline
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The start time of the run.
canaryRunTimeline_started :: Lens.Lens' CanaryRunTimeline (Prelude.Maybe Prelude.UTCTime)
canaryRunTimeline_started :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CanaryRunTimeline -> f CanaryRunTimeline
canaryRunTimeline_started = (CanaryRunTimeline -> Maybe POSIX)
-> (CanaryRunTimeline -> Maybe POSIX -> CanaryRunTimeline)
-> Lens
     CanaryRunTimeline CanaryRunTimeline (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRunTimeline' {Maybe POSIX
started :: Maybe POSIX
$sel:started:CanaryRunTimeline' :: CanaryRunTimeline -> Maybe POSIX
started} -> Maybe POSIX
started) (\s :: CanaryRunTimeline
s@CanaryRunTimeline' {} Maybe POSIX
a -> CanaryRunTimeline
s {$sel:started:CanaryRunTimeline' :: Maybe POSIX
started = Maybe POSIX
a} :: CanaryRunTimeline) ((Maybe POSIX -> f (Maybe POSIX))
 -> CanaryRunTimeline -> f CanaryRunTimeline)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CanaryRunTimeline
-> f CanaryRunTimeline
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable CanaryRunTimeline

instance Prelude.NFData CanaryRunTimeline