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

-- | 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 the part of a web request that you want to inspect the size of
-- and indicates whether you want to add the specification to a
-- SizeConstraintSet or delete it from a @SizeConstraintSet@.
--
-- /See:/ 'newSizeConstraintSetUpdate' smart constructor.
data SizeConstraintSetUpdate = SizeConstraintSetUpdate'
  { -- | Specify @INSERT@ to add a SizeConstraintSetUpdate to a
    -- SizeConstraintSet. Use @DELETE@ to remove a @SizeConstraintSetUpdate@
    -- from a @SizeConstraintSet@.
    SizeConstraintSetUpdate -> ChangeAction
action :: ChangeAction,
    -- | Specifies a constraint on the size of a part of the web request. AWS WAF
    -- uses the @Size@, @ComparisonOperator@, and @FieldToMatch@ to build an
    -- expression in the form of \"@Size@ @ComparisonOperator@ size in bytes of
    -- @FieldToMatch@\". If that expression is true, the @SizeConstraint@ is
    -- considered to match.
    SizeConstraintSetUpdate -> SizeConstraint
sizeConstraint :: SizeConstraint
  }
  deriving (SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool
$c/= :: SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool
== :: SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool
$c== :: SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool
Prelude.Eq, ReadPrec [SizeConstraintSetUpdate]
ReadPrec SizeConstraintSetUpdate
Int -> ReadS SizeConstraintSetUpdate
ReadS [SizeConstraintSetUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SizeConstraintSetUpdate]
$creadListPrec :: ReadPrec [SizeConstraintSetUpdate]
readPrec :: ReadPrec SizeConstraintSetUpdate
$creadPrec :: ReadPrec SizeConstraintSetUpdate
readList :: ReadS [SizeConstraintSetUpdate]
$creadList :: ReadS [SizeConstraintSetUpdate]
readsPrec :: Int -> ReadS SizeConstraintSetUpdate
$creadsPrec :: Int -> ReadS SizeConstraintSetUpdate
Prelude.Read, Int -> SizeConstraintSetUpdate -> ShowS
[SizeConstraintSetUpdate] -> ShowS
SizeConstraintSetUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SizeConstraintSetUpdate] -> ShowS
$cshowList :: [SizeConstraintSetUpdate] -> ShowS
show :: SizeConstraintSetUpdate -> String
$cshow :: SizeConstraintSetUpdate -> String
showsPrec :: Int -> SizeConstraintSetUpdate -> ShowS
$cshowsPrec :: Int -> SizeConstraintSetUpdate -> ShowS
Prelude.Show, forall x. Rep SizeConstraintSetUpdate x -> SizeConstraintSetUpdate
forall x. SizeConstraintSetUpdate -> Rep SizeConstraintSetUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SizeConstraintSetUpdate x -> SizeConstraintSetUpdate
$cfrom :: forall x. SizeConstraintSetUpdate -> Rep SizeConstraintSetUpdate x
Prelude.Generic)

-- |
-- Create a value of 'SizeConstraintSetUpdate' 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', 'sizeConstraintSetUpdate_action' - Specify @INSERT@ to add a SizeConstraintSetUpdate to a
-- SizeConstraintSet. Use @DELETE@ to remove a @SizeConstraintSetUpdate@
-- from a @SizeConstraintSet@.
--
-- 'sizeConstraint', 'sizeConstraintSetUpdate_sizeConstraint' - Specifies a constraint on the size of a part of the web request. AWS WAF
-- uses the @Size@, @ComparisonOperator@, and @FieldToMatch@ to build an
-- expression in the form of \"@Size@ @ComparisonOperator@ size in bytes of
-- @FieldToMatch@\". If that expression is true, the @SizeConstraint@ is
-- considered to match.
newSizeConstraintSetUpdate ::
  -- | 'action'
  ChangeAction ->
  -- | 'sizeConstraint'
  SizeConstraint ->
  SizeConstraintSetUpdate
