{-# 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.SizeConstraintSet
-- 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.WAFRegional.Types.SizeConstraintSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
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.
--
-- A complex type that contains @SizeConstraint@ objects, which specify the
-- parts of web requests that you want AWS WAF to inspect the size of. If a
-- @SizeConstraintSet@ contains more than one @SizeConstraint@ object, a
-- request only needs to match one constraint to be considered a match.
--
-- /See:/ 'newSizeConstraintSet' smart constructor.
data SizeConstraintSet = SizeConstraintSet'
  { -- | The name, if any, of the @SizeConstraintSet@.
    SizeConstraintSet -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A unique identifier for a @SizeConstraintSet@. You use
    -- @SizeConstraintSetId@ to get information about a @SizeConstraintSet@
    -- (see GetSizeConstraintSet), update a @SizeConstraintSet@ (see
    -- UpdateSizeConstraintSet), insert a @SizeConstraintSet@ into a @Rule@ or
    -- delete one from a @Rule@ (see UpdateRule), and delete a
    -- @SizeConstraintSet@ from AWS WAF (see DeleteSizeConstraintSet).
    --
    -- @SizeConstraintSetId@ is returned by CreateSizeConstraintSet and by
    -- ListSizeConstraintSets.
    SizeConstraintSet -> Text
sizeConstraintSetId :: Prelude.Text,
    -- | Specifies the parts of web requests that you want to inspect the size
    -- of.
    SizeConstraintSet -> [SizeConstraint]
sizeConstraints :: [SizeConstraint]
  }
  deriving (SizeConstraintSet -> SizeConstraintSet -> Bool
(SizeConstraintSet -> SizeConstraintSet -> Bool)
-> (SizeConstraintSet -> SizeConstraintSet -> Bool)
-> Eq SizeConstraintSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SizeConstraintSet -> SizeConstraintSet -> Bool
$c/= :: SizeConstraintSet -> SizeConstraintSet -> Bool
== :: SizeConstraintSet -> SizeConstraintSet -> Bool
$c== :: SizeConstraintSet -> SizeConstraintSet -> Bool
Prelude.Eq, ReadPrec [SizeConstraintSet]
ReadPrec SizeConstraintSet
Int -> ReadS SizeConstraintSet
ReadS [SizeConstraintSet]
(Int -> ReadS SizeConstraintSet)
-> ReadS [SizeConstraintSet]
-> ReadPrec SizeConstraintSet
-> ReadPrec [SizeConstraintSet]
-> Read SizeConstraintSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SizeConstraintSet]
$creadListPrec :: ReadPrec [SizeConstraintSet]
readPrec :: ReadPrec SizeConstraintSet
$creadPrec :: ReadPrec SizeConstraintSet
readList :: ReadS [SizeConstraintSet]
$creadList :: ReadS [SizeConstraintSet]
readsPrec :: Int -> ReadS SizeConstraintSet
$creadsPrec :: Int -> ReadS SizeConstraintSet
Prelude.Read, Int -> SizeConstraintSet -> ShowS
[SizeConstraintSet] -> ShowS
SizeConstraintSet -> String
(Int -> SizeConstraintSet -> ShowS)
-> (SizeConstraintSet -> String)
-> ([SizeConstraintSet] -> ShowS)
-> Show SizeConstraintSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SizeConstraintSet] -> ShowS
$cshowList :: [SizeConstraintSet] -> ShowS
show :: SizeConstraintSet -> String
$cshow :: SizeConstraintSet -> String
showsPrec :: Int -> SizeConstraintSet -> ShowS
$cshowsPrec :: Int -> SizeConstraintSet -> ShowS
Prelude.Show, (forall x. SizeConstraintSet -> Rep SizeConstraintSet x)
-> (forall x. Rep SizeConstraintSet x -> SizeConstraintSet)
-> Generic SizeConstraintSet
forall x. Rep SizeConstraintSet x -> SizeConstraintSet
forall x. SizeConstraintSet -> Rep SizeConstraintSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SizeConstraintSet x -> SizeConstraintSet
$cfrom :: forall x. SizeConstraintSet -> Rep SizeConstraintSet x
Prelude.Generic)

-- |
-- Create a value of 'SizeConstraintSet' 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:
--
-- 'name', 'sizeConstraintSet_name' - The name, if any, of the @SizeConstraintSet@.
--
-- 'sizeConstraintSetId', 'sizeConstraintSet_sizeConstraintSetId' - A unique identifier for a @SizeConstraintSet@. You use
-- @SizeConstraintSetId@ to get information about a @SizeConstraintSet@
-- (see GetSizeConstraintSet), update a @SizeConstraintSet@ (see
-- UpdateSizeConstraintSet), insert a @SizeConstraintSet@ into a @Rule@ or
-- delete one from a @Rule@ (see UpdateRule), and delete a
-- @SizeConstraintSet@ from AWS WAF (see DeleteSizeConstraintSet).
--
-- @SizeConstraintSetId@ is returned by CreateSizeConstraintSet and by
-- ListSizeConstraintSets.
--
-- 'sizeConstraints', 'sizeConstraintSet_sizeConstraints' - Specifies the parts of web requests that you want to inspect the size
-- of.
newSizeConstraintSet ::
  -- | 'sizeConstraintSetId'
  Prelude.Text ->
  SizeConstraintSet
newSizeConstraintSet :: Text -> SizeConstraintSet
newSizeConstraintSet Text
pSizeConstraintSetId_ =
  SizeConstraintSet' :: Maybe Text -> Text -> [SizeConstraint] -> SizeConstraintSet
SizeConstraintSet'
    { $sel:name:SizeConstraintSet' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sizeConstraintSetId:SizeConstraintSet' :: Text
sizeConstraintSetId = Text
pSizeConstraintSetId_,
      $sel:sizeConstraints:SizeConstraintSet' :: [SizeConstraint]
sizeConstraints = [SizeConstraint]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name, if any, of the @SizeConstraintSet@.
sizeConstraintSet_name :: Lens.Lens' SizeConstraintSet (Prelude.Maybe Prelude.Text)
sizeConstraintSet_name :: (Maybe Text -> f (Maybe Text))
-> SizeConstraintSet -> f SizeConstraintSet
sizeConstraintSet_name = (SizeConstraintSet -> Maybe Text)
-> (SizeConstraintSet -> Maybe Text -> SizeConstraintSet)
-> Lens
     SizeConstraintSet SizeConstraintSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraintSet' {Maybe Text
name :: Maybe Text
$sel:name:SizeConstraintSet' :: SizeConstraintSet -> Maybe Text
name} -> Maybe Text
name) (\s :: SizeConstraintSet
s@SizeConstraintSet' {} Maybe Text
a -> SizeConstraintSet
s {$sel:name:SizeConstraintSet' :: Maybe Text
name = Maybe Text
a} :: SizeConstraintSet)

-- | A unique identifier for a @SizeConstraintSet@. You use
-- @SizeConstraintSetId@ to get information about a @SizeConstraintSet@
-- (see GetSizeConstraintSet), update a @SizeConstraintSet@ (see
-- UpdateSizeConstraintSet), insert a @SizeConstraintSet@ into a @Rule@ or
-- delete one from a @Rule@ (see UpdateRule), and delete a
-- @SizeConstraintSet@ from AWS WAF (see DeleteSizeConstraintSet).
--
-- @SizeConstraintSetId@ is returned by CreateSizeConstraintSet and by
-- ListSizeConstraintSets.
sizeConstraintSet_sizeConstraintSetId :: Lens.Lens' SizeConstraintSet Prelude.Text
sizeConstraintSet_sizeConstraintSetId :: (Text -> f Text) -> SizeConstraintSet -> f SizeConstraintSet
sizeConstraintSet_sizeConstraintSetId = (SizeConstraintSet -> Text)
-> (SizeConstraintSet -> Text -> SizeConstraintSet)
-> Lens SizeConstraintSet SizeConstraintSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraintSet' {Text
sizeConstraintSetId :: Text
$sel:sizeConstraintSetId:SizeConstraintSet' :: SizeConstraintSet -> Text
sizeConstraintSetId} -> Text
sizeConstraintSetId) (\s :: SizeConstraintSet
s@SizeConstraintSet' {} Text
a -> SizeConstraintSet
s {$sel:sizeConstraintSetId:SizeConstraintSet' :: Text
sizeConstraintSetId = Text
a} :: SizeConstraintSet)

-- | Specifies the parts of web requests that you want to inspect the size
-- of.
sizeConstraintSet_sizeConstraints :: Lens.Lens' SizeConstraintSet [SizeConstraint]
sizeConstraintSet_sizeConstraints :: ([SizeConstraint] -> f [SizeConstraint])
-> SizeConstraintSet -> f SizeConstraintSet
sizeConstraintSet_sizeConstraints = (SizeConstraintSet -> [SizeConstraint])
-> (SizeConstraintSet -> [SizeConstraint] -> SizeConstraintSet)
-> Lens
     SizeConstraintSet
     SizeConstraintSet
     [SizeConstraint]
     [SizeConstraint]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SizeConstraintSet' {[SizeConstraint]
sizeConstraints :: [SizeConstraint]
$sel:sizeConstraints:SizeConstraintSet' :: SizeConstraintSet -> [SizeConstraint]
sizeConstraints} -> [SizeConstraint]
sizeConstraints) (\s :: SizeConstraintSet
s@SizeConstraintSet' {} [SizeConstraint]
a -> SizeConstraintSet
s {$sel:sizeConstraints:SizeConstraintSet' :: [SizeConstraint]
sizeConstraints = [SizeConstraint]
a} :: SizeConstraintSet) (([SizeConstraint] -> f [SizeConstraint])
 -> SizeConstraintSet -> f SizeConstraintSet)
-> (([SizeConstraint] -> f [SizeConstraint])
    -> [SizeConstraint] -> f [SizeConstraint])
-> ([SizeConstraint] -> f [SizeConstraint])
-> SizeConstraintSet
-> f SizeConstraintSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([SizeConstraint] -> f [SizeConstraint])
-> [SizeConstraint] -> f [SizeConstraint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SizeConstraintSet where
  parseJSON :: Value -> Parser SizeConstraintSet
parseJSON =
    String
-> (Object -> Parser SizeConstraintSet)
-> Value
-> Parser SizeConstraintSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SizeConstraintSet"
      ( \Object
x ->
          Maybe Text -> Text -> [SizeConstraint] -> SizeConstraintSet
SizeConstraintSet'
            (Maybe Text -> Text -> [SizeConstraint] -> SizeConstraintSet)
-> Parser (Maybe Text)
-> Parser (Text -> [SizeConstraint] -> SizeConstraintSet)
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
"Name")
            Parser (Text -> [SizeConstraint] -> SizeConstraintSet)
-> Parser Text -> Parser ([SizeConstraint] -> SizeConstraintSet)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SizeConstraintSetId")
            Parser ([SizeConstraint] -> SizeConstraintSet)
-> Parser [SizeConstraint] -> Parser SizeConstraintSet
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [SizeConstraint])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SizeConstraints"
                            Parser (Maybe [SizeConstraint])
-> [SizeConstraint] -> Parser [SizeConstraint]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [SizeConstraint]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable SizeConstraintSet

instance Prelude.NFData SizeConstraintSet