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

import qualified Amazonka.Core as Core
import Amazonka.FIS.Types.ExperimentActionState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the action for an experiment.
--
-- /See:/ 'newExperimentAction' smart constructor.
data ExperimentAction = ExperimentAction'
  { -- | The name of the action that must be completed before this action starts.
    ExperimentAction -> Maybe [Text]
startAfter :: Prelude.Maybe [Prelude.Text],
    -- | The state of the action.
    ExperimentAction -> Maybe ExperimentActionState
state :: Prelude.Maybe ExperimentActionState,
    -- | The ID of the action.
    ExperimentAction -> Maybe Text
actionId :: Prelude.Maybe Prelude.Text,
    -- | The parameters for the action.
    ExperimentAction -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The targets for the action.
    ExperimentAction -> Maybe (HashMap Text Text)
targets :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The description for the action.
    ExperimentAction -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (ExperimentAction -> ExperimentAction -> Bool
(ExperimentAction -> ExperimentAction -> Bool)
-> (ExperimentAction -> ExperimentAction -> Bool)
-> Eq ExperimentAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExperimentAction -> ExperimentAction -> Bool
$c/= :: ExperimentAction -> ExperimentAction -> Bool
== :: ExperimentAction -> ExperimentAction -> Bool
$c== :: ExperimentAction -> ExperimentAction -> Bool
Prelude.Eq, ReadPrec [ExperimentAction]
ReadPrec ExperimentAction
Int -> ReadS ExperimentAction
ReadS [ExperimentAction]
(Int -> ReadS ExperimentAction)
-> ReadS [ExperimentAction]
-> ReadPrec ExperimentAction
-> ReadPrec [ExperimentAction]
-> Read ExperimentAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExperimentAction]
$creadListPrec :: ReadPrec [ExperimentAction]
readPrec :: ReadPrec ExperimentAction
$creadPrec :: ReadPrec ExperimentAction
readList :: ReadS [ExperimentAction]
$creadList :: ReadS [ExperimentAction]
readsPrec :: Int -> ReadS ExperimentAction
$creadsPrec :: Int -> ReadS ExperimentAction
Prelude.Read, Int -> ExperimentAction -> ShowS
[ExperimentAction] -> ShowS
ExperimentAction -> String
(Int -> ExperimentAction -> ShowS)
-> (ExperimentAction -> String)
-> ([ExperimentAction] -> ShowS)
-> Show ExperimentAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExperimentAction] -> ShowS
$cshowList :: [ExperimentAction] -> ShowS
show :: ExperimentAction -> String
$cshow :: ExperimentAction -> String
showsPrec :: Int -> ExperimentAction -> ShowS
$cshowsPrec :: Int -> ExperimentAction -> ShowS
Prelude.Show, (forall x. ExperimentAction -> Rep ExperimentAction x)
-> (forall x. Rep ExperimentAction x -> ExperimentAction)
-> Generic ExperimentAction
forall x. Rep ExperimentAction x -> ExperimentAction
forall x. ExperimentAction -> Rep ExperimentAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExperimentAction x -> ExperimentAction
$cfrom :: forall x. ExperimentAction -> Rep ExperimentAction x
Prelude.Generic)

-- |
-- Create a value of 'ExperimentAction' 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:
--
-- 'startAfter', 'experimentAction_startAfter' - The name of the action that must be completed before this action starts.
--
-- 'state', 'experimentAction_state' - The state of the action.
--
-- 'actionId', 'experimentAction_actionId' - The ID of the action.
--
-- 'parameters', 'experimentAction_parameters' - The parameters for the action.
--
-- 'targets', 'experimentAction_targets' - The targets for the action.
--
-- 'description', 'experimentAction_description' - The description for the action.
newExperimentAction ::
  ExperimentAction
newExperimentAction :: ExperimentAction
newExperimentAction =
  ExperimentAction' :: Maybe [Text]
-> Maybe ExperimentActionState
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe (HashMap Text Text)
-> Maybe Text
-> ExperimentAction
ExperimentAction'
    { $sel:startAfter:ExperimentAction' :: Maybe [Text]
startAfter = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:state:ExperimentAction' :: Maybe ExperimentActionState
state = Maybe ExperimentActionState
forall a. Maybe a
Prelude.Nothing,
      $sel:actionId:ExperimentAction' :: Maybe Text
actionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:ExperimentAction' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:targets:ExperimentAction' :: Maybe (HashMap Text Text)
targets = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ExperimentAction' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the action that must be completed before this action starts.
experimentAction_startAfter :: Lens.Lens' ExperimentAction (Prelude.Maybe [Prelude.Text])
experimentAction_startAfter :: (Maybe [Text] -> f (Maybe [Text]))
-> ExperimentAction -> f ExperimentAction
experimentAction_startAfter = (ExperimentAction -> Maybe [Text])
-> (ExperimentAction -> Maybe [Text] -> ExperimentAction)
-> Lens
     ExperimentAction ExperimentAction (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe [Text]
startAfter :: Maybe [Text]
$sel:startAfter:ExperimentAction' :: ExperimentAction -> Maybe [Text]
startAfter} -> Maybe [Text]
startAfter) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe [Text]
a -> ExperimentAction
s {$sel:startAfter:ExperimentAction' :: Maybe [Text]
startAfter = Maybe [Text]
a} :: ExperimentAction) ((Maybe [Text] -> f (Maybe [Text]))
 -> ExperimentAction -> f ExperimentAction)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ExperimentAction
