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

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

-- | If this canary performs visual monitoring by comparing screenshots, this
-- structure contains the ID of the canary run that is used as the baseline
-- for screenshots, and the coordinates of any parts of those screenshots
-- that are ignored during visual monitoring comparison.
--
-- Visual monitoring is supported only on canaries running the
-- __syn-puppeteer-node-3.2__ runtime or later.
--
-- /See:/ 'newVisualReferenceOutput' smart constructor.
data VisualReferenceOutput = VisualReferenceOutput'
  { -- | An array of screenshots that are used as the baseline for comparisons
    -- during visual monitoring.
    VisualReferenceOutput -> Maybe [BaseScreenshot]
baseScreenshots :: Prelude.Maybe [BaseScreenshot],
    -- | The ID of the canary run that produced the screenshots that are used as
    -- the baseline for visual monitoring comparisons during future runs of
    -- this canary.
    VisualReferenceOutput -> Maybe Text
baseCanaryRunId :: Prelude.Maybe Prelude.Text
  }
  deriving (VisualReferenceOutput -> VisualReferenceOutput -> Bool
(VisualReferenceOutput -> VisualReferenceOutput -> Bool)
-> (VisualReferenceOutput -> VisualReferenceOutput -> Bool)
-> Eq VisualReferenceOutput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VisualReferenceOutput -> VisualReferenceOutput -> Bool
$c/= :: VisualReferenceOutput -> VisualReferenceOutput -> Bool
== :: VisualReferenceOutput -> VisualReferenceOutput -> Bool
$c== :: VisualReferenceOutput -> VisualReferenceOutput -> Bool
Prelude.Eq, ReadPrec [VisualReferenceOutput]
ReadPrec VisualReferenceOutput
Int -> ReadS VisualReferenceOutput
ReadS [VisualReferenceOutput]
(Int -> ReadS VisualReferenceOutput)
-> ReadS [VisualReferenceOutput]
-> ReadPrec VisualReferenceOutput
-> ReadPrec [VisualReferenceOutput]
-> Read VisualReferenceOutput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VisualReferenceOutput]
$creadListPrec :: ReadPrec [VisualReferenceOutput]
readPrec :: ReadPrec VisualReferenceOutput
$creadPrec :: ReadPrec VisualReferenceOutput
readList :: ReadS [VisualReferenceOutput]
$creadList :: ReadS [VisualReferenceOutput]
readsPrec :: Int -> ReadS VisualReferenceOutput
$creadsPrec :: Int -> ReadS VisualReferenceOutput
Prelude.Read, Int -> VisualReferenceOutput -> ShowS
[VisualReferenceOutput] -> ShowS
VisualReferenceOutput -> String
(Int -> VisualReferenceOutput -> ShowS)
-> (VisualReferenceOutput -> String)
-> ([VisualReferenceOutput] -> ShowS)
-> Show VisualReferenceOutput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VisualReferenceOutput] -> ShowS
$cshowList :: [VisualReferenceOutput] -> ShowS
show :: VisualReferenceOutput -> String
$cshow :: VisualReferenceOutput -> String
showsPrec :: Int -> VisualReferenceOutput -> ShowS
$cshowsPrec :: Int -> VisualReferenceOutput -> ShowS
Prelude.Show, (forall x. VisualReferenceOutput -> Rep VisualReferenceOutput x)
-> (forall x. Rep VisualReferenceOutput x -> VisualReferenceOutput)
-> Generic VisualReferenceOutput
forall x. Rep VisualReferenceOutput x -> VisualReferenceOutput
forall x. VisualReferenceOutput -> Rep VisualReferenceOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VisualReferenceOutput x -> VisualReferenceOutput
$cfrom :: forall x. VisualReferenceOutput -> Rep VisualReferenceOutput x
Prelude.Generic)

-- |
-- Create a value of 'VisualReferenceOutput' 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:
--
-- 'baseScreenshots', 'visualReferenceOutput_baseScreenshots' - An array of screenshots that are used as the baseline for comparisons
-- during visual monitoring.
--
-- 'baseCanaryRunId', 'visualReferenceOutput_baseCanaryRunId' - The ID of the canary run that produced the screenshots that are used as
-- the baseline for visual monitoring comparisons during future runs of
-- this canary.
newVisualReferenceOutput ::
  VisualReferenceOutput
newVisualReferenceOutput :: VisualReferenceOutput
newVisualReferenceOutput =
  VisualReferenceOutput' :: Maybe [BaseScreenshot] -> Maybe Text -> VisualReferenceOutput
