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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Synthetics.Types.CanaryRun

-- | This structure contains information about the most recent run of a
-- single canary.
--
-- /See:/ 'newCanaryLastRun' smart constructor.
data CanaryLastRun = CanaryLastRun'
  { -- | The name of the canary.
    CanaryLastRun -> Maybe Text
canaryName :: Prelude.Maybe Prelude.Text,
    -- | The results from this canary\'s most recent run.
    CanaryLastRun -> Maybe CanaryRun
lastRun :: Prelude.Maybe CanaryRun
  }
  deriving (CanaryLastRun -> CanaryLastRun -> Bool
(CanaryLastRun -> CanaryLastRun -> Bool)
-> (CanaryLastRun -> CanaryLastRun -> Bool) -> Eq CanaryLastRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CanaryLastRun -> CanaryLastRun -> Bool
$c/= :: CanaryLastRun -> CanaryLastRun -> Bool
== :: CanaryLastRun -> CanaryLastRun -> Bool
$c== :: CanaryLastRun -> CanaryLastRun -> Bool
Prelude.Eq, ReadPrec [CanaryLastRun]
ReadPrec CanaryLastRun
Int -> ReadS CanaryLastRun
ReadS [CanaryLastRun]
(Int -> ReadS CanaryLastRun)
-> ReadS [CanaryLastRun]
-> ReadPrec CanaryLastRun
-> ReadPrec [CanaryLastRun]
-> Read CanaryLastRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CanaryLastRun]
$creadListPrec :: ReadPrec [CanaryLastRun]
readPrec :: ReadPrec CanaryLastRun
$creadPrec :: ReadPrec CanaryLastRun
readList :: ReadS [CanaryLastRun]
$creadList :: ReadS [CanaryLastRun]
readsPrec :: Int -> ReadS CanaryLastRun
$creadsPrec :: Int -> ReadS CanaryLastRun
Prelude.Read, Int -> CanaryLastRun -> ShowS
[CanaryLastRun] -> ShowS
CanaryLastRun -> String
(Int -> CanaryLastRun -> ShowS)
-> (CanaryLastRun -> String)
-> ([CanaryLastRun] -> ShowS)
-> Show CanaryLastRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CanaryLastRun] -> ShowS
$cshowList :: [CanaryLastRun] -> ShowS
show :: CanaryLastRun -> String
$cshow :: CanaryLastRun -> String
showsPrec :: Int -> CanaryLastRun -> ShowS
$cshowsPrec :: Int -> CanaryLastRun -> ShowS
Prelude.Show, (forall x. CanaryLastRun -> Rep CanaryLastRun x)
-> (forall x. Rep CanaryLastRun x -> CanaryLastRun)
-> Generic CanaryLastRun
forall x. Rep CanaryLastRun x -> CanaryLastRun
forall x. CanaryLastRun -> Rep CanaryLastRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CanaryLastRun x -> CanaryLastRun
$cfrom :: forall x. CanaryLastRun -> Rep CanaryLastRun x
Prelude.Generic)

-- |
-- Create a value of 'CanaryLastRun' 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:
--
-- 'canaryName', 'canaryLastRun_canaryName' - The name of the canary.
--
-- 'lastRun', 'canaryLastRun_lastRun' - The results from this canary\'s most recent run.
newCanaryLastRun ::
  CanaryLastRun
newCanaryLastRun :: CanaryLastRun
newCanaryLastRun =
  CanaryLastRun' :: Maybe Text -> Maybe CanaryRun -> CanaryLastRun
CanaryLastRun'
    { $sel:canaryName:CanaryLastRun' :: Maybe Text
canaryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastRun:CanaryLastRun' :: Maybe CanaryRun
lastRun = Maybe CanaryRun
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the canary.
canaryLastRun_canaryName :: Lens.Lens' CanaryLastRun (Prelude.Maybe Prelude.Text)
canaryLastRun_canaryName :: (Maybe Text -> f (Maybe Text)) -> CanaryLastRun -> f CanaryLastRun
canaryLastRun_canaryName = (CanaryLastRun -> Maybe Text)
-> (CanaryLastRun -> Maybe Text -> CanaryLastRun)
-> Lens CanaryLastRun CanaryLastRun (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryLastRun' {Maybe Text
canaryName :: Maybe Text
$sel:canaryName:CanaryLastRun' :: CanaryLastRun -> Maybe Text
canaryName} -> Maybe Text
canaryName) (\s :: CanaryLastRun
s@CanaryLastRun' {} Maybe Text
a -> CanaryLastRun
s {$sel:canaryName:CanaryLastRun' :: Maybe Text
canaryName = Maybe Text
a} :: CanaryLastRun)

-- | The results from this canary\'s most recent run.
canaryLastRun_lastRun :: Lens.Lens' CanaryLastRun (Prelude.Maybe CanaryRun)
canaryLastRun_lastRun :: (Maybe CanaryRun -> f (Maybe CanaryRun))
-> CanaryLastRun -> f CanaryLastRun
canaryLastRun_lastRun = (CanaryLastRun -> Maybe CanaryRun)
-> (CanaryLastRun -> Maybe CanaryRun -> CanaryLastRun)
-> Lens
     CanaryLastRun CanaryLastRun (Maybe CanaryRun) (Maybe CanaryRun)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryLastRun' {Maybe CanaryRun
lastRun :: Maybe CanaryRun
$sel:lastRun:CanaryLastRun' :: CanaryLastRun -> Maybe CanaryRun
lastRun} -> Maybe CanaryRun
lastRun) (\s :: CanaryLastRun
s@CanaryLastRun' {} Maybe CanaryRun
a -> CanaryLastRun
s {$sel:lastRun:CanaryLastRun' :: Maybe CanaryRun
lastRun = Maybe CanaryRun
a} :: CanaryLastRun)

instance Core.FromJSON CanaryLastRun where
  parseJSON :: Value -> Parser CanaryLastRun
parseJSON =
    String
-> (Object -> Parser CanaryLastRun)
-> Value
-> Parser CanaryLastRun
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CanaryLastRun"
      ( \Object
x ->
          Maybe Text -> Maybe CanaryRun -> CanaryLastRun
CanaryLastRun'
            (Maybe Text -> Maybe CanaryRun -> CanaryLastRun)
-> Parser (Maybe Text) -> Parser (Maybe CanaryRun -> CanaryLastRun)
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
"CanaryName")
            Parser (Maybe CanaryRun -> CanaryLastRun)
-> Parser (Maybe CanaryRun) -> Parser CanaryLastRun
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CanaryRun)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastRun")
      )

instance Prelude.Hashable CanaryLastRun

instance Prelude.NFData CanaryLastRun