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

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.MitigationActionParams
import qualified Amazonka.Lens as Lens
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 user-friendly name for the mitigation action.
    MitigationAction -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for the mitigation action.
    MitigationAction -> Maybe Text
id :: 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
(MitigationAction -> MitigationAction -> Bool)
-> (MitigationAction -> MitigationAction -> Bool)
-> Eq MitigationAction
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]
(Int -> ReadS MitigationAction)
-> ReadS [MitigationAction]
-> ReadPrec MitigationAction
-> ReadPrec [MitigationAction]
-> Read 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
(Int -> MitigationAction -> ShowS)
-> (MitigationAction -> String)
-> ([MitigationAction] -> ShowS)
-> Show MitigationAction
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. MitigationAction -> Rep MitigationAction x)
-> (forall x. Rep MitigationAction x -> MitigationAction)
-> Generic MitigationAction
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.
--
-- 'name', 'mitigationAction_name' - A user-friendly name for the mitigation action.
--
-- 'id', 'mitigationAction_id' - A unique identifier for the mitigation action.
--
-- 'roleArn', 'mitigationAction_roleArn' - The IAM role ARN used to apply this mitigation action.
newMitigationAction ::
  MitigationAction
newMitigationAction :: MitigationAction
newMitigationAction =
  MitigationAction' :: Maybe MitigationActionParams
-> Maybe Text -> Maybe Text -> Maybe Text -> MitigationAction
MitigationAction'
    { $sel:actionParams:MitigationAction' :: Maybe MitigationActionParams
actionParams = Maybe MitigationActionParams
forall a. Maybe a
Prelude.Nothing,
      $sel:name:MitigationAction' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:MitigationAction' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:MitigationAction' :: Maybe Text
roleArn = Maybe Text
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 :: (Maybe MitigationActionParams -> f (Maybe MitigationActionParams))
-> MitigationAction -> f MitigationAction
mitigationAction_actionParams = (MitigationAction -> Maybe MitigationActionParams)
-> (MitigationAction
    -> Maybe MitigationActionParams -> MitigationAction)
-> Lens
     MitigationAction
     MitigationAction
     (Maybe MitigationActionParams)
     (Maybe MitigationActionParams)
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 user-friendly name for the mitigation action.
mitigationAction_name :: Lens.Lens' MitigationAction (Prelude.Maybe Prelude.Text)
mitigationAction_name :: (Maybe Text -> f (Maybe Text))
-> MitigationAction -> f MitigationAction
mitigationAction_name = (MitigationAction -> Maybe Text)
-> (MitigationAction -> Maybe Text -> MitigationAction)
-> Lens MitigationAction MitigationAction (Maybe Text) (Maybe Text)
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)

-- | A unique identifier for the mitigation action.
mitigationAction_id :: Lens.Lens' MitigationAction (Prelude.Maybe Prelude.Text)
mitigationAction_id :: (Maybe Text -> f (Maybe Text))
-> MitigationAction -> f MitigationAction
mitigationAction_id = (MitigationAction -> Maybe Text)
-> (MitigationAction -> Maybe Text -> MitigationAction)
-> Lens MitigationAction MitigationAction (Maybe Text) (Maybe Text)
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)

-- | The IAM role ARN used to apply this mitigation action.
mitigationAction_roleArn :: Lens.Lens' MitigationAction (Prelude.Maybe Prelude.Text)
mitigationAction_roleArn :: (Maybe Text -> f (Maybe Text))
-> MitigationAction -> f MitigationAction
mitigationAction_roleArn = (MitigationAction -> Maybe Text)
-> (MitigationAction -> Maybe Text -> MitigationAction)
-> Lens MitigationAction MitigationAction (Maybe Text) (Maybe Text)
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 Core.FromJSON MitigationAction where
  parseJSON :: Value -> Parser MitigationAction
parseJSON =
    String
-> (Object -> Parser MitigationAction)
-> Value
-> Parser MitigationAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MitigationAction"
      ( \Object
x ->
          Maybe MitigationActionParams
-> Maybe Text -> Maybe Text -> Maybe Text -> MitigationAction
MitigationAction'
            (Maybe MitigationActionParams
 -> Maybe Text -> Maybe Text -> Maybe Text -> MitigationAction)
-> Parser (Maybe MitigationActionParams)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> MitigationAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MitigationActionParams)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"actionParams")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> MitigationAction)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> MitigationAction)
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
"name")
            Parser (Maybe Text -> Maybe Text -> MitigationAction)
-> Parser (Maybe Text) -> Parser (Maybe Text -> MitigationAction)
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 -> MitigationAction)
-> Parser (Maybe Text) -> Parser MitigationAction
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
"roleArn")
      )

instance Prelude.Hashable MitigationAction

instance Prelude.NFData MitigationAction