{-# 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.FIS.Types.ExperimentStopCondition
-- 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.FIS.Types.ExperimentStopCondition 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

-- | Describes the stop condition for an experiment.
--
-- /See:/ 'newExperimentStopCondition' smart constructor.
data ExperimentStopCondition = ExperimentStopCondition'
  { -- | The source for the stop condition.
    ExperimentStopCondition -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the CloudWatch alarm, if applicable.
    ExperimentStopCondition -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ExperimentStopCondition -> ExperimentStopCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExperimentStopCondition -> ExperimentStopCondition -> Bool
$c/= :: ExperimentStopCondition -> ExperimentStopCondition -> Bool
== :: ExperimentStopCondition -> ExperimentStopCondition -> Bool
$c== :: ExperimentStopCondition -> ExperimentStopCondition -> Bool
Prelude.Eq, ReadPrec [ExperimentStopCondition]
ReadPrec ExperimentStopCondition
Int -> ReadS ExperimentStopCondition
ReadS [ExperimentStopCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExperimentStopCondition]
$creadListPrec :: ReadPrec [ExperimentStopCondition]
readPrec :: ReadPrec ExperimentStopCondition
$creadPrec :: ReadPrec ExperimentStopCondition
readList :: ReadS [ExperimentStopCondition]
$creadList :: ReadS [ExperimentStopCondition]
readsPrec :: Int -> ReadS ExperimentStopCondition
$creadsPrec :: Int -> ReadS ExperimentStopCondition
Prelude.Read, Int -> ExperimentStopCondition -> ShowS
[ExperimentStopCondition] -> ShowS
ExperimentStopCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExperimentStopCondition] -> ShowS
$cshowList :: [ExperimentStopCondition] -> ShowS
show :: ExperimentStopCondition -> String
$cshow :: ExperimentStopCondition -> String
showsPrec :: Int -> ExperimentStopCondition -> ShowS
$cshowsPrec :: Int -> ExperimentStopCondition -> ShowS
Prelude.Show, forall x. Rep ExperimentStopCondition x -> ExperimentStopCondition
forall x. ExperimentStopCondition -> Rep ExperimentStopCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExperimentStopCondition x -> ExperimentStopCondition
$cfrom :: forall x. ExperimentStopCondition -> Rep ExperimentStopCondition x
Prelude.Generic)

-- |
-- Create a value of 'ExperimentStopCondition' 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:
--
-- 'source', 'experimentStopCondition_source' - The source for the stop condition.
--
-- 'value', 'experimentStopCondition_value' - The Amazon Resource Name (ARN) of the CloudWatch alarm, if applicable.
newExperimentStopCondition ::
  ExperimentStopCondition
newExperimentStopCondition :: ExperimentStopCondition
newExperimentStopCondition =
  ExperimentStopCondition'
    { $sel:source:ExperimentStopCondition' :: Maybe Text
source = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ExperimentStopCondition' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The source for the stop condition.
experimentStopCondition_source :: Lens.Lens' ExperimentStopCondition (Prelude.Maybe Prelude.Text)
experimentStopCondition_source :: Lens' ExperimentStopCondition (Maybe Text)
experimentStopCondition_source = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentStopCondition' {Maybe Text
source :: Maybe Text
$sel:source:ExperimentStopCondition' :: ExperimentStopCondition -> Maybe Text
source} -> Maybe Text
source) (\s :: ExperimentStopCondition
s@ExperimentStopCondition' {} Maybe Text
a -> ExperimentStopCondition
s {$sel:source:ExperimentStopCondition' :: Maybe Text
source = Maybe Text
a} :: ExperimentStopCondition)

-- | The Amazon Resource Name (ARN) of the CloudWatch alarm, if applicable.
experimentStopCondition_value :: Lens.Lens' ExperimentStopCondition (Prelude.Maybe Prelude.Text)
experimentStopCondition_value :: Lens' ExperimentStopCondition (Maybe Text)
experimentStopCondition_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentStopCondition' {Maybe Text
value :: Maybe Text
$sel:value:ExperimentStopCondition' :: ExperimentStopCondition -> Maybe Text
value} -> Maybe Text
value) (\s :: ExperimentStopCondition
s@ExperimentStopCondition' {} Maybe Text
a -> ExperimentStopCondition
s {$sel:value:ExperimentStopCondition' :: Maybe Text
value = Maybe Text
a} :: ExperimentStopCondition)

instance Data.FromJSON ExperimentStopCondition where
  parseJSON :: Value -> Parser ExperimentStopCondition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExperimentStopCondition"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ExperimentStopCondition
ExperimentStopCondition'
            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
"source")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"value")
      )

instance Prelude.Hashable ExperimentStopCondition where
  hashWithSalt :: Int -> ExperimentStopCondition -> Int
hashWithSalt Int
_salt ExperimentStopCondition' {Maybe Text
value :: Maybe Text
source :: Maybe Text
$sel:value:ExperimentStopCondition' :: ExperimentStopCondition -> Maybe Text
$sel:source:ExperimentStopCondition' :: ExperimentStopCondition -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
source
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData ExperimentStopCondition where
  rnf :: ExperimentStopCondition -> ()
rnf ExperimentStopCondition' {Maybe Text
value :: Maybe Text
source :: Maybe Text
$sel:value:ExperimentStopCondition' :: ExperimentStopCondition -> Maybe Text
$sel:source:ExperimentStopCondition' :: ExperimentStopCondition -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
source seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value