newSizeConstraintSetUpdate :: ChangeAction -> SizeConstraint -> SizeConstraintSetUpdate
newSizeConstraintSetUpdate ChangeAction
pAction_ SizeConstraint
pSizeConstraint_ =
  SizeConstraintSetUpdate'
    { $sel:action:SizeConstraintSetUpdate' :: ChangeAction
action = ChangeAction
pAction_,
      $sel:sizeConstraint:SizeConstraintSetUpdate' :: SizeConstraint
sizeConstraint = SizeConstraint
pSizeConstraint_
    }

-- | Specify @INSERT@ to add a SizeConstraintSetUpdate to a
-- SizeConstraintSet. Use @DELETE@ to remove a @SizeConstraintSetUpdate@
-- from a @SizeConstraintSet@.
sizeConstraintSetUpdate_action :: Lens.Lens' SizeConstraintSetUpdate ChangeAction
sizeConstraintSetUpdate_action :: Lens' SizeConstraintSetUpdate ChangeAction
sizeConstraintSetUpdate_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraintSetUpdate' {ChangeAction
action :: ChangeAction
$sel:action:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> ChangeAction
action} -> ChangeAction
action) (\s :: SizeConstraintSetUpdate
s@SizeConstraintSetUpdate' {} ChangeAction
a -> SizeConstraintSetUpdate
s {$sel:action:SizeConstraintSetUpdate' :: ChangeAction
action = ChangeAction
a} :: SizeConstraintSetUpdate)

-- | Specifies a constraint on the size of a part of the web request. AWS WAF
-- uses the @Size@, @ComparisonOperator@, and @FieldToMatch@ to build an
-- expression in the form of \"@Size@ @ComparisonOperator@ size in bytes of
-- @FieldToMatch@\". If that expression is true, the @SizeConstraint@ is
-- considered to match.
sizeConstraintSetUpdate_sizeConstraint :: Lens.Lens' SizeConstraintSetUpdate SizeConstraint
sizeConstraintSetUpdate_sizeConstraint :: Lens' SizeConstraintSetUpdate SizeConstraint
sizeConstraintSetUpdate_sizeConstraint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraintSetUpdate' {SizeConstraint
sizeConstraint :: SizeConstraint
$sel:sizeConstraint:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> SizeConstraint
sizeConstraint} -> SizeConstraint
sizeConstraint) (\s :: SizeConstraintSetUpdate
s@SizeConstraintSetUpdate' {} SizeConstraint
a -> SizeConstraintSetUpdate
s {$sel:sizeConstraint:SizeConstraintSetUpdate' :: SizeConstraint
sizeConstraint = SizeConstraint
a} :: SizeConstraintSetUpdate)

instance Prelude.Hashable SizeConstraintSetUpdate where
  hashWithSalt :: Int -> SizeConstraintSetUpdate -> Int
hashWithSalt Int
_salt SizeConstraintSetUpdate' {ChangeAction
SizeConstraint
sizeConstraint :: SizeConstraint
action :: ChangeAction
$sel:sizeConstraint:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> SizeConstraint
$sel:action:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> ChangeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChangeAction
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SizeConstraint
sizeConstraint

instance Prelude.NFData SizeConstraintSetUpdate where
  rnf :: SizeConstraintSetUpdate -> ()
rnf SizeConstraintSetUpdate' {ChangeAction
SizeConstraint
sizeConstraint :: SizeConstraint
action :: ChangeAction
$sel:sizeConstraint:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> SizeConstraint
$sel:action:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> 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 SizeConstraint
sizeConstraint

instance Data.ToJSON SizeConstraintSetUpdate where
  toJSON :: SizeConstraintSetUpdate -> Value
toJSON SizeConstraintSetUpdate' {ChangeAction
SizeConstraint
sizeConstraint :: SizeConstraint
action :: ChangeAction
$sel:sizeConstraint:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> SizeConstraint
$sel:action:SizeConstraintSetUpdate' :: SizeConstraintSetUpdate -> 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
"SizeConstraint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SizeConstraint
sizeConstraint)
          ]
      )