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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Synthetics.Types.CanaryRunStatus
import Amazonka.Synthetics.Types.CanaryRunTimeline

-- | This structure contains the details about one run of one canary.
--
-- /See:/ 'newCanaryRun' smart constructor.
data CanaryRun = CanaryRun'
  { -- | The status of this run.
    CanaryRun -> Maybe CanaryRunStatus
status :: Prelude.Maybe CanaryRunStatus,
    -- | The location where the canary stored artifacts from the run. Artifacts
    -- include the log file, screenshots, and HAR files.
    CanaryRun -> Maybe Text
artifactS3Location :: Prelude.Maybe Prelude.Text,
    -- | The name of the canary.
    CanaryRun -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A unique ID that identifies this canary run.
    CanaryRun -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A structure that contains the start and end times of this run.
    CanaryRun -> Maybe CanaryRunTimeline
timeline :: Prelude.Maybe CanaryRunTimeline
  }
  deriving (CanaryRun -> CanaryRun -> Bool
(CanaryRun -> CanaryRun -> Bool)
-> (CanaryRun -> CanaryRun -> Bool) -> Eq CanaryRun
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CanaryRun -> CanaryRun -> Bool
$c/= :: CanaryRun -> CanaryRun -> Bool
== :: CanaryRun -> CanaryRun -> Bool
$c== :: CanaryRun -> CanaryRun -> Bool
Prelude.Eq, ReadPrec [CanaryRun]
ReadPrec CanaryRun
Int -> ReadS CanaryRun
ReadS [CanaryRun]
(Int -> ReadS CanaryRun)
-> ReadS [CanaryRun]
-> ReadPrec CanaryRun
-> ReadPrec [CanaryRun]
-> Read CanaryRun
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CanaryRun]
$creadListPrec :: ReadPrec [CanaryRun]
readPrec :: ReadPrec CanaryRun
$creadPrec :: ReadPrec CanaryRun
readList :: ReadS [CanaryRun]
$creadList :: ReadS [CanaryRun]
readsPrec :: Int -> ReadS CanaryRun
$creadsPrec :: Int -> ReadS CanaryRun
Prelude.Read, Int -> CanaryRun -> ShowS
[CanaryRun] -> ShowS
CanaryRun -> String
(Int -> CanaryRun -> ShowS)
-> (CanaryRun -> String)
-> ([CanaryRun] -> ShowS)
-> Show CanaryRun
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CanaryRun] -> ShowS
$cshowList :: [CanaryRun] -> ShowS
show :: CanaryRun -> String
$cshow :: CanaryRun -> String
showsPrec :: Int -> CanaryRun -> ShowS
$cshowsPrec :: Int -> CanaryRun -> ShowS
Prelude.Show, (forall x. CanaryRun -> Rep CanaryRun x)
-> (forall x. Rep CanaryRun x -> CanaryRun) -> Generic CanaryRun
forall x. Rep CanaryRun x -> CanaryRun
forall x. CanaryRun -> Rep CanaryRun x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CanaryRun x -> CanaryRun
$cfrom :: forall x. CanaryRun -> Rep CanaryRun x
Prelude.Generic)

-- |
-- Create a value of 'CanaryRun' 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:
--
-- 'status', 'canaryRun_status' - The status of this run.
--
-- 'artifactS3Location', 'canaryRun_artifactS3Location' - The location where the canary stored artifacts from the run. Artifacts
-- include the log file, screenshots, and HAR files.
--
-- 'name', 'canaryRun_name' - The name of the canary.
--
-- 'id', 'canaryRun_id' - A unique ID that identifies this canary run.
--
-- 'timeline', 'canaryRun_timeline' - A structure that contains the start and end times of this run.
newCanaryRun ::
  CanaryRun
newCanaryRun :: CanaryRun
newCanaryRun =
  CanaryRun' :: Maybe CanaryRunStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CanaryRunTimeline
-> CanaryRun
CanaryRun'
    { $sel:status:CanaryRun' :: Maybe CanaryRunStatus
status = Maybe CanaryRunStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:artifactS3Location:CanaryRun' :: Maybe Text
artifactS3Location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CanaryRun' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:CanaryRun' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timeline:CanaryRun' :: Maybe CanaryRunTimeline
timeline = Maybe CanaryRunTimeline
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of this run.
canaryRun_status :: Lens.Lens' CanaryRun (Prelude.Maybe CanaryRunStatus)
canaryRun_status :: (Maybe CanaryRunStatus -> f (Maybe CanaryRunStatus))
-> CanaryRun -> f CanaryRun
canaryRun_status = (CanaryRun -> Maybe CanaryRunStatus)
-> (CanaryRun -> Maybe CanaryRunStatus -> CanaryRun)
-> Lens
     CanaryRun CanaryRun (Maybe CanaryRunStatus) (Maybe CanaryRunStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRun' {Maybe CanaryRunStatus
status :: Maybe CanaryRunStatus
$sel:status:CanaryRun' :: CanaryRun -> Maybe CanaryRunStatus
status} -> Maybe CanaryRunStatus
status) (\s :: CanaryRun
s@CanaryRun' {} Maybe CanaryRunStatus
a -> CanaryRun
s {$sel:status:CanaryRun' :: Maybe CanaryRunStatus
status = Maybe CanaryRunStatus
a} :: CanaryRun)

