{-# 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.IoT.Types.MitigationAction
-- 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.IoT.Types.MitigationAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.MitigationActionParams
import qualified Amazonka.Prelude as Prelude

-- | Describes which changes should be applied as part of a mitigation
-- action.
--
-- /See:/ 'newMitigationAction' smart constructor.
data MitigationAction = MitigationAction'
  { -- | The set of parameters for this mitigation action. The parameters vary,
    -- depending on the kind of action you apply.
    MitigationAction -> Maybe MitigationActionParams
actionParams :: Prelude.Maybe MitigationActionParams,
    -- | A unique identifier for the mitigation action.
    MitigationAction -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A user-friendly name for the mitigation action.
    MitigationAction -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The IAM role ARN used to apply this mitigation action.
    MitigationAction -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (MitigationAction -> MitigationAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MitigationAction -> MitigationAction -> Bool
$c/= :: MitigationAction -> MitigationAction -> Bool
== :: MitigationAction -> MitigationAction -> Bool
$c== :: MitigationAction -> MitigationAction -> Bool
Prelude.Eq, ReadPrec [MitigationAction]
ReadPrec MitigationAction
Int -> ReadS MitigationAction
ReadS [MitigationAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MitigationAction]
$creadListPrec :: ReadPrec [MitigationAction]
readPrec :: ReadPrec MitigationAction
$creadPrec :: ReadPrec MitigationAction
readList :: ReadS [MitigationAction]
$creadList :: ReadS [MitigationAction]
readsPrec :: Int -> ReadS MitigationAction
$creadsPrec :: Int -> ReadS MitigationAction
Prelude.Read, Int -> MitigationAction -> ShowS
[MitigationAction] -> ShowS
MitigationAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MitigationAction] -> ShowS
$cshowList :: [MitigationAction] -> ShowS
show :: MitigationAction -> String
$cshow :: MitigationAction -> String
showsPrec :: Int -> MitigationAction -> ShowS
$cshowsPrec :: Int -> MitigationAction -> ShowS
Prelude.Show, forall x. Rep MitigationAction x -> MitigationAction
forall x. MitigationAction -> Rep MitigationAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MitigationAction x -> MitigationAction
$cfrom :: forall x. MitigationAction -> Rep MitigationAction x
Prelude.Generic)

-- |
-- Create a value of 'MitigationAction' 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:
--
-- 'actionParams', 'mitigationAction_actionParams' - The set of parameters for this mitigation action. The parameters vary,
-- depending on the kind of action you apply.
--
-- 'id', 'mitigationAction_id' - A unique identifier for the mitigation action.
--
-- 'name', 'mitigationAction_name' - A user-friendly name for the mitigation action.
--
-- 'roleArn', 'mitigationAction_roleArn' - The IAM role ARN used to apply this mitigation action.
newMitigationAction ::
  MitigationAction
newMitigationAction :: MitigationAction
newMitigationAction =
  MitigationAction'
    { $sel:actionParams:MitigationAction' :: Maybe MitigationActionParams
actionParams = forall a. Maybe a
Prelude.Nothing,
      $sel:id:MitigationAction' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:name:MitigationAction' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:MitigationAction' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing
    }

-- | The set of parameters for this mitigation action. The parameters vary,
-- depending on the kind of action you apply.
mitigationAction_actionParams :: Lens.Lens' MitigationAction (Prelude.Maybe MitigationActionParams)
mitigationAction_actionParams :: Lens' MitigationAction (Maybe MitigationActionParams)
mitigationAction_actionParams = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MitigationAction' {Maybe MitigationActionParams
actionParams :: Maybe MitigationActionParams
$sel:actionParams:MitigationAction' :: MitigationAction -> Maybe MitigationActionParams
actionParams} -> Maybe MitigationActionParams
actionParams) (\s :: MitigationAction
s@MitigationAction' {} Maybe MitigationActionParams
a -> MitigationAction
s {$sel:actionParams:MitigationAction' :: Maybe MitigationActionParams
actionParams = Maybe MitigationActionParams
a} :: MitigationAction)

-- | A unique identifier for the mitigation action.
mitigationAction_id :: Lens.Lens' MitigationAction (Prelude.Maybe Prelude.Text)
mitigationAction_id :: Lens' MitigationAction (Maybe Text)
mitigationAction_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MitigationAction' {Maybe Text
id :: Maybe Text
$sel:id:MitigationAction' :: MitigationAction -> Maybe Text
id} -> Maybe Text
id) (\s :: MitigationAction
s@MitigationAction' {} Maybe Text
a -> MitigationAction
s {$sel:id:MitigationAction' :: Maybe Text
id = Maybe Text
a} :: MitigationAction)

-- | A user-friendly name for the mitigation action.
mitigationAction_name :: Lens.Lens' MitigationAction (Prelude.Maybe Prelude.Text)
mitigationAction_name :: Lens' MitigationAction (Maybe Text)
mitigationAction_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MitigationAction' {Maybe Text
name :: Maybe Text
$sel:name:MitigationAction' :: MitigationAction -> Maybe Text
name} -> Maybe Text
name) (\s :: MitigationAction
s@MitigationAction' {} Maybe Text
a -> MitigationAction
s {$sel:name:MitigationAction' :: Maybe Text
name = Maybe Text
a} :: MitigationAction)

-- | The IAM role ARN used to apply this mitigation action.
mitigationAction_roleArn :: Lens.Lens' MitigationAction (Prelude.Maybe Prelude.Text)
mitigationAction_roleArn :: Lens' MitigationAction (Maybe Text)
mitigationAction_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MitigationAction' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:MitigationAction' :: MitigationAction -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: MitigationAction
s@MitigationAction' {} Maybe Text
a -> MitigationAction
s {$sel:roleArn:MitigationAction' :: Maybe Text
roleArn = Maybe Text
a} :: MitigationAction)

instance Data.FromJSON MitigationAction where
  parseJSON :: Value -> Parser MitigationAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MitigationAction"
      ( \Object
x ->
          Maybe MitigationActionParams
-> Maybe Text -> Maybe Text -> Maybe Text -> MitigationAction
MitigationAction'
            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
"actionParams")
            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
"id")
            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
"name")
            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
"roleArn")
      )

instance Prelude.Hashable MitigationAction where
  hashWithSalt :: Int -> MitigationAction -> Int
hashWithSalt Int
_salt MitigationAction' {Maybe Text
Maybe MitigationActionParams
roleArn :: Maybe Text
name :: Maybe Text
id :: Maybe Text
actionParams :: Maybe MitigationActionParams
$sel:roleArn:MitigationAction' :: MitigationAction -> Maybe Text
$sel:name:MitigationAction' :: MitigationAction -> Maybe Text
$sel:id:MitigationAction' :: MitigationAction -> Maybe Text
$sel:actionParams:MitigationAction' :: MitigationAction -> Maybe MitigationActionParams
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MitigationActionParams
actionParams
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn

instance Prelude.NFData MitigationAction where
  rnf :: MitigationAction -> ()
rnf MitigationAction' {Maybe Text
Maybe MitigationActionParams
roleArn :: Maybe Text
name :: Maybe Text
id :: Maybe Text
actionParams :: Maybe MitigationActionParams
$sel:roleArn:MitigationAction' :: MitigationAction -> Maybe Text
$sel:name:MitigationAction' :: MitigationAction -> Maybe Text
$sel:id:MitigationAction' :: MitigationAction -> Maybe Text
$sel:actionParams:MitigationAction' :: MitigationAction -> Maybe MitigationActionParams
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MitigationActionParams
actionParams
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn