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

import qualified Amazonka.Core as Core
import Amazonka.FIS.Types.ActionParameter
import Amazonka.FIS.Types.ActionTarget
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an action. For more information, see
-- <https://docs.aws.amazon.com/fis/latest/userguide/fis-actions-reference.html AWS FIS actions>
-- in the /AWS Fault Injection Simulator User Guide/.
--
-- /See:/ 'newAction' smart constructor.
data Action = Action'
  { -- | The action parameters, if applicable.
    Action -> Maybe (HashMap Text ActionParameter)
parameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text ActionParameter),
    -- | The supported targets for the action.
    Action -> Maybe (HashMap Text ActionTarget)
targets :: Prelude.Maybe (Prelude.HashMap Prelude.Text ActionTarget),
    -- | The ID of the action.
    Action -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The description for the action.
    Action -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The tags for the action.
    Action -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (Action -> Action -> Bool
(Action -> Action -> Bool)
-> (Action -> Action -> Bool) -> Eq Action
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c== :: Action -> Action -> Bool
Prelude.Eq, ReadPrec [Action]
ReadPrec Action
Int -> ReadS Action
ReadS [Action]
(Int -> ReadS Action)
-> ReadS [Action]
-> ReadPrec Action
-> ReadPrec [Action]
-> Read Action
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Action]
$creadListPrec :: ReadPrec [Action]
readPrec :: ReadPrec Action
$creadPrec :: ReadPrec Action
readList :: ReadS [Action]
$creadList :: ReadS [Action]
readsPrec :: Int -> ReadS Action
$creadsPrec :: Int -> ReadS Action
Prelude.Read, Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
(Int -> Action -> ShowS)
-> (Action -> String) -> ([Action] -> ShowS) -> Show Action
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Action] -> ShowS
$cshowList :: [Action] -> ShowS
show :: Action -> String
$cshow :: Action -> String
showsPrec :: Int -> Action -> ShowS
$cshowsPrec :: Int -> Action -> ShowS
Prelude.Show, (forall x. Action -> Rep Action x)
-> (forall x. Rep Action x -> Action) -> Generic Action
forall x. Rep Action x -> Action
forall x. Action -> Rep Action x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Action x -> Action
$cfrom :: forall x. Action -> Rep Action x
Prelude.Generic)

-- |
-- Create a value of 'Action' 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:
--
-- 'parameters', 'action_parameters' - The action parameters, if applicable.
--
-- 'targets', 'action_targets' - The supported targets for the action.
--
-- 'id', 'action_id' - The ID of the action.
--
-- 'description', 'action_description' - The description for the action.
--
-- 'tags', 'action_tags' - The tags for the action.
newAction ::
  Action
newAction :: Action
newAction =
  Action' :: Maybe (HashMap Text ActionParameter)
-> Maybe (HashMap Text ActionTarget)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Action
Action'
    { $sel:parameters:Action' :: Maybe (HashMap Text ActionParameter)
parameters = Maybe (HashMap Text ActionParameter)
forall a. Maybe a
Prelude.Nothing,
      $sel:targets:Action' :: Maybe (HashMap Text ActionTarget)
targets = Maybe (HashMap Text ActionTarget)
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Action' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Action' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:Action' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

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

-- | The tags for the action.
action_tags :: Lens.Lens' Action (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
action_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Action -> f Action
action_tags = (Action -> Maybe (HashMap Text Text))
-> (Action -> Maybe (HashMap Text Text) -> Action)
-> Lens
     Action
     Action
     (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 (\Action' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:Action' :: Action -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: Action
s@Action' {} Maybe (HashMap Text Text)
a -> Action
s {$sel:tags:Action' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: Action) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> Action -> f Action)
-> ((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)))
-> Action
-> f Action
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

instance Core.FromJSON Action where
  parseJSON :: Value -> Parser Action
parseJSON =
    String -> (Object -> Parser Action) -> Value -> Parser Action
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Action"
      ( \Object
x ->
          Maybe (HashMap Text ActionParameter)
-> Maybe (HashMap Text ActionTarget)
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Action
Action'
            (Maybe (HashMap Text ActionParameter)
 -> Maybe (HashMap Text ActionTarget)
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Action)
-> Parser (Maybe (HashMap Text ActionParameter))
-> Parser
     (Maybe (HashMap Text ActionTarget)
      -> Maybe Text -> Maybe Text -> Maybe (HashMap Text Text) -> Action)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text ActionParameter)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"parameters" Parser (Maybe (Maybe (HashMap Text ActionParameter)))
-> Maybe (HashMap Text ActionParameter)
-> Parser (Maybe (HashMap Text ActionParameter))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text ActionParameter)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe (HashMap Text ActionTarget)
   -> Maybe Text -> Maybe Text -> Maybe (HashMap Text Text) -> Action)
-> Parser (Maybe (HashMap Text ActionTarget))
-> Parser
     (Maybe Text -> Maybe Text -> Maybe (HashMap Text Text) -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text ActionTarget)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targets" Parser (Maybe (Maybe (HashMap Text ActionTarget)))
-> Maybe (HashMap Text ActionTarget)
-> Parser (Maybe (HashMap Text ActionTarget))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text ActionTarget)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text -> Maybe Text -> Maybe (HashMap Text Text) -> Action)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe (HashMap Text Text) -> Action)
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
"id")
            Parser (Maybe Text -> Maybe (HashMap Text Text) -> Action)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> Action)
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")
            Parser (Maybe (HashMap Text Text) -> Action)
-> Parser (Maybe (HashMap Text Text)) -> Parser Action
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
"tags" 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)
      )

instance Prelude.Hashable Action

instance Prelude.NFData Action