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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
    -- Logs console to draw the boundaries on the screen. For more information,
    -- see {LINK}
    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
(BaseScreenshot -> BaseScreenshot -> Bool)
-> (BaseScreenshot -> BaseScreenshot -> Bool) -> Eq BaseScreenshot
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]
(Int -> ReadS BaseScreenshot)
-> ReadS [BaseScreenshot]
-> ReadPrec BaseScreenshot
-> ReadPrec [BaseScreenshot]
-> Read 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
(Int -> BaseScreenshot -> ShowS)
-> (BaseScreenshot -> String)
-> ([BaseScreenshot] -> ShowS)
-> Show BaseScreenshot
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. BaseScreenshot -> Rep BaseScreenshot x)
-> (forall x. Rep BaseScreenshot x -> BaseScreenshot)
-> Generic BaseScreenshot
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
-- Logs console to draw the boundaries on the screen. For more information,
-- see {LINK}
--
-- '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' :: Maybe [Text] -> Text -> BaseScreenshot
BaseScreenshot'
    { $sel:ignoreCoordinates:BaseScreenshot' :: Maybe [Text]
ignoreCoordinates =
        Maybe [Text]
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
-- Logs console to draw the boundaries on the screen. For more information,
-- see {LINK}
baseScreenshot_ignoreCoordinates :: Lens.Lens' BaseScreenshot (Prelude.Maybe [Prelude.Text])
baseScreenshot_ignoreCoordinates :: (Maybe [Text] -> f (Maybe [Text]))
-> BaseScreenshot -> f BaseScreenshot
baseScreenshot_ignoreCoordinates = (BaseScreenshot -> Maybe [Text])
-> (BaseScreenshot -> Maybe [Text] -> BaseScreenshot)
-> Lens BaseScreenshot BaseScreenshot (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> BaseScreenshot -> f BaseScreenshot)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> BaseScreenshot
-> f BaseScreenshot
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
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 :: (Text -> f Text) -> BaseScreenshot -> f BaseScreenshot
baseScreenshot_screenshotName = (BaseScreenshot -> Text)
-> (BaseScreenshot -> Text -> BaseScreenshot)
-> Lens BaseScreenshot BaseScreenshot Text Text
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 Core.FromJSON BaseScreenshot where
  parseJSON :: Value -> Parser BaseScreenshot
parseJSON =
    String
-> (Object -> Parser BaseScreenshot)
-> Value
-> Parser BaseScreenshot
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BaseScreenshot"
      ( \Object
x ->
          Maybe [Text] -> Text -> BaseScreenshot
BaseScreenshot'
            (Maybe [Text] -> Text -> BaseScreenshot)
-> Parser (Maybe [Text]) -> Parser (Text -> BaseScreenshot)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IgnoreCoordinates"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Text -> BaseScreenshot)
-> Parser Text -> Parser BaseScreenshot
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ScreenshotName")
      )

instance Prelude.Hashable BaseScreenshot

instance Prelude.NFData BaseScreenshot

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IgnoreCoordinates" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
ignoreCoordinates,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ScreenshotName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
screenshotName)
          ]
      )