-- | The location where the canary stored artifacts from the run. Artifacts
-- include the log file, screenshots, and HAR files.
canaryRun_artifactS3Location :: Lens.Lens' CanaryRun (Prelude.Maybe Prelude.Text)
canaryRun_artifactS3Location :: (Maybe Text -> f (Maybe Text)) -> CanaryRun -> f CanaryRun
canaryRun_artifactS3Location = (CanaryRun -> Maybe Text)
-> (CanaryRun -> Maybe Text -> CanaryRun)
-> Lens CanaryRun CanaryRun (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRun' {Maybe Text
artifactS3Location :: Maybe Text
$sel:artifactS3Location:CanaryRun' :: CanaryRun -> Maybe Text
artifactS3Location} -> Maybe Text
artifactS3Location) (\s :: CanaryRun
s@CanaryRun' {} Maybe Text
a -> CanaryRun
s {$sel:artifactS3Location:CanaryRun' :: Maybe Text
artifactS3Location = Maybe Text
a} :: CanaryRun)

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

-- | A unique ID that identifies this canary run.
canaryRun_id :: Lens.Lens' CanaryRun (Prelude.Maybe Prelude.Text)
canaryRun_id :: (Maybe Text -> f (Maybe Text)) -> CanaryRun -> f CanaryRun
canaryRun_id = (CanaryRun -> Maybe Text)
-> (CanaryRun -> Maybe Text -> CanaryRun)
-> Lens CanaryRun CanaryRun (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRun' {Maybe Text
id :: Maybe Text
$sel:id:CanaryRun' :: CanaryRun -> Maybe Text
id} -> Maybe Text
id) (\s :: CanaryRun
s@CanaryRun' {} Maybe Text
a -> CanaryRun
s {$sel:id:CanaryRun' :: Maybe Text
id = Maybe Text
a} :: CanaryRun)

-- | A structure that contains the start and end times of this run.
canaryRun_timeline :: Lens.Lens' CanaryRun (Prelude.Maybe CanaryRunTimeline)
canaryRun_timeline :: (Maybe CanaryRunTimeline -> f (Maybe CanaryRunTimeline))
-> CanaryRun -> f CanaryRun
canaryRun_timeline = (CanaryRun -> Maybe CanaryRunTimeline)
-> (CanaryRun -> Maybe CanaryRunTimeline -> CanaryRun)
-> Lens
     CanaryRun
     CanaryRun
     (Maybe CanaryRunTimeline)
     (Maybe CanaryRunTimeline)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CanaryRun' {Maybe CanaryRunTimeline
timeline :: Maybe CanaryRunTimeline
$sel:timeline:CanaryRun' :: CanaryRun -> Maybe CanaryRunTimeline
timeline} -> Maybe CanaryRunTimeline
timeline) (\s :: CanaryRun
s@CanaryRun' {} Maybe CanaryRunTimeline
a -> CanaryRun
s {$sel:timeline:CanaryRun' :: Maybe CanaryRunTimeline
timeline = Maybe CanaryRunTimeline
a} :: CanaryRun)

instance Core.FromJSON CanaryRun where
  parseJSON :: Value -> Parser CanaryRun
parseJSON =
    String -> (Object -> Parser CanaryRun) -> Value -> Parser CanaryRun
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CanaryRun"
      ( \Object
x ->
          Maybe CanaryRunStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe CanaryRunTimeline
-> CanaryRun
CanaryRun'
            (Maybe CanaryRunStatus
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe CanaryRunTimeline
 -> CanaryRun)
-> Parser (Maybe CanaryRunStatus)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe CanaryRunTimeline
      -> CanaryRun)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CanaryRunStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe CanaryRunTimeline
   -> CanaryRun)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe CanaryRunTimeline -> CanaryRun)
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
"ArtifactS3Location")
            Parser
  (Maybe Text -> Maybe Text -> Maybe CanaryRunTimeline -> CanaryRun)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe CanaryRunTimeline -> CanaryRun)
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
"Name")
            Parser (Maybe Text -> Maybe CanaryRunTimeline -> CanaryRun)
-> Parser (Maybe Text)
-> Parser (Maybe CanaryRunTimeline -> CanaryRun)
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
"Id")
            Parser (Maybe CanaryRunTimeline -> CanaryRun)
-> Parser (Maybe CanaryRunTimeline) -> Parser CanaryRun
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CanaryRunTimeline)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timeline")
      )

instance Prelude.Hashable CanaryRun

instance Prelude.NFData CanaryRun