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

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

-- | An object that specifies what screenshots to use as a baseline for
-- visual monitoring by this canary, and optionally the parts of the
-- screenshots to ignore during the visual monitoring comparison.
--
-- Visual monitoring is supported only on canaries running the
-- __syn-puppeteer-node-3.2__ runtime or later. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_SyntheticsLogger_VisualTesting.html Visual monitoring>
-- and
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_Blueprints_VisualTesting.html Visual monitoring blueprint>
--
-- /See:/ 'newVisualReferenceInput' smart constructor.
data VisualReferenceInput = VisualReferenceInput'
  { -- | An array of screenshots that will be used as the baseline for visual
    -- monitoring in future runs of this canary. If there is a screenshot that
    -- you don\'t want to be used for visual monitoring, remove it from this
    -- array.
    VisualReferenceInput -> Maybe [BaseScreenshot]
baseScreenshots :: Prelude.Maybe [BaseScreenshot],
    -- | Specifies which canary run to use the screenshots from as the baseline
    -- for future visual monitoring with this canary. Valid values are
    -- @nextrun@ to use the screenshots from the next run after this update is
    -- made, @lastrun@ to use the screenshots from the most recent run before
    -- this update was made, or the value of @Id@ in the
    -- <https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_CanaryRun.html CanaryRun>
    -- from any past run of this canary.
    VisualReferenceInput -> Text
baseCanaryRunId :: Prelude.Text
  }
  deriving (VisualReferenceInput -> VisualReferenceInput -> Bool
(VisualReferenceInput -> VisualReferenceInput -> Bool)
-> (VisualReferenceInput -> VisualReferenceInput -> Bool)
-> Eq VisualReferenceInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VisualReferenceInput -> VisualReferenceInput -> Bool
$c/= :: VisualReferenceInput -> VisualReferenceInput -> Bool
== :: VisualReferenceInput -> VisualReferenceInput -> Bool
$c== :: VisualReferenceInput -> VisualReferenceInput -> Bool
Prelude.Eq, ReadPrec [VisualReferenceInput]
ReadPrec VisualReferenceInput
Int -> ReadS VisualReferenceInput
ReadS [VisualReferenceInput]
(Int -> ReadS VisualReferenceInput)
-> ReadS [VisualReferenceInput]
-> ReadPrec VisualReferenceInput
-> ReadPrec [VisualReferenceInput]
-> Read VisualReferenceInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VisualReferenceInput]
$creadListPrec :: ReadPrec [VisualReferenceInput]
readPrec :: ReadPrec VisualReferenceInput
$creadPrec :: ReadPrec VisualReferenceInput
readList :: ReadS [VisualReferenceInput]
$creadList :: ReadS [VisualReferenceInput]
readsPrec :: Int -> ReadS VisualReferenceInput
$creadsPrec :: Int -> ReadS VisualReferenceInput
Prelude.Read, Int -> VisualReferenceInput -> ShowS
[VisualReferenceInput] -> ShowS
VisualReferenceInput -> String
(Int -> VisualReferenceInput -> ShowS)
-> (VisualReferenceInput -> String)
-> ([VisualReferenceInput] -> ShowS)
-> Show VisualReferenceInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VisualReferenceInput] -> ShowS
$cshowList :: [VisualReferenceInput] -> ShowS
show :: VisualReferenceInput -> String
$cshow :: VisualReferenceInput -> String
showsPrec :: Int -> VisualReferenceInput -> ShowS
$cshowsPrec :: Int -> VisualReferenceInput -> ShowS
Prelude.Show, (forall x. VisualReferenceInput -> Rep VisualReferenceInput x)
-> (forall x. Rep VisualReferenceInput x -> VisualReferenceInput)
-> Generic VisualReferenceInput
forall x. Rep VisualReferenceInput x -> VisualReferenceInput
forall x. VisualReferenceInput -> Rep VisualReferenceInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VisualReferenceInput x -> VisualReferenceInput
$cfrom :: forall x. VisualReferenceInput -> Rep VisualReferenceInput x
Prelude.Generic)

-- |
-- Create a value of 'VisualReferenceInput' 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', 'visualReferenceInput_baseScreenshots' - An array of screenshots that will be used as the baseline for visual
-- monitoring in future runs of this canary. If there is a screenshot that
-- you don\'t want to be used for visual monitoring, remove it from this
-- array.
--
-- 'baseCanaryRunId', 'visualReferenceInput_baseCanaryRunId' - Specifies which canary run to use the screenshots from as the baseline
-- for future visual monitoring with this canary. Valid values are
-- @nextrun@ to use the screenshots from the next run after this update is
-- made, @lastrun@ to use the screenshots from the most recent run before
-- this update was made, or the value of @Id@ in the
-- <https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_CanaryRun.html CanaryRun>
-- from any past run of this canary.
newVisualReferenceInput ::
  -- | 'baseCanaryRunId'
  Prelude.Text ->
  VisualReferenceInput
