{-# 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.SizeConstraintSetUpdate
-- 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.SizeConstraintSetUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAF.Types.ChangeAction
import Amazonka.WAF.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
(SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool)
-> (SizeConstraintSetUpdate -> SizeConstraintSetUpdate -> Bool)
-> Eq SizeConstraintSetUpdate
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]
(Int -> ReadS SizeConstraintSetUpdate)
-> ReadS [SizeConstraintSetUpdate]
-> ReadPrec SizeConstraintSetUpdate
-> ReadPrec [SizeConstraintSetUpdate]
-> Read 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
(Int -> SizeConstraintSetUpdate -> ShowS)
-> (SizeConstraintSetUpdate -> String)
-> ([SizeConstraintSetUpdate] -> ShowS)
-> Show SizeConstraintSetUpdate
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.
 SizeConstraintSetUpdate -> Rep SizeConstraintSetUpdate x)
-> (forall x.
    Rep SizeConstraintSetUpdate x -> SizeConstraintSetUpdate)
-> Generic SizeConstraintSetUpdate
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' :: ChangeAction -> SizeConstraint -> SizeConstraintSetUpdate
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 :: (ChangeAction -> f ChangeAction)
-> SizeConstraintSetUpdate -> f SizeConstraintSetUpdate
sizeConstraintSetUpdate_action = (SizeConstraintSetUpdate -> ChangeAction)
-> (SizeConstraintSetUpdate
    -> ChangeAction -> SizeConstraintSetUpdate)
-> Lens
     SizeConstraintSetUpdate
     SizeConstraintSetUpdate
     ChangeAction
     ChangeAction
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 :: (SizeConstraint -> f SizeConstraint)
-> SizeConstraintSetUpdate -> f SizeConstraintSetUpdate
sizeConstraintSetUpdate_sizeConstraint = (SizeConstraintSetUpdate -> SizeConstraint)
-> (SizeConstraintSetUpdate
    -> SizeConstraint -> SizeConstraintSetUpdate)
-> Lens
     SizeConstraintSetUpdate
     SizeConstraintSetUpdate
     SizeConstraint
     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

instance Prelude.NFData SizeConstraintSetUpdate

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> ChangeAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ChangeAction
action),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SizeConstraint" Text -> SizeConstraint -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SizeConstraint
sizeConstraint)
          ]
      )