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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.WafOverrideActionType

-- | This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- The action to take if any rule within the @RuleGroup@ matches a request.
--
-- /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 will take place.
    WafOverrideAction -> WafOverrideActionType
type' :: WafOverrideActionType
  }
  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 will take place.
newWafOverrideAction ::
  -- | 'type''
  WafOverrideActionType ->
  WafOverrideAction
newWafOverrideAction :: WafOverrideActionType -> WafOverrideAction
newWafOverrideAction WafOverrideActionType
pType_ =
  WafOverrideAction' :: WafOverrideActionType -> WafOverrideAction
WafOverrideAction' {$sel:type':WafOverrideAction' :: WafOverrideActionType
type' = WafOverrideActionType
pType_}

-- | @COUNT@ overrides the action specified by the individual rule within a
-- @RuleGroup@ . If set to @NONE@, the rule\'s action will take place.
wafOverrideAction_type :: Lens.Lens' WafOverrideAction WafOverrideActionType
wafOverrideAction_type :: (WafOverrideActionType -> f WafOverrideActionType)
-> WafOverrideAction -> f WafOverrideAction
wafOverrideAction_type = (WafOverrideAction -> WafOverrideActionType)
-> (WafOverrideAction
    -> WafOverrideActionType -> WafOverrideAction)
-> Lens
     WafOverrideAction
     WafOverrideAction
     WafOverrideActionType
     WafOverrideActionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WafOverrideAction' {WafOverrideActionType
type' :: WafOverrideActionType
$sel:type':WafOverrideAction' :: WafOverrideAction -> WafOverrideActionType
type'} -> WafOverrideActionType
type') (\s :: WafOverrideAction
s@WafOverrideAction' {} WafOverrideActionType
a -> WafOverrideAction
s {$sel:type':WafOverrideAction' :: WafOverrideActionType
type' = WafOverrideActionType
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 ->
          WafOverrideActionType -> WafOverrideAction
WafOverrideAction' (WafOverrideActionType -> WafOverrideAction)
-> Parser WafOverrideActionType -> Parser WafOverrideAction
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser WafOverrideActionType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable WafOverrideAction

instance Prelude.NFData WafOverrideAction

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