VisualReferenceOutput'
    { $sel:baseScreenshots:VisualReferenceOutput' :: Maybe [BaseScreenshot]
baseScreenshots =
        Maybe [BaseScreenshot]
forall a. Maybe a
Prelude.Nothing,
      $sel:baseCanaryRunId:VisualReferenceOutput' :: Maybe Text
baseCanaryRunId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of screenshots that are used as the baseline for comparisons
-- during visual monitoring.
visualReferenceOutput_baseScreenshots :: Lens.Lens' VisualReferenceOutput (Prelude.Maybe [BaseScreenshot])
visualReferenceOutput_baseScreenshots :: (Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
-> VisualReferenceOutput -> f VisualReferenceOutput
visualReferenceOutput_baseScreenshots = (VisualReferenceOutput -> Maybe [BaseScreenshot])
-> (VisualReferenceOutput
    -> Maybe [BaseScreenshot] -> VisualReferenceOutput)
-> Lens
     VisualReferenceOutput
     VisualReferenceOutput
     (Maybe [BaseScreenshot])
     (Maybe [BaseScreenshot])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VisualReferenceOutput' {Maybe [BaseScreenshot]
baseScreenshots :: Maybe [BaseScreenshot]
$sel:baseScreenshots:VisualReferenceOutput' :: VisualReferenceOutput -> Maybe [BaseScreenshot]
baseScreenshots} -> Maybe [BaseScreenshot]
baseScreenshots) (\s :: VisualReferenceOutput
s@VisualReferenceOutput' {} Maybe [BaseScreenshot]
a -> VisualReferenceOutput
s {$sel:baseScreenshots:VisualReferenceOutput' :: Maybe [BaseScreenshot]
baseScreenshots = Maybe [BaseScreenshot]
a} :: VisualReferenceOutput) ((Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
 -> VisualReferenceOutput -> f VisualReferenceOutput)
-> ((Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
    -> Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
-> (Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
-> VisualReferenceOutput
-> f VisualReferenceOutput
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [BaseScreenshot] [BaseScreenshot] [BaseScreenshot] [BaseScreenshot]
-> Iso
     (Maybe [BaseScreenshot])
     (Maybe [BaseScreenshot])
     (Maybe [BaseScreenshot])
     (Maybe [BaseScreenshot])
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
  [BaseScreenshot] [BaseScreenshot] [BaseScreenshot] [BaseScreenshot]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the canary run that produced the screenshots that are used as
-- the baseline for visual monitoring comparisons during future runs of
-- this canary.
visualReferenceOutput_baseCanaryRunId :: Lens.Lens' VisualReferenceOutput (Prelude.Maybe Prelude.Text)
visualReferenceOutput_baseCanaryRunId :: (Maybe Text -> f (Maybe Text))
-> VisualReferenceOutput -> f VisualReferenceOutput
visualReferenceOutput_baseCanaryRunId = (VisualReferenceOutput -> Maybe Text)
-> (VisualReferenceOutput -> Maybe Text -> VisualReferenceOutput)
-> Lens
     VisualReferenceOutput
     VisualReferenceOutput
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VisualReferenceOutput' {Maybe Text
baseCanaryRunId :: Maybe Text
$sel:baseCanaryRunId:VisualReferenceOutput' :: VisualReferenceOutput -> Maybe Text
baseCanaryRunId} -> Maybe Text
baseCanaryRunId) (\s :: VisualReferenceOutput
s@VisualReferenceOutput' {} Maybe Text
a -> VisualReferenceOutput
s {$sel:baseCanaryRunId:VisualReferenceOutput' :: Maybe Text
baseCanaryRunId = Maybe Text
a} :: VisualReferenceOutput)

instance Core.FromJSON VisualReferenceOutput where
  parseJSON :: Value -> Parser VisualReferenceOutput
parseJSON =
    String
-> (Object -> Parser VisualReferenceOutput)
-> Value
-> Parser VisualReferenceOutput
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VisualReferenceOutput"
      ( \Object
x ->
          Maybe [BaseScreenshot] -> Maybe Text -> VisualReferenceOutput
VisualReferenceOutput'
            (Maybe [BaseScreenshot] -> Maybe Text -> VisualReferenceOutput)
-> Parser (Maybe [BaseScreenshot])
-> Parser (Maybe Text -> VisualReferenceOutput)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [BaseScreenshot]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BaseScreenshots"
                            Parser (Maybe (Maybe [BaseScreenshot]))
-> Maybe [BaseScreenshot] -> Parser (Maybe [BaseScreenshot])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [BaseScreenshot]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> VisualReferenceOutput)
-> Parser (Maybe Text) -> Parser VisualReferenceOutput
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
"BaseCanaryRunId")
      )

instance Prelude.Hashable VisualReferenceOutput

instance Prelude.NFData VisualReferenceOutput