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

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

-- | Describes the stop condition for an experiment.
--
-- /See:/ 'newExperimentStopCondition' smart constructor.
data ExperimentStopCondition = ExperimentStopCondition'
  { -- | The Amazon Resource Name (ARN) of the CloudWatch alarm, if applicable.
    ExperimentStopCondition -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The source for the stop condition.
    ExperimentStopCondition -> Maybe Text
source :: Prelude.Maybe Prelude.Text
  }
  deriving (ExperimentStopCondition -> ExperimentStopCondition -> Bool
(ExperimentStopCondition -> ExperimentStopCondition -> Bool)
-> (ExperimentStopCondition -> ExperimentStopCondition -> Bool)
-> Eq ExperimentStopCondition
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]
(Int -> ReadS ExperimentStopCondition)
-> ReadS [ExperimentStopCondition]
-> ReadPrec ExperimentStopCondition
-> ReadPrec [ExperimentStopCondition]
-> Read 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
(Int -> ExperimentStopCondition -> ShowS)
-> (ExperimentStopCondition -> String)
-> ([ExperimentStopCondition] -> ShowS)
-> Show ExperimentStopCondition
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.
 ExperimentStopCondition -> Rep ExperimentStopCondition x)
-> (forall x.
    Rep ExperimentStopCondition x -> ExperimentStopCondition)
-> Generic ExperimentStopCondition
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:
--
-- 'value', 'experimentStopCondition_value' - The Amazon Resource Name (ARN) of the CloudWatch alarm, if applicable.
--
-- 'source', 'experimentStopCondition_source' - The source for the stop condition.
newExperimentStopCondition ::
  ExperimentStopCondition
newExperimentStopCondition :: ExperimentStopCondition
newExperimentStopCondition =
  ExperimentStopCondition' :: Maybe Text -> Maybe Text -> ExperimentStopCondition
ExperimentStopCondition'
    { $sel:value:ExperimentStopCondition' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:source:ExperimentStopCondition' :: Maybe Text
source = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the CloudWatch alarm, if applicable.
experimentStopCondition_value :: Lens.Lens' ExperimentStopCondition (Prelude.Maybe Prelude.Text)
experimentStopCondition_value :: (Maybe Text -> f (Maybe Text))
-> ExperimentStopCondition -> f ExperimentStopCondition
experimentStopCondition_value = (ExperimentStopCondition -> Maybe Text)
-> (ExperimentStopCondition
    -> Maybe Text -> ExperimentStopCondition)
-> Lens
     ExperimentStopCondition
     ExperimentStopCondition
     (Maybe Text)
     (Maybe Text)
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)

-- | The source for the stop condition.
experimentStopCondition_source :: Lens.Lens' ExperimentStopCondition (Prelude.Maybe Prelude.Text)
experimentStopCondition_source :: (Maybe Text -> f (Maybe Text))
-> ExperimentStopCondition -> f ExperimentStopCondition
experimentStopCondition_source = (ExperimentStopCondition -> Maybe Text)
-> (ExperimentStopCondition
    -> Maybe Text -> ExperimentStopCondition)
-> Lens
     ExperimentStopCondition
     ExperimentStopCondition
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable ExperimentStopCondition

instance Prelude.NFData ExperimentStopCondition