{-# 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.Shield.Types.Mitigation
-- 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.Shield.Types.Mitigation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The mitigation applied to a DDoS attack.
--
-- /See:/ 'newMitigation' smart constructor.
data Mitigation = Mitigation'
  { -- | The name of the mitigation taken for this attack.
    Mitigation -> Maybe Text
mitigationName :: Prelude.Maybe Prelude.Text
  }
  deriving (Mitigation -> Mitigation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Mitigation -> Mitigation -> Bool
$c/= :: Mitigation -> Mitigation -> Bool
== :: Mitigation -> Mitigation -> Bool
$c== :: Mitigation -> Mitigation -> Bool
Prelude.Eq, ReadPrec [Mitigation]
ReadPrec Mitigation
Int -> ReadS Mitigation
ReadS [Mitigation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Mitigation]
$creadListPrec :: ReadPrec [Mitigation]
readPrec :: ReadPrec Mitigation
$creadPrec :: ReadPrec Mitigation
readList :: ReadS [Mitigation]
$creadList :: ReadS [Mitigation]
readsPrec :: Int -> ReadS Mitigation
$creadsPrec :: Int -> ReadS Mitigation
Prelude.Read, Int -> Mitigation -> ShowS
[Mitigation] -> ShowS
Mitigation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Mitigation] -> ShowS
$cshowList :: [Mitigation] -> ShowS
show :: Mitigation -> String
$cshow :: Mitigation -> String
showsPrec :: Int -> Mitigation -> ShowS
$cshowsPrec :: Int -> Mitigation -> ShowS
Prelude.Show, forall x. Rep Mitigation x -> Mitigation
forall x. Mitigation -> Rep Mitigation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Mitigation x -> Mitigation
$cfrom :: forall x. Mitigation -> Rep Mitigation x
Prelude.Generic)

-- |
-- Create a value of 'Mitigation' 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:
--
-- 'mitigationName', 'mitigation_mitigationName' - The name of the mitigation taken for this attack.
newMitigation ::
  Mitigation
newMitigation :: Mitigation
newMitigation =
  Mitigation' {$sel:mitigationName:Mitigation' :: Maybe Text
mitigationName = forall a. Maybe a
Prelude.Nothing}

-- | The name of the mitigation taken for this attack.
mitigation_mitigationName :: Lens.Lens' Mitigation (Prelude.Maybe Prelude.Text)
mitigation_mitigationName :: Lens' Mitigation (Maybe Text)
mitigation_mitigationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Mitigation' {Maybe Text
mitigationName :: Maybe Text
$sel:mitigationName:Mitigation' :: Mitigation -> Maybe Text
mitigationName} -> Maybe Text
mitigationName) (\s :: Mitigation
s@Mitigation' {} Maybe Text
a -> Mitigation
s {$sel:mitigationName:Mitigation' :: Maybe Text
mitigationName = Maybe Text
a} :: Mitigation)

instance Data.FromJSON Mitigation where
  parseJSON :: Value -> Parser Mitigation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Mitigation"
      ( \Object
x ->
          Maybe Text -> Mitigation
Mitigation'
            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
"MitigationName")
      )

instance Prelude.Hashable Mitigation where
  hashWithSalt :: Int -> Mitigation -> Int
hashWithSalt Int
_salt Mitigation' {Maybe Text
mitigationName :: Maybe Text
$sel:mitigationName:Mitigation' :: Mitigation -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
mitigationName

instance Prelude.NFData Mitigation where
  rnf :: Mitigation -> ()
rnf Mitigation' {Maybe Text
mitigationName :: Maybe Text
$sel:mitigationName:Mitigation' :: Mitigation -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
mitigationName