newVisualReferenceInput :: Text -> VisualReferenceInput
newVisualReferenceInput Text
pBaseCanaryRunId_ =
  VisualReferenceInput' :: Maybe [BaseScreenshot] -> Text -> VisualReferenceInput
VisualReferenceInput'
    { $sel:baseScreenshots:VisualReferenceInput' :: Maybe [BaseScreenshot]
baseScreenshots =
        Maybe [BaseScreenshot]
forall a. Maybe a
Prelude.Nothing,
      $sel:baseCanaryRunId:VisualReferenceInput' :: Text
baseCanaryRunId = Text
pBaseCanaryRunId_
    }

-- | An array of screenshots that will be used as the baseline for visual
-- monitoring in future runs of this canary. If there is a screenshot that
-- you don\'t want to be used for visual monitoring, remove it from this
-- array.
visualReferenceInput_baseScreenshots :: Lens.Lens' VisualReferenceInput (Prelude.Maybe [BaseScreenshot])
visualReferenceInput_baseScreenshots :: (Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
-> VisualReferenceInput -> f VisualReferenceInput
visualReferenceInput_baseScreenshots = (VisualReferenceInput -> Maybe [BaseScreenshot])
-> (VisualReferenceInput
    -> Maybe [BaseScreenshot] -> VisualReferenceInput)
-> Lens
     VisualReferenceInput
     VisualReferenceInput
     (Maybe [BaseScreenshot])
     (Maybe [BaseScreenshot])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VisualReferenceInput' {Maybe [BaseScreenshot]
baseScreenshots :: Maybe [BaseScreenshot]
$sel:baseScreenshots:VisualReferenceInput' :: VisualReferenceInput -> Maybe [BaseScreenshot]
baseScreenshots} -> Maybe [BaseScreenshot]
baseScreenshots) (\s :: VisualReferenceInput
s@VisualReferenceInput' {} Maybe [BaseScreenshot]
a -> VisualReferenceInput
s {$sel:baseScreenshots:VisualReferenceInput' :: Maybe [BaseScreenshot]
baseScreenshots = Maybe [BaseScreenshot]
a} :: VisualReferenceInput) ((Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
 -> VisualReferenceInput -> f VisualReferenceInput)
-> ((Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
    -> Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
-> (Maybe [BaseScreenshot] -> f (Maybe [BaseScreenshot]))
-> VisualReferenceInput
-> f VisualReferenceInput
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

-- | Specifies which canary run to use the screenshots from as the baseline
-- for future visual monitoring with this canary. Valid values are
-- @nextrun@ to use the screenshots from the next run after this update is
-- made, @lastrun@ to use the screenshots from the most recent run before
-- this update was made, or the value of @Id@ in the
-- <https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_CanaryRun.html CanaryRun>
-- from any past run of this canary.
visualReferenceInput_baseCanaryRunId :: Lens.Lens' VisualReferenceInput Prelude.Text
visualReferenceInput_baseCanaryRunId :: (Text -> f Text) -> VisualReferenceInput -> f VisualReferenceInput
visualReferenceInput_baseCanaryRunId = (VisualReferenceInput -> Text)
-> (VisualReferenceInput -> Text -> VisualReferenceInput)
-> Lens VisualReferenceInput VisualReferenceInput Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VisualReferenceInput' {Text
baseCanaryRunId :: Text
$sel:baseCanaryRunId:VisualReferenceInput' :: VisualReferenceInput -> Text
baseCanaryRunId} -> Text
baseCanaryRunId) (\s :: VisualReferenceInput
s@VisualReferenceInput' {} Text
a -> VisualReferenceInput
s {$sel:baseCanaryRunId:VisualReferenceInput' :: Text
baseCanaryRunId = Text
a} :: VisualReferenceInput)

instance Prelude.Hashable VisualReferenceInput

instance Prelude.NFData VisualReferenceInput

instance Core.ToJSON VisualReferenceInput where
  toJSON :: VisualReferenceInput -> Value
toJSON VisualReferenceInput' {Maybe [BaseScreenshot]
Text
baseCanaryRunId :: Text
baseScreenshots :: Maybe [BaseScreenshot]
$sel:baseCanaryRunId:VisualReferenceInput' :: VisualReferenceInput -> Text
$sel:baseScreenshots:VisualReferenceInput' :: VisualReferenceInput -> Maybe [BaseScreenshot]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BaseScreenshots" Text -> [BaseScreenshot] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([BaseScreenshot] -> Pair) -> Maybe [BaseScreenshot] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [BaseScreenshot]
baseScreenshots,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"BaseCanaryRunId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
baseCanaryRunId)
          ]
      )