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

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

-- | Describes the action for an experiment.
--
-- /See:/ 'newExperimentAction' smart constructor.
data ExperimentAction = ExperimentAction'
  { -- | The ID of the action.
    ExperimentAction -> Maybe Text
actionId :: Prelude.Maybe Prelude.Text,
    -- | The description for the action.
    ExperimentAction -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The time that the action ended.
    ExperimentAction -> Maybe POSIX
endTime :: Prelude.Maybe Data.POSIX,
    -- | The parameters for the action.
    ExperimentAction -> Maybe (HashMap Text Text)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the action that must be completed before this action starts.
    ExperimentAction -> Maybe [Text]
startAfter :: Prelude.Maybe [Prelude.Text],
    -- | The time that the action started.
    ExperimentAction -> Maybe POSIX
startTime :: Prelude.Maybe Data.POSIX,
    -- | The state of the action.
    ExperimentAction -> Maybe ExperimentActionState
state :: Prelude.Maybe ExperimentActionState,
    -- | The targets for the action.
    ExperimentAction -> Maybe (HashMap Text Text)
targets :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (ExperimentAction -> ExperimentAction -> Bool
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]
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
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. 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:
--
-- 'actionId', 'experimentAction_actionId' - The ID of the action.
--
-- 'description', 'experimentAction_description' - The description for the action.
--
-- 'endTime', 'experimentAction_endTime' - The time that the action ended.
--
-- 'parameters', 'experimentAction_parameters' - The parameters for the action.
--
-- 'startAfter', 'experimentAction_startAfter' - The name of the action that must be completed before this action starts.
--
-- 'startTime', 'experimentAction_startTime' - The time that the action started.
--
-- 'state', 'experimentAction_state' - The state of the action.
--
-- 'targets', 'experimentAction_targets' - The targets for the action.
newExperimentAction ::
  ExperimentAction
newExperimentAction :: ExperimentAction
newExperimentAction =
  ExperimentAction'
    { $sel:actionId:ExperimentAction' :: Maybe Text
actionId = forall a. Maybe a
Prelude.Nothing,
      $sel:description:ExperimentAction' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:ExperimentAction' :: Maybe POSIX
endTime = forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:ExperimentAction' :: Maybe (HashMap Text Text)
parameters = forall a. Maybe a
Prelude.Nothing,
      $sel:startAfter:ExperimentAction' :: Maybe [Text]
startAfter = forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:ExperimentAction' :: Maybe POSIX
startTime = forall a. Maybe a
Prelude.Nothing,
      $sel:state:ExperimentAction' :: Maybe ExperimentActionState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:targets:ExperimentAction' :: Maybe (HashMap Text Text)
targets = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the action.
experimentAction_actionId :: Lens.Lens' ExperimentAction (Prelude.Maybe Prelude.Text)
experimentAction_actionId :: Lens' ExperimentAction (Maybe Text)
experimentAction_actionId = 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 description for the action.
experimentAction_description :: Lens.Lens' ExperimentAction (Prelude.Maybe Prelude.Text)
experimentAction_description :: Lens' ExperimentAction (Maybe Text)
experimentAction_description = 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)

-- | The time that the action ended.
experimentAction_endTime :: Lens.Lens' ExperimentAction (Prelude.Maybe Prelude.UTCTime)
experimentAction_endTime :: Lens' ExperimentAction (Maybe UTCTime)
experimentAction_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:ExperimentAction' :: ExperimentAction -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe POSIX
a -> ExperimentAction
s {$sel:endTime:ExperimentAction' :: Maybe POSIX
endTime = Maybe POSIX
a} :: ExperimentAction) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The parameters for the action.
experimentAction_parameters :: Lens.Lens' ExperimentAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
experimentAction_parameters :: Lens' ExperimentAction (Maybe (HashMap Text Text))
experimentAction_parameters = 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) 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 action that must be completed before this action starts.
experimentAction_startAfter :: Lens.Lens' ExperimentAction (Prelude.Maybe [Prelude.Text])
experimentAction_startAfter :: Lens' ExperimentAction (Maybe [Text])
experimentAction_startAfter = 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) 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 time that the action started.
experimentAction_startTime :: Lens.Lens' ExperimentAction (Prelude.Maybe Prelude.UTCTime)
experimentAction_startTime :: Lens' ExperimentAction (Maybe UTCTime)
experimentAction_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentAction' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:ExperimentAction' :: ExperimentAction -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: ExperimentAction
s@ExperimentAction' {} Maybe POSIX
a -> ExperimentAction
s {$sel:startTime:ExperimentAction' :: Maybe POSIX
startTime = Maybe POSIX
a} :: ExperimentAction) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The state of the action.
experimentAction_state :: Lens.Lens' ExperimentAction (Prelude.Maybe ExperimentActionState)
experimentAction_state :: Lens' ExperimentAction (Maybe ExperimentActionState)
experimentAction_state = 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 targets for the action.
experimentAction_targets :: Lens.Lens' ExperimentAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
experimentAction_targets :: Lens' ExperimentAction (Maybe (HashMap Text Text))
experimentAction_targets = 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) 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

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

instance Prelude.Hashable ExperimentAction where
  hashWithSalt :: Int -> ExperimentAction -> Int
hashWithSalt Int
_salt ExperimentAction' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe ExperimentActionState
targets :: Maybe (HashMap Text Text)
state :: Maybe ExperimentActionState
startTime :: Maybe POSIX
startAfter :: Maybe [Text]
parameters :: Maybe (HashMap Text Text)
endTime :: Maybe POSIX
description :: Maybe Text
actionId :: Maybe Text
$sel:targets:ExperimentAction' :: ExperimentAction -> Maybe (HashMap Text Text)
$sel:state:ExperimentAction' :: ExperimentAction -> Maybe ExperimentActionState
$sel:startTime:ExperimentAction' :: ExperimentAction -> Maybe POSIX
$sel:startAfter:ExperimentAction' :: ExperimentAction -> Maybe [Text]
$sel:parameters:ExperimentAction' :: ExperimentAction -> Maybe (HashMap Text Text)
$sel:endTime:ExperimentAction' :: ExperimentAction -> Maybe POSIX
$sel:description:ExperimentAction' :: ExperimentAction -> Maybe Text
$sel:actionId:ExperimentAction' :: ExperimentAction -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
actionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
parameters
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
startAfter
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExperimentActionState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
targets

instance Prelude.NFData ExperimentAction where
  rnf :: ExperimentAction -> ()
rnf ExperimentAction' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe POSIX
Maybe ExperimentActionState
targets :: Maybe (HashMap Text Text)
state :: Maybe ExperimentActionState
startTime :: Maybe POSIX
startAfter :: Maybe [Text]
parameters :: Maybe (HashMap Text Text)
endTime :: Maybe POSIX
description :: Maybe Text
actionId :: Maybe Text
$sel:targets:ExperimentAction' :: ExperimentAction -> Maybe (HashMap Text Text)
$sel:state:ExperimentAction' :: ExperimentAction -> Maybe ExperimentActionState
$sel:startTime:ExperimentAction' :: ExperimentAction -> Maybe POSIX
$sel:startAfter:ExperimentAction' :: ExperimentAction -> Maybe [Text]
$sel:parameters:ExperimentAction' :: ExperimentAction -> Maybe (HashMap Text Text)
$sel:endTime:ExperimentAction' :: ExperimentAction -> Maybe POSIX
$sel:description:ExperimentAction' :: ExperimentAction -> Maybe Text
$sel:actionId:ExperimentAction' :: ExperimentAction -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
actionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
parameters
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
startAfter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ExperimentActionState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
targets