{-# 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.SecurityHub.Types.WafOverrideAction
-- 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.SecurityHub.Types.WafOverrideAction where

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

-- | Details about an override action for a rule.
--
-- /See:/ 'newWafOverrideAction' smart constructor.
data WafOverrideAction = WafOverrideAction'
  { -- | @COUNT@ overrides the action specified by the individual rule within a
    -- @RuleGroup@ .
    --
    -- If set to @NONE@, the rule\'s action takes place.
    WafOverrideAction -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (WafOverrideAction -> WafOverrideAction -> Bool
(WafOverrideAction -> WafOverrideAction -> Bool)
-> (WafOverrideAction -> WafOverrideAction -> Bool)
-> Eq WafOverrideAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WafOverrideAction -> WafOverrideAction -> Bool
$c/= :: WafOverrideAction -> WafOverrideAction -> Bool
== :: WafOverrideAction -> WafOverrideAction -> Bool
$c== :: WafOverrideAction -> WafOverrideAction -> Bool
Prelude.Eq, ReadPrec [WafOverrideAction]
ReadPrec WafOverrideAction
Int -> ReadS WafOverrideAction
ReadS [WafOverrideAction]
(Int -> ReadS WafOverrideAction)
-> ReadS [WafOverrideAction]
-> ReadPrec WafOverrideAction
-> ReadPrec [WafOverrideAction]
-> Read WafOverrideAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WafOverrideAction]
$creadListPrec :: ReadPrec [WafOverrideAction]
readPrec :: ReadPrec WafOverrideAction
$creadPrec :: ReadPrec WafOverrideAction
readList :: ReadS [WafOverrideAction]
$creadList :: ReadS [WafOverrideAction]
readsPrec :: Int -> ReadS WafOverrideAction
$creadsPrec :: Int -> ReadS WafOverrideAction
Prelude.Read, Int -> WafOverrideAction -> ShowS
[WafOverrideAction] -> ShowS
WafOverrideAction -> String
(Int -> WafOverrideAction -> ShowS)
-> (WafOverrideAction -> String)
-> ([WafOverrideAction] -> ShowS)
-> Show WafOverrideAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WafOverrideAction] -> ShowS
$cshowList :: [WafOverrideAction] -> ShowS
show :: WafOverrideAction -> String
$cshow :: WafOverrideAction -> String
showsPrec :: Int -> WafOverrideAction -> ShowS
$cshowsPrec :: Int -> WafOverrideAction -> ShowS
Prelude.Show, (forall x. WafOverrideAction -> Rep WafOverrideAction x)
-> (forall x. Rep WafOverrideAction x -> WafOverrideAction)
-> Generic WafOverrideAction
forall x. Rep WafOverrideAction x -> WafOverrideAction
forall x. WafOverrideAction -> Rep WafOverrideAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WafOverrideAction x -> WafOverrideAction
$cfrom :: forall x. WafOverrideAction -> Rep WafOverrideAction x
Prelude.Generic)

-- |
-- Create a value of 'WafOverrideAction' 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:
--
-- 'type'', 'wafOverrideAction_type' - @COUNT@ overrides the action specified by the individual rule within a
-- @RuleGroup@ .
--
-- If set to @NONE@, the rule\'s action takes place.
newWafOverrideAction ::
  WafOverrideAction
newWafOverrideAction :: WafOverrideAction
newWafOverrideAction =
  WafOverrideAction' :: Maybe Text -> WafOverrideAction
WafOverrideAction' {$sel:type':WafOverrideAction' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | @COUNT@ overrides the action specified by the individual rule within a
-- @RuleGroup@ .
--
-- If set to @NONE@, the rule\'s action takes place.
wafOverrideAction_type :: Lens.Lens' WafOverrideAction (Prelude.Maybe Prelude.Text)
wafOverrideAction_type :: (Maybe Text -> f (Maybe Text))
-> WafOverrideAction -> f WafOverrideAction
wafOverrideAction_type = (WafOverrideAction -> Maybe Text)
-> (WafOverrideAction -> Maybe Text -> WafOverrideAction)
-> Lens
     WafOverrideAction WafOverrideAction (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WafOverrideAction' {Maybe Text
type' :: Maybe Text
$sel:type':WafOverrideAction' :: WafOverrideAction -> Maybe Text
type'} -> Maybe Text
type') (\s :: WafOverrideAction
s@WafOverrideAction' {} Maybe Text
a -> WafOverrideAction
s {$sel:type':WafOverrideAction' :: Maybe Text
type' = Maybe Text
a} :: WafOverrideAction)

instance Core.FromJSON WafOverrideAction where
  parseJSON :: Value -> Parser WafOverrideAction
parseJSON =
    String
-> (Object -> Parser WafOverrideAction)
-> Value
-> Parser WafOverrideAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WafOverrideAction"
      ( \Object
x ->
          Maybe Text -> WafOverrideAction
WafOverrideAction' (Maybe Text -> WafOverrideAction)
-> Parser (Maybe Text) -> Parser WafOverrideAction
forall (f :: * -> *) a b. Functor 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
"Type")
      )

instance Prelude.Hashable WafOverrideAction

instance Prelude.NFData WafOverrideAction

instance Core.ToJSON WafOverrideAction where
  toJSON :: WafOverrideAction -> Value
toJSON WafOverrideAction' {Maybe Text
type' :: Maybe Text
$sel:type':WafOverrideAction' :: WafOverrideAction -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
type']
      )