-> f ExperimentAction
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 state of the action.
experimentAction_state :: Lens.Lens' ExperimentAction (Prelude.Maybe ExperimentActionState)
experimentAction_state :: (Maybe ExperimentActionState -> f (Maybe ExperimentActionState))
-> ExperimentAction -> f ExperimentAction
experimentAction_state = (ExperimentAction -> Maybe ExperimentActionState)
-> (ExperimentAction
    -> Maybe ExperimentActionState -> ExperimentAction)
-> Lens
     ExperimentAction
     ExperimentAction
     (Maybe ExperimentActionState)
     (Maybe ExperimentActionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe ExperimentActionState
state :: Maybe ExperimentActionState
$sel:state:ExperimentAction' :: ExperimentAction -> Maybe ExperimentActionState
state} -> Maybe ExperimentActionState
state) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe ExperimentActionState
a -> ExperimentAction
s {$sel:state:ExperimentAction' :: Maybe ExperimentActionState
state = Maybe ExperimentActionState
a} :: ExperimentAction)

-- | The ID of the action.
experimentAction_actionId :: Lens.Lens' ExperimentAction (Prelude.Maybe Prelude.Text)
experimentAction_actionId :: (Maybe Text -> f (Maybe Text))
-> ExperimentAction -> f ExperimentAction
experimentAction_actionId = (ExperimentAction -> Maybe Text)
-> (ExperimentAction -> Maybe Text -> ExperimentAction)
-> Lens ExperimentAction ExperimentAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe Text
actionId :: Maybe Text
$sel:actionId:ExperimentAction' :: ExperimentAction -> Maybe Text
actionId} -> Maybe Text
actionId) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe Text
a -> ExperimentAction
s {$sel:actionId:ExperimentAction' :: Maybe Text
actionId = Maybe Text
a} :: ExperimentAction)

-- | The parameters for the action.
experimentAction_parameters :: Lens.Lens' ExperimentAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
experimentAction_parameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ExperimentAction -> f ExperimentAction
experimentAction_parameters = (ExperimentAction -> Maybe (HashMap Text Text))
-> (ExperimentAction
    -> Maybe (HashMap Text Text) -> ExperimentAction)
-> Lens
     ExperimentAction
     ExperimentAction
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe (HashMap Text Text)
parameters :: Maybe (HashMap Text Text)
$sel:parameters:ExperimentAction' :: ExperimentAction -> Maybe (HashMap Text Text)
parameters} -> Maybe (HashMap Text Text)
parameters) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe (HashMap Text Text)
a -> ExperimentAction
s {$sel:parameters:ExperimentAction' :: Maybe (HashMap Text Text)
parameters = Maybe (HashMap Text Text)
a} :: ExperimentAction) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ExperimentAction -> f ExperimentAction)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ExperimentAction
-> f ExperimentAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The targets for the action.
experimentAction_targets :: Lens.Lens' ExperimentAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
experimentAction_targets :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ExperimentAction -> f ExperimentAction
experimentAction_targets = (ExperimentAction -> Maybe (HashMap Text Text))
-> (ExperimentAction
    -> Maybe (HashMap Text Text) -> ExperimentAction)
-> Lens
     ExperimentAction
     ExperimentAction
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe (HashMap Text Text)
targets :: Maybe (HashMap Text Text)
$sel:targets:ExperimentAction' :: ExperimentAction -> Maybe (HashMap Text Text)
targets} -> Maybe (HashMap Text Text)
targets) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe (HashMap Text Text)
a -> ExperimentAction
s {$sel:targets:ExperimentAction' :: Maybe (HashMap Text Text)
targets = Maybe (HashMap Text Text)
a} :: ExperimentAction) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ExperimentAction -> f ExperimentAction)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ExperimentAction
-> f ExperimentAction
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The description for the action.
experimentAction_description :: Lens.Lens' ExperimentAction (Prelude.Maybe Prelude.Text)
experimentAction_description :: (Maybe Text -> f (Maybe Text))
-> ExperimentAction -> f ExperimentAction
experimentAction_description = (ExperimentAction -> Maybe Text)
-> (ExperimentAction -> Maybe Text -> ExperimentAction)
-> Lens ExperimentAction ExperimentAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe Text
description :: Maybe Text
$sel:description:ExperimentAction' :: ExperimentAction -> Maybe Text
description} -> Maybe Text
description) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe Text
a -> ExperimentAction
s {$sel:description:ExperimentAction' :: Maybe Text
description = Maybe Text
a} :: ExperimentAction)

instance Core.FromJSON ExperimentAction where
  parseJSON :: Value -> Parser ExperimentAction
parseJSON =
    String
-> (Object -> Parser ExperimentAction)
-> Value
-> Parser ExperimentAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExperimentAction"
      ( \Object
x ->
          Maybe [Text]
-> Maybe ExperimentActionState
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe (HashMap Text Text)
-> Maybe Text
-> ExperimentAction
ExperimentAction'
            (Maybe [Text]
 -> Maybe ExperimentActionState
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> ExperimentAction)
-> Parser (Maybe [Text])
-> Parser
     (Maybe ExperimentActionState
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> ExperimentAction)
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
"startAfter" 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
  (Maybe ExperimentActionState
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> ExperimentAction)
-> Parser (Maybe ExperimentActionState)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> ExperimentAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ExperimentActionState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"state")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> ExperimentAction)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe (HashMap Text Text) -> Maybe Text -> ExperimentAction)
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
"actionId")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe (HashMap Text Text) -> Maybe Text -> ExperimentAction)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe (HashMap Text Text) -> Maybe Text -> ExperimentAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"parameters" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe (HashMap Text Text) -> Maybe Text -> ExperimentAction)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Text -> ExperimentAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targets" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ExperimentAction)
-> Parser (Maybe Text) -> Parser ExperimentAction
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
"description")
      )

instance Prelude.Hashable ExperimentAction

instance Prelude.NFData ExperimentAction