{-# 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.BaseScreenshot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Synthetics.Types.BaseScreenshot where

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

-- | A structure representing a screenshot that is used as a baseline during
-- visual monitoring comparisons made by the canary.
--
-- /See:/ 'newBaseScreenshot' smart constructor.
data BaseScreenshot = BaseScreenshot'
  { -- | Coordinates that define the part of a screen to ignore during screenshot
    -- comparisons. To obtain the coordinates to use here, use the CloudWatch
    -- console to draw the boundaries on the screen. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/synthetics_canaries_deletion.html Editing or deleting a canary>
    BaseScreenshot -> Maybe [Text]
ignoreCoordinates :: Prelude.Maybe [Prelude.Text],
    -- | The name of the screenshot. This is generated the first time the canary
    -- is run after the @UpdateCanary@ operation that specified for this canary
    -- to perform visual monitoring.
    BaseScreenshot -> Text
screenshotName :: Prelude.Text
  }
  deriving (BaseScreenshot -> BaseScreenshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BaseScreenshot -> BaseScreenshot -> Bool
$c/= :: BaseScreenshot -> BaseScreenshot -> Bool
== :: BaseScreenshot -> BaseScreenshot -> Bool
$c== :: BaseScreenshot -> BaseScreenshot -> Bool
Prelude.Eq, ReadPrec [BaseScreenshot]
ReadPrec BaseScreenshot
Int -> ReadS BaseScreenshot
ReadS [BaseScreenshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BaseScreenshot]
$creadListPrec :: ReadPrec [BaseScreenshot]
readPrec :: ReadPrec BaseScreenshot
$creadPrec :: ReadPrec BaseScreenshot
readList :: ReadS [BaseScreenshot]
$creadList :: ReadS [BaseScreenshot]
readsPrec :: Int -> ReadS BaseScreenshot
$creadsPrec :: Int -> ReadS BaseScreenshot
Prelude.Read, Int -> BaseScreenshot -> ShowS
[BaseScreenshot] -> ShowS
BaseScreenshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BaseScreenshot] -> ShowS
$cshowList :: [BaseScreenshot] -> ShowS
show :: BaseScreenshot -> String
$cshow :: BaseScreenshot -> String
showsPrec :: Int -> BaseScreenshot -> ShowS
$cshowsPrec :: Int -> BaseScreenshot -> ShowS
Prelude.Show, forall x. Rep BaseScreenshot x -> BaseScreenshot
forall x. BaseScreenshot -> Rep BaseScreenshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BaseScreenshot x -> BaseScreenshot
$cfrom :: forall x. BaseScreenshot -> Rep BaseScreenshot x
Prelude.Generic)

-- |
-- Create a value of 'BaseScreenshot' 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:
--
-- 'ignoreCoordinates', 'baseScreenshot_ignoreCoordinates' - Coordinates that define the part of a screen to ignore during screenshot
-- comparisons. To obtain the coordinates to use here, use the CloudWatch
-- console to draw the boundaries on the screen. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/synthetics_canaries_deletion.html Editing or deleting a canary>
--
-- 'screenshotName', 'baseScreenshot_screenshotName' - The name of the screenshot. This is generated the first time the canary
-- is run after the @UpdateCanary@ operation that specified for this canary
-- to perform visual monitoring.
newBaseScreenshot ::
  -- | 'screenshotName'
  Prelude.Text ->
  BaseScreenshot
newBaseScreenshot :: Text -> BaseScreenshot
newBaseScreenshot Text
pScreenshotName_ =
  BaseScreenshot'
    { $sel:ignoreCoordinates:BaseScreenshot' :: Maybe [Text]
ignoreCoordinates =
        forall a. Maybe a
Prelude.Nothing,
      $sel:screenshotName:BaseScreenshot' :: Text
screenshotName = Text
pScreenshotName_
    }

-- | Coordinates that define the part of a screen to ignore during screenshot
-- comparisons. To obtain the coordinates to use here, use the CloudWatch
-- console to draw the boundaries on the screen. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/synthetics_canaries_deletion.html Editing or deleting a canary>
baseScreenshot_ignoreCoordinates :: Lens.Lens' BaseScreenshot (Prelude.Maybe [Prelude.Text])
baseScreenshot_ignoreCoordinates :: Lens' BaseScreenshot (Maybe [Text])
baseScreenshot_ignoreCoordinates = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BaseScreenshot' {Maybe [Text]
ignoreCoordinates :: Maybe [Text]
$sel:ignoreCoordinates:BaseScreenshot' :: BaseScreenshot -> Maybe [Text]
ignoreCoordinates} -> Maybe [Text]
ignoreCoordinates) (\s :: BaseScreenshot
s@BaseScreenshot' {} Maybe [Text]
a -> BaseScreenshot
s {$sel:ignoreCoordinates:BaseScreenshot' :: Maybe [Text]
ignoreCoordinates = Maybe [Text]
a} :: BaseScreenshot) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the screenshot. This is generated the first time the canary
-- is run after the @UpdateCanary@ operation that specified for this canary
-- to perform visual monitoring.
baseScreenshot_screenshotName :: Lens.Lens' BaseScreenshot Prelude.Text
baseScreenshot_screenshotName :: Lens' BaseScreenshot Text
baseScreenshot_screenshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BaseScreenshot' {Text
screenshotName :: Text
$sel:screenshotName:BaseScreenshot' :: BaseScreenshot -> Text
screenshotName} -> Text
screenshotName) (\s :: BaseScreenshot
s@BaseScreenshot' {} Text
a -> BaseScreenshot
s {$sel:screenshotName:BaseScreenshot' :: Text
screenshotName = Text
a} :: BaseScreenshot)

instance Data.FromJSON BaseScreenshot where
  parseJSON :: Value -> Parser BaseScreenshot
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BaseScreenshot"
      ( \Object
x ->
          Maybe [Text] -> Text -> BaseScreenshot
BaseScreenshot'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IgnoreCoordinates"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ScreenshotName")
      )

instance Prelude.Hashable BaseScreenshot where
  hashWithSalt :: Int -> BaseScreenshot -> Int
hashWithSalt Int
_salt BaseScreenshot' {Maybe [Text]
Text
screenshotName :: Text
ignoreCoordinates :: Maybe [Text]
$sel:screenshotName:BaseScreenshot' :: BaseScreenshot -> Text
$sel:ignoreCoordinates:BaseScreenshot' :: BaseScreenshot -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ignoreCoordinates
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
screenshotName

instance Prelude.NFData BaseScreenshot where
  rnf :: BaseScreenshot -> ()
rnf BaseScreenshot' {Maybe [Text]
Text
screenshotName :: Text
ignoreCoordinates :: Maybe [Text]
$sel:screenshotName:BaseScreenshot' :: BaseScreenshot -> Text
$sel:ignoreCoordinates:BaseScreenshot' :: BaseScreenshot -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
ignoreCoordinates
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
screenshotName

instance Data.ToJSON BaseScreenshot where
  toJSON :: BaseScreenshot -> Value
toJSON BaseScreenshot' {Maybe [Text]
Text
screenshotName :: Text
ignoreCoordinates :: Maybe [Text]
$sel:screenshotName:BaseScreenshot' :: BaseScreenshot -> Text
$sel:ignoreCoordinates:BaseScreenshot' :: BaseScreenshot -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IgnoreCoordinates" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ignoreCoordinates,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ScreenshotName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
screenshotName)
          ]
      )