{-# 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.WAFRegional.Types.WebACLUpdate
-- 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.WAFRegional.Types.WebACLUpdate 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
import Amazonka.WAFRegional.Types.ActivatedRule
import Amazonka.WAFRegional.Types.ChangeAction

-- | 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.
--
-- Specifies whether to insert a @Rule@ into or delete a @Rule@ from a
-- @WebACL@.
--
-- /See:/ 'newWebACLUpdate' smart constructor.
data WebACLUpdate = WebACLUpdate'
  { -- | Specifies whether to insert a @Rule@ into or delete a @Rule@ from a
    -- @WebACL@.
    WebACLUpdate -> ChangeAction
action :: ChangeAction,
    -- | The @ActivatedRule@ object in an UpdateWebACL request specifies a @Rule@
    -- that you want to insert or delete, the priority of the @Rule@ in the
    -- @WebACL@, and the action that you want AWS WAF to take when a web
    -- request matches the @Rule@ (@ALLOW@, @BLOCK@, or @COUNT@).
    WebACLUpdate -> ActivatedRule
activatedRule :: ActivatedRule
  }
  deriving (WebACLUpdate -> WebACLUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WebACLUpdate -> WebACLUpdate -> Bool
$c/= :: WebACLUpdate -> WebACLUpdate -> Bool
== :: WebACLUpdate -> WebACLUpdate -> Bool
$c== :: WebACLUpdate -> WebACLUpdate -> Bool
Prelude.Eq, ReadPrec [WebACLUpdate]
ReadPrec WebACLUpdate
Int -> ReadS WebACLUpdate
ReadS [WebACLUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WebACLUpdate]
$creadListPrec :: ReadPrec [WebACLUpdate]
readPrec :: ReadPrec WebACLUpdate
$creadPrec :: ReadPrec WebACLUpdate
readList :: ReadS [WebACLUpdate]
$creadList :: ReadS [WebACLUpdate]
readsPrec :: Int -> ReadS WebACLUpdate
$creadsPrec :: Int -> ReadS WebACLUpdate
Prelude.Read, Int -> WebACLUpdate -> ShowS
[WebACLUpdate] -> ShowS
WebACLUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WebACLUpdate] -> ShowS
$cshowList :: [WebACLUpdate] -> ShowS
show :: WebACLUpdate -> String
$cshow :: WebACLUpdate -> String
showsPrec :: Int -> WebACLUpdate -> ShowS
$cshowsPrec :: Int -> WebACLUpdate -> ShowS
Prelude.Show, forall x. Rep WebACLUpdate x -> WebACLUpdate
forall x. WebACLUpdate -> Rep WebACLUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WebACLUpdate x -> WebACLUpdate
$cfrom :: forall x. WebACLUpdate -> Rep WebACLUpdate x
Prelude.Generic)

-- |
-- Create a value of 'WebACLUpdate' 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:
--
-- 'action', 'webACLUpdate_action' - Specifies whether to insert a @Rule@ into or delete a @Rule@ from a
-- @WebACL@.
--
-- 'activatedRule', 'webACLUpdate_activatedRule' - The @ActivatedRule@ object in an UpdateWebACL request specifies a @Rule@
-- that you want to insert or delete, the priority of the @Rule@ in the
-- @WebACL@, and the action that you want AWS WAF to take when a web
-- request matches the @Rule@ (@ALLOW@, @BLOCK@, or @COUNT@).
newWebACLUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'activatedRule'
  ActivatedRule ->
  WebACLUpdate
newWebACLUpdate :: ChangeAction -> ActivatedRule -> WebACLUpdate
newWebACLUpdate ChangeAction
pAction_ ActivatedRule
pActivatedRule_ =
  WebACLUpdate'
    { $sel:action:WebACLUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:activatedRule:WebACLUpdate' :: ActivatedRule
activatedRule = ActivatedRule
pActivatedRule_
    }

-- | Specifies whether to insert a @Rule@ into or delete a @Rule@ from a
-- @WebACL@.
webACLUpdate_action :: Lens.Lens' WebACLUpdate ChangeAction
webACLUpdate_action :: Lens' WebACLUpdate ChangeAction
webACLUpdate_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WebACLUpdate' {ChangeAction
action :: ChangeAction
$sel:action:WebACLUpdate' :: WebACLUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: WebACLUpdate
s@WebACLUpdate' {} ChangeAction
a -> WebACLUpdate
s {$sel:action:WebACLUpdate' :: ChangeAction
action = ChangeAction
a} :: WebACLUpdate)

-- | The @ActivatedRule@ object in an UpdateWebACL request specifies a @Rule@
-- that you want to insert or delete, the priority of the @Rule@ in the
-- @WebACL@, and the action that you want AWS WAF to take when a web
-- request matches the @Rule@ (@ALLOW@, @BLOCK@, or @COUNT@).
webACLUpdate_activatedRule :: Lens.Lens' WebACLUpdate ActivatedRule
webACLUpdate_activatedRule :: Lens' WebACLUpdate ActivatedRule
webACLUpdate_activatedRule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WebACLUpdate' {ActivatedRule
activatedRule :: ActivatedRule
$sel:activatedRule:WebACLUpdate' :: WebACLUpdate -> ActivatedRule
activatedRule} -> ActivatedRule
activatedRule) (\s :: WebACLUpdate
s@WebACLUpdate' {} ActivatedRule
a -> WebACLUpdate
s {$sel:activatedRule:WebACLUpdate' :: ActivatedRule
activatedRule = ActivatedRule
a} :: WebACLUpdate)

instance Prelude.Hashable WebACLUpdate where
  hashWithSalt :: Int -> WebACLUpdate -> Int
hashWithSalt Int
_salt WebACLUpdate' {ChangeAction
ActivatedRule
activatedRule :: ActivatedRule
action :: ChangeAction
$sel:activatedRule:WebACLUpdate' :: WebACLUpdate -> ActivatedRule
$sel:action:WebACLUpdate' :: WebACLUpdate -> ChangeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChangeAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ActivatedRule
activatedRule

instance Prelude.NFData WebACLUpdate where
  rnf :: WebACLUpdate -> ()
rnf WebACLUpdate' {ChangeAction
ActivatedRule
activatedRule :: ActivatedRule
action :: ChangeAction
$sel:activatedRule:WebACLUpdate' :: WebACLUpdate -> ActivatedRule
$sel:action:WebACLUpdate' :: WebACLUpdate -> ChangeAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ChangeAction
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ActivatedRule
activatedRule

instance Data.ToJSON WebACLUpdate where
  toJSON :: WebACLUpdate -> Value
toJSON WebACLUpdate' {ChangeAction
ActivatedRule
activatedRule :: ActivatedRule
action :: ChangeAction
$sel:activatedRule:WebACLUpdate' :: WebACLUpdate -> ActivatedRule
$sel:action:WebACLUpdate' :: WebACLUpdate -> ChangeAction
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Action" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ChangeAction
action),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ActivatedRule" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ActivatedRule
activatedRule)
          ]
      )